aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/coreioapi.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-06 16:32:15 -0800
committerJose Antonio Marquez2012-02-06 16:32:15 -0800
commit0db246b19dc0b50f4f663a147ec92c49e656ae35 (patch)
treecf50f0dcb79ba0f62d1e913845e7ecb37e4b1168 /js/io/system/coreioapi.js
parent7f77982f49c75568431ece82d53371f6335c6e39 (diff)
downloadninja-0db246b19dc0b50f4f663a147ec92c49e656ae35.tar.gz
Adding logic to copy ninja libraries
Setting up the logic to handling copying ninja required libraries into the app local file system sandbox to be used by cloud simulator.
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-xjs/io/system/coreioapi.js37
1 files changed, 31 insertions, 6 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 3be6011d..b821936f 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -66,14 +66,39 @@ exports.CoreIoApi = Montage.create(Component, {
66 handleLibrary: { 66 handleLibrary: {
67 enumerable: false, 67 enumerable: false,
68 value: function (e) { 68 value: function (e) {
69 // 69 //Removing events
70 this.chromeFileSystem.removeEventListener('library', this, false); 70 this.chromeFileSystem.removeEventListener('library', this, false);
71 // 71 //
72 if (e._event.ninjaChromeLibrary.length < 1) { 72 var xhr = new XMLHttpRequest(), libs, tocopylibs = [];
73 console.log('no libraries'); 73 //Getting known json list of libraries to copy to chrome
74 } else { 74 xhr.open("GET", '/ninja-internal/js/io/system/ninjalibrary.json', false);
75 console.log('found libraries'); 75 xhr.send();
76 } 76 //Checkng for correct reponse
77 if (xhr.readyState === 4) {
78 //Parsing json libraries
79 libs = JSON.parse(xhr.response);
80 //
81 if (e._event.ninjaChromeLibrary.length > 0) {
82 //Compare
83 } else {
84 //No library is present, must copy all
85 for (var i in libs.libraries) {
86 if (libs.libraries[i].singular) {
87 tocopylibs.push({name: String(libs.libraries[i].name+libs.libraries[i].version).toLowerCase(), path: libs.libraries[i].path, singular: true});
88 } else {
89 tocopylibs.push({name: String(libs.libraries[i].name+libs.libraries[i].version).toLowerCase(), path: libs.libraries[i].path, singular: false});
90 }
91 }
92 }
93 //
94 if (tocopylibs.length > 0) {
95 //Copy libraries
96 } else {
97 //No libraries to copy
98 }
99 } else {
100 //Error
101 }
77 } 102 }
78 }, 103 },
79 //////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////