diff options
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-x | js/io/system/coreioapi.js | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 3fb9374a..e2c2e4dd 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -17,6 +17,7 @@ var Montage = require("montage/core/core").Montage, | |||
17 | Popup = require("js/components/popup.reel").Popup, | 17 | Popup = require("js/components/popup.reel").Popup, |
18 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, | 18 | CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, |
19 | ChromeApi = require("js/io/system/chromeapi").ChromeApi; | 19 | ChromeApi = require("js/io/system/chromeapi").ChromeApi; |
20 | NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; | ||
20 | //////////////////////////////////////////////////////////////////////// | 21 | //////////////////////////////////////////////////////////////////////// |
21 | //Exporting as Project I/O | 22 | //Exporting as Project I/O |
22 | exports.CoreIoApi = Montage.create(Component, { | 23 | exports.CoreIoApi = Montage.create(Component, { |
@@ -37,6 +38,8 @@ exports.CoreIoApi = Montage.create(Component, { | |||
37 | this.ioServiceDetected = false; | 38 | this.ioServiceDetected = false; |
38 | } | 39 | } |
39 | //////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////// |
41 | //Instance of ninja library | ||
42 | this.ninjaLibrary = NinjaLibrary; | ||
40 | //Getting reference of chrome file system API | 43 | //Getting reference of chrome file system API |
41 | this.chromeFileSystem = ChromeApi; | 44 | this.chromeFileSystem = ChromeApi; |
42 | //Sending size in MBs for file system storage | 45 | //Sending size in MBs for file system storage |
@@ -55,10 +58,48 @@ exports.CoreIoApi = Montage.create(Component, { | |||
55 | handleReady: { | 58 | handleReady: { |
56 | enumerable: false, | 59 | enumerable: false, |
57 | value: function (e) { | 60 | value: function (e) { |
61 | //Removing events | ||
58 | this.chromeFileSystem.removeEventListener('ready', this, false); | 62 | this.chromeFileSystem.removeEventListener('ready', this, false); |
59 | this.chromeNinjaLibrary = this.chromeFileSystem.getLocalLibrary(); | 63 | //Listening for library to be copied event (builds list) |
64 | this.chromeFileSystem.addEventListener('library', this, false); | ||
60 | } | 65 | } |
61 | }, | 66 | }, |
67 | //////////////////////////////////////////////////////////////////// | ||
68 | // | ||
69 | handleLibrary: { | ||
70 | enumerable: false, | ||
71 | value: function (e) { | ||
72 | //Removing events | ||
73 | this.chromeFileSystem.removeEventListener('library', this, false); | ||
74 | //Listening for synced library event | ||
75 | this.ninjaLibrary.addEventListener('sync', this, false); | ||
76 | //Sending library to be synced to chrome | ||
77 | this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); | ||
78 | |||
79 | } | ||
80 | }, | ||
81 | //////////////////////////////////////////////////////////////////// | ||
82 | // | ||
83 | handleSync: { | ||
84 | enumerable: false, | ||
85 | value: function (e) { | ||
86 | console.log('Ninja Local Library: Ready'); | ||
87 | //Removing events | ||
88 | this.ninjaLibrary.removeEventListener('sync', this, false); | ||
89 | this.ninjaLibrary.coreApi = this; | ||
90 | //TODO: Add sync loading screen logic | ||
91 | |||
92 | |||
93 | |||
94 | |||
95 | //TODO: Remove test | ||
96 | this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0'); | ||
97 | |||
98 | |||
99 | |||
100 | |||
101 | } | ||
102 | }, | ||
62 | //////////////////////////////////////////////////////////////////// | 103 | //////////////////////////////////////////////////////////////////// |
63 | // | 104 | // |
64 | _chromeNinjaLibrary: { | 105 | _chromeNinjaLibrary: { |
@@ -361,15 +402,16 @@ exports.CoreIoApi = Montage.create(Component, { | |||
361 | xhr = new XMLHttpRequest(); | 402 | xhr = new XMLHttpRequest(); |
362 | // | 403 | // |
363 | xhr.open("POST", serviceURL, false); | 404 | xhr.open("POST", serviceURL, false); |
405 | xhr.responseType = "arraybuffer"; | ||
364 | if(file.contentType && file.contentType.length) | 406 | if(file.contentType && file.contentType.length) |
365 | xhr.setRequestHeader("Content-Type", file.contentType); | 407 | xhr.setRequestHeader("Content-Type", file.contentType); |
366 | else | 408 | else |
367 | xhr.setRequestHeader("Content-Type", "text/plain"); | 409 | xhr.setRequestHeader("Content-Type", "text/plain"); |
368 | 410 | ||
369 | if(file.contents && file.contents.length) | 411 | if (file.contents) |
370 | xhr.send(file.contents); | 412 | xhr.send(file.contents); |
371 | else | 413 | else |
372 | xhr.send(); | 414 | xhr.send(); |
373 | 415 | ||
374 | if (xhr.readyState === 4) { | 416 | if (xhr.readyState === 4) { |
375 | retValue.status = xhr.status; | 417 | retValue.status = xhr.status; |