aboutsummaryrefslogtreecommitdiff
path: root/js/io/system
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/system')
-rw-r--r--js/io/system/config.xml6
-rwxr-xr-x[-rw-r--r--]js/io/system/coreioapi.js (renamed from js/io/system/shellapi.js)400
-rwxr-xr-x[-rw-r--r--]js/io/system/fileio.js175
-rwxr-xr-x[-rw-r--r--]js/io/system/filesystem.js78
-rwxr-xr-x[-rw-r--r--]js/io/system/projectio.js0
5 files changed, 480 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..4407d59a 100644..100755
--- a/js/io/system/shellapi.js
+++ b/js/io/system/coreioapi.js
@@ -6,104 +6,201 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7/* ///////////////////////////////////////////////////////////////////// 7/* /////////////////////////////////////////////////////////////////////
8//////////////////////////////////////////////////////////////////////// 8////////////////////////////////////////////////////////////////////////
9NOTES: All logic should be handled in the FileSystem and I/O classes 9NOTES:
10
11Dialog methods on NativeShellApp
12ShowFileOpenDialog(initialDir) - shows a file open dialog
13initialDir is optional and if specified will cause the dialog to initially display that directory as the open location
14ShowFileSaveAsDialog(initialURI) - shows a file Save As dialog
15initialURI is optional and if specified will cause the dialog to initially display the directory as the default location
16and the filename as the current filename.
17ShowSelectDirectoryDialog(initialDir, dialogTitle) - displays a directory select/chooser dialog
18intitalDir is optional and specifies the directory that should be selected/shown when the dialog opens
19dialogTitle is optional and specifies the title that should appear in the dialog caption
20//////////////////////////////////////////////////////////////////////// 10////////////////////////////////////////////////////////////////////////
21///////////////////////////////////////////////////////////////////// */ 11///////////////////////////////////////////////////////////////////// */
12var 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
23exports.ShellApi = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { 18exports.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._cloudDialogComponents.blackout = document.createElement('div');
76 this._cloudDialogComponents.blackout.style.width = '100%';
77 this._cloudDialogComponents.blackout.style.height = '100%';
78 this._cloudDialogComponents.blackout.style.background = 'rgba(0, 0, 0, .6)';
79 this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout);
80 //
81 ////////////////////////////////////////////////////
82 //Creating popup from m-js component
83 var popup = document.createElement('div');
84 //
85 this._cloudDialogComponents.dialog = CloudPopup.create();
86 //
87 document.body.appendChild(popup);
88 //
89 this._cloudDialogComponents.dialog.element = popup;
90 this._cloudDialogComponents.dialog.needsDraw = true;
91 this._cloudDialogComponents.dialog.element.style.opacity = 0;
92 //
93 this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false);
94 }
95 },
96
97 handleFirstDraw: {
98 value: function (e) {
99 if (e._target._element.className === 'cloud_popup') {
100 this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false);
101 //
102 this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '200px', y: '200px'});
103 this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false);
104 } else {
34 // 105 //
35 if (xhr.readyState === 4) { 106 this._cloudDialogComponents.dialog.element.style.opacity = 1;
36 file = xhr.responseXML.getElementsByTagName('file')[0].firstChild.nodeValue; 107 this._cloudDialogComponents.popup.element.style.opacity = 1;
37 directory = xhr.responseXML.getElementsByTagName('directory')[0].firstChild.nodeValue; 108 }
38 if (file.length)
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 } 109 }
50 }, 110 },
111
112
51 //////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////
52 // 114 //
53 openShellDialog: { 115 hideCloudDialog: {
54 enumerable: false, 116 enumerable: false,
55 value: function(dialog) { 117 value: function () {
56 //Initializing return variable 118 }
57 var input = null; 119 },
58 //Checking for the type of prompt set via object 120 ////////////////////////////////////////////////////////////////////
59 switch (dialog.type) { 121 //
60 case 'file': 122 _ioServiceDetected: {
61 //Checking for action the prompt will ask the user 123 enumerable: false,
62 if (dialog.action.toLowerCase() == 'open') { 124 value: false
63 //File open dialog 125 },
64 input = window.NativeShellApp.ShowFileOpenDialog(); 126 ////////////////////////////////////////////////////////////////////
65 } else if (dialog.action.toLowerCase() == 'new') { 127 //Checking for service availability on boot
66 //File new dialog 128 ioServiceDetected: {
67 input = window.NativeShellApp.ShowFileSaveAsDialog(); 129 enumerable: false,
68 } 130 get: function() {
69 break; 131 return this._ioServiceDetected;
70 case 'directory': 132 },
71 //Checking for action the prompt will ask the user 133 set: function(value) {
72 if (dialog.action.toLowerCase() == 'open') { 134 this._ioServiceDetected = value;
73 //Directory open dialog 135 }
74 input = window.NativeShellApp.ShowSelectDirectoryDialog(); 136 },
75 } else if (dialog.action.toLowerCase() == 'new') { 137 ////////////////////////////////////////////////////////////////////
76 //Directory new dialog 138 //Root API URL
77 input = window.NativeShellApp.ShowSelectDirectoryDialog(); 139 _rootUrl: {
78 } 140 enumerable: false,
79 break; 141 value: null
80 break;
81 default:
82 break;
83 }
84 return input;
85 }
86 }, 142 },
87 //////////////////////////////////////////////////////////////////// 143 ////////////////////////////////////////////////////////////////////
88 // 144 //
89 startServer: { 145 rootUrl: {
90 enumerable: false, 146 enumerable: false,
91 value: function (dir) { 147 get: function() {
92 var server = window.NativeShellApp.StartWebServer(dir); 148 return this._rootUrl;
93 return server; 149 },
150 set: function(value) {
151 this._rootUrl = window.localStorage["ioRootUrl"] = value;
94 } 152 }
95 }, 153 },
96 //////////////////////////////////////////////////////////////////// 154 ///