aboutsummaryrefslogtreecommitdiff
path: root/js/io
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
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')
-rw-r--r--js/io/system/chromeapi.js11
-rwxr-xr-xjs/io/system/coreioapi.js37
-rw-r--r--js/io/system/ninjalibrary.json6
3 files changed, 46 insertions, 8 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index f4e04a09..fb141687 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -69,9 +69,16 @@ exports.ChromeApi = Montage.create(Object.prototype, {
69 69
70 //////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////
71 // 71 //
72 directoryDelete: {//TODO: Make sure it uses a force delete 72 directoryDelete: {
73 enumerable: true, 73 enumerable: true,
74 value: function() { 74 value: function(directoryPath, callback) {
75 //
76 this.fileSystem.getDirectory(directoryPath, {}, function(dirEntry) {
77 //
78 dirEntry.removeRecursively(function() {
79 callback(true);
80 });
81 }, function (e) {callback(false)});
75 } 82 }
76 }, 83 },
77 //////////////////////////////////////////////////////////////////// 84 ////////////////////////////////////////////////////////////////////
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 ////////////////////////////////////////////////////////////////////
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
new file mode 100644
index 00000000..affb72a0
--- /dev/null
+++ b/js/io/system/ninjalibrary.json
@@ -0,0 +1,6 @@
1{
2 "libraries": [
3 {"name": "Montage", "path": "/ninja-internal/node_modules/descriptor.json", "version": "0.6.0"},
4 {"name": "RDGE", "path": "/ninja-internal/js/helper-classes/RDGE/rdge-compiled.js", "version": "0.6.0", "singular": "true"}
5 ]
6} \ No newline at end of file