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) | 405 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/fileio.js | 175 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/filesystem.js | 78 | ||||
-rwxr-xr-x[-rw-r--r--] | js/io/system/projectio.js | 0 |
5 files changed, 485 insertions, 179 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..6b803f22 100644..100755 --- a/js/io/system/shellapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -6,104 +6,206 @@ 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, { |
19 | //////////////////////////////////////////////////////////////////// | ||
20 | // | ||
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 | // | ||
31 | console.log('Cloud Status: URL detected in localStorage as '+this.rootUrl); | ||
32 | } else { | ||
33 | // | ||
34 | this.ioServiceDetected = false; | ||
35 | console.log('Cloud Status: No URL detected in localStorage'); | ||
36 | } | ||
37 | } | ||
38 | }, | ||
39 | //////////////////////////////////////////////////////////////////// | ||
40 | //Method to check status of I/O API, will return false if not active | ||
41 | cloudAvailable: { | ||
42 | enumerable: false, | ||
43 | value: function () { | ||
44 | // | ||
45 | if (this.rootUrl && this.getCloudStatus().status === 200) { | ||
46 | //Active | ||
47 | return true; | ||
48 | } else { | ||
49 | //Inactive | ||
50 | if (!this._cloudDialogOpen && this.application.ninja) { | ||
51 | this.showCloudDialog(); | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | }, | ||
24 | //////////////////////////////////////////////////////////////////// | 57 | //////////////////////////////////////////////////////////////////// |
25 | // | 58 | // |
26 | init: { | 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 | _cloudDialogComponents: { |
33 | xhr.send(); | 66 | enumerable: false, |
67 | value: {blackout: null, popup: null, dialog: null} | ||
68 | }, | ||
69 | //////////////////////////////////////////////////////////////////// | ||
70 | // | ||
71 | showCloudDialog: { | ||
72 | enumerable: false, | ||
73 | value: function () { | ||
74 | // | ||
75 | this._cloudDialogOpen = true; | ||
76 | // | ||
77 | this._cloudDialogComponents.blackout = document.createElement('div'); | ||
78 | this._cloudDialogComponents.blackout.style.width = '100%'; | ||
79 | this._cloudDialogComponents.blackout.style.height = '100%'; | ||
80 | this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)'; | ||
81 | this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout); | ||
82 | // | ||
83 | //////////////////////////////////////////////////// | ||
84 | //Creating popup from m-js component | ||
85 | var popup = document.createElement('div'); | ||
86 | // | ||
87 | this._cloudDialogComponents.dialog = CloudPopup.create(); | ||
88 | // | ||
89 | document.body.appendChild(popup); | ||
90 | // | ||
91 | this._cloudDialogComponents.dialog.element = popup; | ||
92 | this._cloudDialogComponents.dialog.needsDraw = true; | ||
93 | this._cloudDialogComponents.dialog.element.style.opacity = 0; | ||
94 | // | ||
95 | this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false); | ||
96 | } | ||
97 | }, | ||
98 | //////////////////////////////////////////////////////////////////// | ||
99 | // | ||
100 | handleFirstDraw: { | ||
101 | value: function (e) { | ||
102 | if (e._target._element.className === 'cloud_popup') { | ||
103 | this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false); | ||
104 | // | ||
105 | this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'}); | ||
106 | this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false); | ||
107 | } else { | ||
34 | // | 108 | // |
35 | if (xhr.readyState === 4) { | 109 | this._cloudDialogComponents.dialog.element.style.opacity = 1; |
36 | file = xhr.responseXML.getElementsByTagName('file')[0].firstChild.nodeValue; | 110 | this._cloudDialogComponents.popup.element.style.opacity = 1; |
37 | directory = xhr.responseXML.getElementsByTagName('directory')[0].firstChild.nodeValue; | 111 | this._cloudDialogComponents.popup.element.style.margin = '-100px 0px 0px -190px'; |
38 | if (file.length) | 112 | } |
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 | } | 113 | } |
50 | }, | 114 | }, |
51 | //////////////////////////////////////////////////////////////////// | 115 | //////////////////////////////////////////////////////////////////// |
52 | // | 116 | // |
53 | openShellDialog: { | 117 | hideCloudDialog: { |
54 | enumerable: false, | 118 | enumerable: false, |
55 | value: function(dialog) { | 119 | value: function () { |
56 | //Initializing return variable | 120 | // |
57 | var input = null; | 121 | this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.blackout); |
58 | //Checking for the type of prompt set via object | 122 | this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.popup.element); |
59 | switch (dialog.type) { | 123 | } |
60 | case 'file': | 124 | }, |
61 | //Checking for action the prompt will ask the user | 125 | //////////////////////////////////////////////////////////////////// |
62 | if (dialog.action.toLowerCase() == 'open') { | 126 | // |
63 | //File open dialog | 127 | _ioServiceDetected: { |
64 | input = window.NativeShellApp.ShowFileOpenDialog(); | 128 | enumerable: false, |
65 | } else if (dialog.action.toLowerCase() == 'new') { | 129 | value: false |
66 | //File new dialog | 130 | }, |
67 | input = window.NativeShellApp.ShowFileSaveAsDialog(); | 131 | //////////////////////////////////////////////////////////////////// |
68 | } | 132 | //Checking for service availability on boot |
69 | break; | 133 | ioServiceDetected: { |
70 | case 'directory': | 134 | enumerable: false, |
71 | //Checking for action the prompt will ask the user | 135 | get: function() { |
72 | if (dialog.action.toLowerCase() == 'open') { | 136 | return this._ioServiceDetected; |
73 | //Directory open dialog | 137 | }, |
74 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | 138 | set: function(value) { |
75 | } else if (dialog.action.toLowerCase() == 'new') { | 139 | this._ioServiceDetected = value; |
76 | //Directory new dialog | 140 | } |
77 | input = window.NativeShellApp.ShowSelectDirectoryDialog(); | 141 | }, |
78 | } | 142 | //////////////////////////////////////////////////////////////////// |
79 | break; | 143 | //Root API URL |
80 | break; | 144 | _rootUrl: { |
81 | default: | 145 | enumerable: false, |
82 | break; | 146 | value: null |
83 | } | 147 | }, |
84 | return input; | 148 | //////////////////////////////////////////////////////////////////// |
85 | } | 149 | // |
150 | rootUrl: { | ||
151 | enumerable: false, | ||
152 | get: function() { | ||
153 | return this._rootUrl; | ||
154 | }, | ||
155 | set: function(value) { | ||
156 | this._rootUrl = window.localStorage["ioRootUrl"] = value; | ||
157 | } | ||
158 | }, | ||
159 | //////////////////////////////////////////////////////////////////// | ||
160 | //API service URL | ||
161 | _apiServiceURL: { | ||