From ad85ff92ba44fb3c8ccf24c2f1b9296804dfa8ca Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 6 Feb 2012 22:33:42 -0800 Subject: Single file library syncing Added the ability to store locally in chrome single file libraries used by Ninja. Working on adding multi-file libraries. --- js/io/system/coreioapi.js | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'js/io/system/coreioapi.js') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index b821936f..9836f33f 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -17,6 +17,7 @@ var Montage = require("montage/core/core").Montage, Popup = require("js/components/popup.reel").Popup, CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, ChromeApi = require("js/io/system/chromeapi").ChromeApi; + NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; //////////////////////////////////////////////////////////////////////// //Exporting as Project I/O exports.CoreIoApi = Montage.create(Component, { @@ -37,6 +38,8 @@ exports.CoreIoApi = Montage.create(Component, { this.ioServiceDetected = false; } //////////////////////////////////////////////////////////// + //Instance of ninja library + this.ninjaLibrary = NinjaLibrary; //Getting reference of chrome file system API this.chromeFileSystem = ChromeApi; //Sending size in MBs for file system storage @@ -69,36 +72,7 @@ exports.CoreIoApi = Montage.create(Component, { //Removing events this.chromeFileSystem.removeEventListener('library', this, false); // - 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 - } + this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3