diff options
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-x | js/io/system/coreioapi.js | 564 |
1 files changed, 282 insertions, 282 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index d3977106..121b4410 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -32,87 +32,87 @@ POSSIBILITY OF SUCH DAMAGE. | |||
32 | //////////////////////////////////////////////////////////////////////// | 32 | //////////////////////////////////////////////////////////////////////// |
33 | NOTES: | 33 | NOTES: |
34 | 34 | ||
35 | Core API reference in NINJA: this.application.ninja.coreIoApi | 35 | Core API reference in NINJA: this.application.ninja.coreIoApi |
36 | 36 | ||
37 | //////////////////////////////////////////////////////////////////////// | 37 | //////////////////////////////////////////////////////////////////////// |
38 | ///////////////////////////////////////////////////////////////////// */ | 38 | ///////////////////////////////////////////////////////////////////// */ |
39 | var Montage = require("montage/core/core").Montage, | 39 | var Montage = require("montage/core/core").Montage, |
40 | Component = require("montage/ui/component").Component, | 40 | Component = require("montage/ui/component").Component, |
41 | Popup = require("js/components/popup.reel").Popup, | 41 | Popup = require("js/components/popup.reel").Popup, |
42 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, | 42 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, |
43 | ChromeApi = require("js/io/system/chromeapi").ChromeApi, | 43 | ChromeApi = require("js/io/system/chromeapi").ChromeApi, |
44 | NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; | 44 | NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; |
45 | //////////////////////////////////////////////////////////////////////// | 45 | //////////////////////////////////////////////////////////////////////// |
46 | //Exporting as Project I/O | 46 | //Exporting as Project I/O |
47 | exports.CoreIoApi = Montage.create(Component, { | 47 | exports.CoreIoApi = Montage.create(Component, { |
48 | //////////////////////////////////////////////////////////////////// | 48 | //////////////////////////////////////////////////////////////////// |
49 | // | 49 | // |
50 | deserializedFromTemplate: { | 50 | deserializedFromTemplate: { |
51 | enumerable: false, | 51 | enumerable: false, |
52 | value: function () { | 52 | value: function () { |
53 | //////////////////////////////////////////////////////////// | 53 | //////////////////////////////////////////////////////////// |
54 | //Checking for local storage of URL for IO | 54 | //Checking for local storage of URL for IO |
55 | if (this.application.localStorage.getItem("ioRootUrl")) { | 55 | if (this.application.localStorage.getItem("ioRootUrl")) { |
56 | //Getting URL from local storage | 56 | //Getting URL from local storage |
57 | this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); | 57 | this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); |
58 | //Checks for IO API to be active | 58 | //Checks for IO API to be active |
59 | this.ioServiceDetected = this.cloudAvailable(); | 59 | this.ioServiceDetected = this.cloudAvailable(); |
60 | } else { | 60 | } else { |
61 | //IO API to be inactive | 61 | //IO API to be inactive |
62 | this.ioServiceDetected = false; | 62 | this.ioServiceDetected = false; |
63 | } | 63 | } |
64 | //////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////// |
65 | //Instance of ninja library | 65 | //Instance of ninja library |
66 | this.ninjaLibrary = NinjaLibrary; | 66 | this.ninjaLibrary = NinjaLibrary; |
67 | this.ninjaLibrary.coreApi = this; | 67 | this.ninjaLibrary.coreApi = this; |
68 | //Getting reference of chrome file system API | 68 | //Getting reference of chrome file system API |
69 | this.chromeFileSystem = ChromeApi; | 69 | this.chromeFileSystem = ChromeApi; |
70 | //Sending size in MBs for file system storage | 70 | //Sending size in MBs for file system storage |
71 | var chromeFs = this.chromeFileSystem.init(20); | 71 | var chromeFs = this.chromeFileSystem.init(20); |
72 | //Checking for availability of API | 72 | //Checking for availability of API |
73 | if (chromeFs) { | 73 | if (chromeFs) { |
74 | this.chromeFileSystem.addEventListener('ready', this, false); | 74 | this.chromeFileSystem.addEventListener('ready', this, false); |
75 | } else { | 75 | } else { |
76 | //Error, Chrome File System API not detected | 76 | //Error, Chrome File System API not detected |
77 | } | 77 | } |
78 | //////////////////////////////////////////////////////////// | 78 | //////////////////////////////////////////////////////////// |
79 | } | 79 | } |
80 | }, | 80 | }, |
81 | //////////////////////////////////////////////////////////////////// | 81 | //////////////////////////////////////////////////////////////////// |
82 | // | 82 | // |
83 | handleReady: { | 83 | handleReady: { |
84 | enumerable: false, | 84 | enumerable: false, |
85 | value: function (e) { | 85 | value: function (e) { |
86 | //Removing events | 86 | //Removing events |
87 | this.chromeFileSystem.removeEventListener('ready', this, false); | 87 | this.chromeFileSystem.removeEventListener('ready', this, false); |
88 | //Listening for library to be copied event (builds list) | 88 | //Listening for library to be copied event (builds list) |
89 | this.chromeFileSystem.addEventListener('library', this, false); | 89 | this.chromeFileSystem.addEventListener('library', this, false); |
90 | //TODO: Add sync loading screen logic (Add screen here) | 90 | //TODO: Add sync loading screen logic (Add screen here) |
91 | } | 91 | } |
92 | }, | 92 | }, |
93 | //////////////////////////////////////////////////////////////////// | 93 | //////////////////////////////////////////////////////////////////// |
94 | // | 94 | // |
95 | handleLibrary: { | 95 | handleLibrary: { |
96 | enumerable: false, | 96 | enumerable: false, |
97 | value: function (e) { | 97 | value: function (e) { |
98 | //Removing events | 98 | //Removing events |
99 | this.chromeFileSystem.removeEventListener('library', this, false); | 99 | this.chromeFileSystem.removeEventListener('library', this, false); |
100 | //Listening for synced library event | 100 | //Listening for synced library event |
101 | this.ninjaLibrary.addEventListener('sync', this, false); | 101 | this.ninjaLibrary.addEventListener('sync', this, false); |
102 | //Sending library to be synced to chrome | 102 | //Sending library to be synced to chrome |
103 | this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); | 103 | this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); |
104 | 104 | ||
105 | } | 105 | } |
106 | }, | 106 | }, |
107 | //////////////////////////////////////////////////////////////////// | 107 | //////////////////////////////////////////////////////////////////// |
108 | // | 108 | // |
109 | handleSync: { | 109 | handleSync: { |
110 | enumerable: false, | 110 | enumerable: false, |
111 | value: function (e) { | 111 | value: function (e) { |
112 | console.log('Ninja Local Library: Ready'); | 112 | console.log('Ninja Local Library: Ready'); |
113 | //Removing events | 113 | //Removing events |
114 | this.ninjaLibrary.removeEventListener('sync', this, false); | 114 | this.ninjaLibrary.removeEventListener('sync', this, false); |
115 | //TODO: Add sync loading screen logic (Remove screen here) | 115 | //TODO: Add sync loading screen logic (Remove screen here) |
116 | } | 116 | } |
117 | }, | 117 | }, |
118 | //////////////////////////////////////////////////////////////////// | 118 | //////////////////////////////////////////////////////////////////// |
@@ -124,12 +124,12 @@ exports.CoreIoApi = Montage.create(Component, { | |||
124 | //////////////////////////////////////////////////////////////////// | 124 | //////////////////////////////////////////////////////////////////// |
125 | // | 125 | // |
126 | chromeNinjaLibrary: { | 126 | chromeNinjaLibrary: { |
127 | enumerable: false, | 127 | enumerable: false, |
128 | get: function() { | 128 | get: function() { |
129 | return this._chromeNinjaLibrary; | 129 | return this._chromeNinjaLibrary; |
130 | }, | 130 | }, |
131 | set: function(value) { | 131 | set: function(value) { |
132 | this._chromeNinjaLibrary = value; | 132 | this._chromeNinjaLibrary = value; |
133 | } | 133 | } |
134 | }, | 134 | }, |
135 | //////////////////////////////////////////////////////////////////// | 135 | //////////////////////////////////////////////////////////////////// |
@@ -141,15 +141,15 @@ exports.CoreIoApi = Montage.create(Component, { | |||
141 | //////////////////////////////////////////////////////////////////// | 141 | //////////////////////////////////////////////////////////////////// |
142 | // | 142 | // |
143 | chromeFileSystem: { | 143 | chromeFileSystem: { |
144 | enumerable: false, | 144 | enumerable: false, |
145 | get: function() { | 145 | get: function() { |
146 | return this._chromeFileSystem; | 146 | return this._chromeFileSystem; |
147 | }, | 147 | }, |
148 | set: function(value) { | 148 | set: function(value) { |
149 | this._chromeFileSystem = value; | 149 | this._chromeFileSystem = value; |
150 | } | 150 | } |
151 | }, | 151 | }, |
152 | //////////////////////////////////////////////////////////////////// | 152 | //////////////////////////////////////////////////////////////////// |
153 | // | 153 | // |
154 | _ioServiceDetected: { | 154 | _ioServiceDetected: { |
155 | enumerable: false, | 155 | enumerable: false, |
@@ -158,15 +158,15 @@ exports.CoreIoApi = Montage.create(Component, { | |||
158 | //////////////////////////////////////////////////////////////////// | 158 | //////////////////////////////////////////////////////////////////// |
159 | //Checking for service availability on boot | 159 | //Checking for service availability on boot |
160 | ioServiceDetected: { | 160 | ioServiceDetected: { |
161 | enumerable: false, | 161 | enumerable: false, |
162 | get: function() { | 162 | get: function() { |
163 | return this._ioServiceDetected; | 163 | return this._ioServiceDetected; |
164 | }, | 164 | }, |
165 | set: function(value) { | 165 | set: function(value) { |
166 | this._ioServiceDetected = value; | 166 | this._ioServiceDetected = value; |
167 | } | 167 | } |
168 | }, | 168 | }, |
169 | //////////////////////////////////////////////////////////////////// | 169 | //////////////////////////////////////////////////////////////////// |
170 | //Root API URL | 170 | //Root API URL |
171 | _rootUrl: { | 171 | _rootUrl: { |
172 | enumerable: false, | 172 | enumerable: false, |
@@ -175,15 +175,15 @@ exports.CoreIoApi = Montage.create(Component, { | |||
175 | //////////////////////////////////////////////////////////////////// | 175 | //////////////////////////////////////////////////////////////////// |
176 | // | 176 | // |
177 | rootUrl: { | 177 | rootUrl: { |
178 | enumerable: false, | 178 | enumerable: false, |
179 | get: function() { | 179 | get: function() { |
180 | return this._rootUrl; | 180 | return this._rootUrl; |
181 | }, | 181 | }, |
182 | set: function(value) { | 182 | set: function(value) { |
183 | this._rootUrl = this.application.localStorage.setItem("ioRootUrl", value); | 183 | this._rootUrl = this.application.localStorage.setItem("ioRootUrl", value); |
184 | } | 184 | } |
185 | }, | 185 | }, |
186 | //////////////////////////////////////////////////////////////////// | 186 | //////////////////////////////////////////////////////////////////// |
187 | //API service URL | 187 | //API service URL |
188 | _apiServiceURL: { | 188 | _apiServiceURL: { |
189 | enumerable: false, | 189 | enumerable: false, |
@@ -192,15 +192,15 @@ exports.CoreIoApi = Montage.create(Component, { | |||
192 | //////////////////////////////////////////////////////////////////// |