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/coreioapi.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'js/io/system/coreioapi.js') 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 + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3