From 0db246b19dc0b50f4f663a147ec92c49e656ae35 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 6 Feb 2012 16:32:15 -0800 Subject: 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. --- js/io/system/chromeapi.js | 11 +++++++++-- js/io/system/coreioapi.js | 37 +++++++++++++++++++++++++++++++------ js/io/system/ninjalibrary.json | 6 ++++++ 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 js/io/system/ninjalibrary.json (limited to 'js/io') 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, { //////////////////////////////////////////////////////////////////// // - directoryDelete: {//TODO: Make sure it uses a force delete + directoryDelete: { enumerable: true, - value: function() { + value: function(directoryPath, callback) { + // + this.fileSystem.getDirectory(directoryPath, {}, function(dirEntry) { + // + dirEntry.removeRecursively(function() { + callback(true); + }); + }, function (e) {callback(false)}); } }, //////////////////////////////////////////////////////////////////// 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, { handleLibrary: { enumerable: false, value: function (e) { - // + //Removing events this.chromeFileSystem.removeEventListener('library', this, false); // - if (e._event.ninjaChromeLibrary.length < 1) { - console.log('no libraries'); - } else { - console.log('found libraries'); - } + var xhr = new XMLHttpRequest(), libs, tocopylibs = []; + //Getting known json list of libraries to copy to chrome + xhr.open("GET", '/ninja-internal/js/io/system/ninjalibrary.json', false); + xhr.send(); + //Checkng for correct reponse + if (xhr.readyState === 4) { + //Parsing json libraries + libs = JSON.parse(xhr.response); + // + if (e._event.ninjaChromeLibrary.length > 0) { + //Compare + } else { + //No library is present, must copy all + for (var i in libs.libraries) { + if (libs.libraries[i].singular) { + tocopylibs.push({name: String(libs.libraries[i].name+libs.libraries[i].version).toLowerCase(), path: libs.libraries[i].path, singular: true}); + } else { + tocopylibs.push({name: String(libs.libraries[i].name+libs.libraries[i].version).toLowerCase(), path: libs.libraries[i].path, singular: false}); + } + } + } + // + if (tocopylibs.length > 0) { + //Copy libraries + } else { + //No libraries to copy + } + } else { + //Error + } } }, //////////////////////////////////////////////////////////////////// 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 @@ +{ + "libraries": [ + {"name": "Montage", "path": "/ninja-internal/node_modules/descriptor.json", "version": "0.6.0"}, + {"name": "RDGE", "path": "/ninja-internal/js/helper-classes/RDGE/rdge-compiled.js", "version": "0.6.0", "singular": "true"} + ] +} \ No newline at end of file -- cgit v1.2.3