XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Nov 19日 09:41

All times are UTC - 8 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 2017年 May 27日 03:46 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
Xwidget does not have a function to return a list of drive volumes.

This code mimics the yahoo widget filesystem.volumes function using activeX. Dropping this code into your script.js file will provide this functionality.

Code:
//==============================================================
// this function is the ActiveX version of filesystem.volumes function;
//==============================================================
function filesystemVolumes() {
    var nobj, result, n, e, x;
    result = "";
    nobj = new ActiveXObject("Scripting.FileSystemObject");
    e = new Enumerator(nobj.Drives);
    for (; !e.atEnd(); e.moveNext()) {
        x = e.item();
        result = ''+result + x.DriveLetter+':';
        result += " - ";
        if (x.DriveType == 3) n = x.ShareName;
        else if (x.IsReady)
        n = x.VolumeName;
    else n = "(Not ready)"; result += n + "|";
  }
  // change the string to an array
  result = result.split("|");
  return(result);
}
//=====================
//End function
//=====================


How would you use it?

Example:
Code:
    var vols = filesystemVolumes();       //var vols = filesystem.volumes;

    //print (" drives = "+ drives);

    //count the drive volumes, create new images for each drive
    for (a in vols) {
        if (vols.hasOwnProperty(a)) {
            volscnt = Number(a);
            //nn =  vols[a].substr(0,2)  ;
       if (debugFlg == 1) {print ("drives available "+vols[a].substr(0,2) )};
            if (preferencesMusicFolderPrefValue.text == vols[a].substr(0,2)) {
       if (debugFlg == 1) {print ("restricting access to the root")};
            preferencesMusicFolderPrefValue.text = "C:\\Users\\Public\\Music";
                 //C:\\Documents and Settings\\All Users\\Documents\\My Music";
            }
        }
    }



Naming the new function filesystemVolumes means that any conversion of an Yahoo widget that uses the filesystem.volumes code is much easier. These type of translated functions can be added to any Xwidget and the simple removal of a '.' will make the old yahoo widget code compatible.


Top
 Profile  
 
PostPosted: 2017年 Jun 8日 03:29 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
Image

I've created an example widget.


Attachments:
filesystemVolumes.xwp [24.84 KiB]
Downloaded 24 times
Top
 Profile  
 
PostPosted: 2017年 Jun 8日 08:55 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4555
yereverluvinuncleber what exactly does this script because he designer gives you the possibility to select and visualize other drive volumes than C:\
and create widgets with multiple volumes at the same time, change them, edit their names..
It's about having them as a list with their extended names..?

_________________
Image
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: 2017年 Jun 8日 11:08 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
FilesystemVolumes returns a list of volumes. That's it. A useful piece of functionality that Xwidget currently appears not to support.

So, if you have some code that requires the filesystem.volumes function then it is not available unless it is implemented in ActiveX/.js. This code shows you how to regain that functionality.

Xwidget is missing a number of fundamental controls/functions that are fairly easy to implement in javascript but really ought to be implemented in C++ as part of Xwidget's functions. They are already documented, see the konfabulator documentation attached below or you could view any other engine's documentation. The good thing here is that the work has already been done to define the functionality and document it.

The yahoo widget engine provides a lot of documented functionality that is also available to other engines. Using the Yahoo widget engine's documentation is a very good guide to the sort of base filesystem functionality that Xwidget should be providing by default. It would provide backward compatibility, a useful supply of existing documentation and useful functionality for Xwidget's future.

filesystem.volumes
An array of currently mounted volumes
Description
The volumes attribute of the filesystem object contains an array of all the currently mounted volumes.


Attachments:
Konfabulator Reference 4.5.zip [2.1 MiB]
Downloaded 32 times
Top
 Profile  
 
PostPosted: 2017年 Jun 8日 15:11 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4555
Ok.. Thanks

_________________
Image
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: 2017年 Jun 9日 00:10 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
These controls that I have written using activeX have simply given Xwidget YWE filesystem functions that I have found useful in my widgets, functions that I have previously used. My versions may not be perfect or complete but they are good enough at the moment. As I convert my yahoo widgets (see my blog on DA) I am replicating this functionality so that future conversion of widgets becomes easier and easier. I will attempt to replicate each filesystem function but that will take time and as I said, it would be much better if Tony used the YW documentation and replicated each filesystem function using the YWE documentation as a roadmap and a guide.

The YW engine did it all VERY well, covered all the bases, it is an incredibly good starting point for Tony to complete Xwidget, a good roadmap that might get Tony back on track. That is what I am demonstrating here.


Top
 Profile  
 
PostPosted: 2017年 Jun 10日 05:05 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
Cores are quite clumsy and they are undocumented. How to manipulate cores from javascript? It is not explained anywhere. The API should be exposed and documented so that the same functions are available from javascript. The Xwidget documentation shows how to do this and gives full documentation.

Cores are fine for noobs but... they are limited and sometimes very clunky in operation.

Xwidget has this fantastic javascript engine built in. It is WASTED here in Xwidgets but is SO powerful that if the world realised that you can run your javascript web code on the desktop and obtain access to the file system functions then it could be a game-changer for many developers.

We need to improve Xwidget, not the cores but exposing the core APIs to javascript. They may be exposed already but they are undocumented.

IF Tony uses the Xwidget documentation as a guide then all he needs to do is code - just as I have done using activeX and javascript in the example above.


Top
 Profile  
 
PostPosted: 2017年 Jun 28日 00:19 
Offline
User avatar

Joined: 2013年 Mar 8日 22:27
Posts: 357
Posted this here: http://docs.xwidget.com/index.php?title ... ve_volumes

See the source how to properly add snippets to docs

List of all snippets on docs: http://docs.xwidget.com/index.php?title ... e_Snippets

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: 2017年 Jun 28日 00:36 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 571
Very good indeed Digigamer. Are you happy for others to make changes there? Happy to contribute to the wiki.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Powered by phpBB® Forum Software © phpBB Group