XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
CONTROL: return a list of drive volumes https://www.bbs.xwidget.com/viewtopic.php?f=10&t=6701 |
Page 1 of 1 |
Author: | yereverluvinuncleber [ May 27th, 2017, 3:46 am ] |
Post subject: | CONTROL: return a list of drive volumes |
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. |
Author: | yereverluvinuncleber [ June 8th, 2017, 3:29 am ] | ||
Post subject: | Re: CONTROL: return a list of drive volumes | ||
![]() I've created an example widget.
|
Author: | Jimking [ June 8th, 2017, 8:55 am ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
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..? |
Author: | yereverluvinuncleber [ June 8th, 2017, 11:08 am ] | ||
Post subject: | Re: CONTROL: return a list of drive volumes | ||
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.
|
Author: | Jimking [ June 8th, 2017, 3:11 pm ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
Ok.. Thanks |
Author: | yereverluvinuncleber [ June 9th, 2017, 12:10 am ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
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. |
Author: | yereverluvinuncleber [ June 10th, 2017, 5:05 am ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
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. |
Author: | digigamer [ June 28th, 2017, 12:19 am ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
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 |
Author: | yereverluvinuncleber [ June 28th, 2017, 12:36 am ] |
Post subject: | Re: CONTROL: return a list of drive volumes |
Very good indeed Digigamer. Are you happy for others to make changes there? Happy to contribute to the wiki. |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |