diff options
Diffstat (limited to 'js/io/system')
-rw-r--r-- | js/io/system/config.xml | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/coreioapi.js (renamed from js/io/system/shellapi.js) | 416 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/fileio.js | 196 | ||||
-rw-r--r-- | js/io/system/filesystem.js | 723 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/projectio.js | 70 |
5 files changed, 527 insertions, 884 deletions
diff --git a/js/io/system/config.xml b/js/io/system/config.xml deleted file mode 100644 index 4660d647..00000000 --- a/js/io/system/config.xml +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!-- COPY TO 'MainApp/cloud' and set your own URLs --> | ||
3 | <services> | ||
4 | <file><![CDATA[http://file.services.ninja.motorola.com/]]></file> | ||
5 | <directory><![CDATA[http://directory.services.ninja.motorola.com/]]></directory> | ||
6 | </services> | ||
diff --git a/js/io/system/shellapi.js b/js/io/system/coreioapi.js index 9976dbed..f0ca568f 100644..100755 --- a/js/io/system/shellapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -6,104 +6,212 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | /* ///////////////////////////////////////////////////////////////////// | 7 | /* ///////////////////////////////////////////////////////////////////// |
8 | //////////////////////////////////////////////////////////////////////// | 8 | //////////////////////////////////////////////////////////////////////// |
9 | NOTES: All logic should be handled in the FileSystem and I/O classes | 9 | NOTES: |
10 | |||
11 | Dialog methods on NativeShellApp | ||
12 | ShowFileOpenDialog(initialDir) - shows a file open dialog | ||
13 | initialDir is optional and if specified will cause the dialog to initially display that directory as the open location | ||
14 | ShowFileSaveAsDialog(initialURI) - shows a file Save As dialog | ||
15 | initialURI is optional and if specified will cause the dialog to initially display the directory as the default location | ||
16 | and the filename as the current filename. | ||
17 | ShowSelectDirectoryDialog(initialDir, dialogTitle) - displays a directory select/chooser dialog | ||
18 | intitalDir is optional and specifies the directory that should be selected/shown when the dialog opens | ||
19 | dialogTitle is optional and specifies the title that should appear in the dialog caption | ||
20 | //////////////////////////////////////////////////////////////////////// | 10 | //////////////////////////////////////////////////////////////////////// |
21 | ///////////////////////////////////////////////////////////////////// */ | 11 | ///////////////////////////////////////////////////////////////////// */ |
12 | var Montage = require("montage/core/core").Montage, | ||
13 | Component = require("montage/ui/component").Component, | ||
14 | Popup = require("js/components/popup.reel").Popup, | ||
15 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup; | ||
16 | //////////////////////////////////////////////////////////////////////// | ||
22 | //Exporting as Project I/O | 17 | //Exporting as Project I/O |
23 | exports.ShellApi = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { | 18 | exports.CoreIoApi = Montage.create(Component, { |
24 | //////////////////////////////////////////////////////////////////// | 19 | //////////////////////////////////////////////////////////////////// |
25 | // | 20 | // |
26 | init: { | 21 | deserializedFromTemplate: { |
22 | enumerable: false, | ||
23 | value: function () { | ||
24 | //Checking for local storage of URL for IO | ||
25 | if (window.localStorage['ioRootUrl']) { | ||
26 | //Getting URL from local storage | ||
27 | this.rootUrl = window.localStorage['ioRootUrl']; | ||
28 | //Checks for IO API to be active | ||
29 | this.ioServiceDetected = this.cloudAvailable(); | ||
30 | } else { | ||
31 | //IO API to be inactive | ||
32 | this.ioServiceDetected = false; | ||
33 | } | ||
34 | } | ||
35 | }, | ||
36 | //////////////////////////////////////////////////////////////////// | ||
37 | //Method to check status of I/O API, will return false if not active | ||
38 | cloudAvailable: { | ||
39 | enumerable: false, | ||
40 | value: function () { | ||
41 | var cloud = this.getCloudStatus(); | ||
42 | // | ||
43 | if (this.rootUrl && cloud.status === 200) { | ||
44 | //Active | ||
45 | this.cloudData.name = cloud.response['name']; | ||
46 | this.cloudData.root = cloud.response['server-root']; | ||
47 | return true; | ||
48 | } else { | ||
49 | //Inactive | ||
50 | if (!this._cloudDialogOpen && this.application.ninja) { | ||
51 | this.showCloudDialog(); | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | }, | ||
57 | //////////////////////////////////////////////////////////////////// | ||
58 | // | ||
59 | _cloudDialogOpen: { | ||
27 | enumerable: false, | 60 | enumerable: false, |
28 | value: function() { | 61 | value: false |
29 | try { | 62 | }, |
30 | var xhr = new XMLHttpRequest(), file, directory; | 63 | //////////////////////////////////////////////////////////////////// |
31 | // | 64 | // |
32 | xhr.open("GET", 'cloud/config.xml', false); | 65 | cloudData: { |
33 | xhr.send(); | 66 | enumerable: false, |
67 | value: {name: null, root: ''} | ||
68 | }, | ||
69 | //////////////////////////////////////////////////////////////////// | ||
70 | // | ||
71 | _cloudDialogComponents: { | ||
72 | enumerable: false, | ||
73 | value: {blackout: null, popup: null, dialog: null} | ||
74 | }, | ||
75 | //////////////////////////////////////////////////////////////////// | ||
76 | // | ||
77 | showCloudDialog: { | ||
78 | enumerable: false, | ||
79 | value: function () { | ||
80 | // | ||
81 | this._cloudDialogOpen = true; | ||
82 | // | ||
83 | this._cloudDialogComponents.blackout = document.createElement('div'); | ||
84 | this._cloudDialogComponents.blackout.style.width = '100%'; | ||
85 | this._cloudDialogComponents.blackout.style.height = '100%'; | ||
86 | this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)'; | ||
87 | this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout); | ||
88 | // | ||
89 | //////////////////////////////////////////////////// | ||
90 | //Creating popup from m-js component | ||
91 | var popup = document.createElement('div'); | ||
92 | // | ||
93 | this._cloudDialogComponents.dialog = CloudPopup.create(); | ||
94 | // | ||
95 | document.body.appendChild(popup); | ||
96 | // | ||
97 | this._cloudDialogComponents.dialog.element = popup; | ||
98 | this._cloudDialogComponents.dialog.needsDraw = true; | ||
99 | this._cloudDialogComponents.dialog.element.style.opacity = 0; | ||
100 | // | ||
101 | this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false); | ||
102 | } | ||
103 | }, | ||
104 | //////////////////////////////////////////////////////////////////// | ||
105 | // | ||
106 | handleFirstDraw: { | ||
107 | value: function (e) { | ||
108 | if (e._target._element.className === 'cloud_popup') { | ||
109 | this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false); | ||
110 | // | ||
111 | this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'}); | ||
112 | this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false); | ||
113 | } else { | ||
34 | // | 114 | // |
35 | if (xhr.readyState === 4) { | 115 | this._cloudDialogComponents.dialog.element.style.opacity = 1; |
36 | file = xhr.responseXML.getElementsByTagName('file')[0].firstChild.nodeValue; | 116 | this._cloudDialogComponents.popup.element.style.opacity = 1; |
37 | directory = xhr.responseXML.getElementsByTagName('directory')[0].firstChild.nodeValue; | 117 | this._cloudDialogComponents.popup.element.style.margin = '-100px 0px 0px -190px'; |
38 | if (file.length) | 118 | } |
39 | this._fileServiceURL = file; | ||
40 | if (directory.length) | ||
41 | this._directoryServiceURL = directory; | ||
42 | // | ||
43 | //console.log(file, directory); | ||
44 | } | ||
45 | } | ||
46 | catch(error) { | ||
47 | console.log(error); | ||
48 | } | ||
49 | } | 119 | } |
50 | }, | 120 | }, |
51 | //////////////////////////////////////////////////////////////////// | 121 | //////////////////////////////////////////////////////////////////// |
52 | // | 122 | // |
53 | openShellDialog: { | 123 | hideCloudDialog: { |
54 | enumerable: false, | 124 | enumerable: false, |
55 | value: function(dialog) { | 125 | value: function () { |
56 | //Initializing return variable | 126 | // |
57 | var input = null; | 127 | this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.blackout); |
58 | //Checking for the type of prompt set via object | 128 | this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.popup.element); |
59 | switch (dialog.type) { | 129 | } |
60 | case 'file': | 130 | }, |
61 | //Checking for action the prompt will ask the user | 131 | //////////////////////////////////////////////////////////////////// |
62 | if (dialog.action.toLowerCase() == 'open') { | 132 | // |
63 | //File open dialog | 133 | _ioServiceDetected: { |
64 | input = window.NativeShellApp.ShowFileOpenDialog(); | 134 | enumerable: false, |
65 | } else if (dialog.action.toLowerCase() == 'new') { | 135 | value: false |
66 | //File new dialog | 136 | }, |
67 | input = window.NativeShellApp.ShowFileSaveAsDialog(); | 137 | //////////////////////////////////////////////////////////////////// |
68 | } | 138 | //Checking for service availability on boot |
69 | break; | 139 | ioServiceDetected: { |
70 | case 'directory': | 140 | enumerable: false, |
71 | //Checking for action the prompt will ask the user | 141 | get: function() { |
72 | if (dialog.action.toLowerCase() == 'open') { | 142 | return this._ioServiceDetected; |
73 | //Directory open dialog | 143 | }, |
74 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | 144 | set: function(value) { |
75 | } else if (dialog.action.toLowerCase() == 'new') { | 145 | this._ioServiceDetected = value; |
76 | //Directory new dialog | 146 | } |
77 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | 147 | }, |
78 | } | 148 | //////////////////////////////////////////////////////////////////// |
79 | break; | 149 | //Root API URL |
80 | break; | 150 | _rootUrl: { |
81 | default: | 151 | enumerable: false, |
82 | break; | 152 | value: null |
83 | } | 153 | }, |
84 | return input; | 154 | //////////////////////////////////////////////////////////////////// |
85 | } | 155 | // |
156 | rootUrl: { | ||
157 | enumerable: false, | ||
158 | get: function() { | ||
159 | return this._rootUrl; | ||
160 | }, | ||
161 | set: function(value) { | ||