aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/chromeapi.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-06 11:40:15 -0800
committerJose Antonio Marquez2012-02-06 11:40:15 -0800
commit295d72960cad391850803e8c4e83d5133bbe82f7 (patch)
tree5a53af8978ec982b74b01edeb125ee24f8b59234 /js/io/system/chromeapi.js
parent17bda238bc6973832394c0ba8fb08da09557931e (diff)
downloadninja-295d72960cad391850803e8c4e83d5133bbe82f7.tar.gz
Setting up library detection for Chrome File System
Diffstat (limited to 'js/io/system/chromeapi.js')
-rw-r--r--js/io/system/chromeapi.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index 6bf6b9fe..f4e04a09 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -31,6 +31,8 @@ exports.ChromeApi = Montage.create(Object.prototype, {
31 var readyEvent = document.createEvent("CustomEvent"); 31 var readyEvent = document.createEvent("CustomEvent");
32 readyEvent.initEvent('ready', true, true); 32 readyEvent.initEvent('ready', true, true);
33 this.dispatchEvent(readyEvent); 33 this.dispatchEvent(readyEvent);
34 //Building data of local Ninja Library
35 this._listNinjaChromeLibrary();
34 }.bind(this), function (e) {return false}); //Returns false on error (not able to init) 36 }.bind(this), function (e) {return false}); //Returns false on error (not able to init)
35 // 37 //
36 return true; 38 return true;
@@ -73,10 +75,17 @@ exports.ChromeApi = Montage.create(Object.prototype, {
73 } 75 }
74 }, 76 },
75 //////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////
76 // 78 //Returns the directory contents to a callback function
77 directoryContents: { 79 directoryContents: {
78 enumerable: true, 80 enumerable: true,
79 value: function() { 81 value: function(directory, callback) {
82 //Creating instance of directory reader
83 this.fileSystem.directoryReader = directory.createReader();
84 //Getting directory contents and sending results to callback
85 this.fileSystem.directoryReader.readEntries(function(results) {
86 //Calling callback with results (null if invalid directory)
87 callback(results);
88 }, function (e) {callback(null)});
80 } 89 }
81 }, 90 },
82 //////////////////////////////////////////////////////////////////// 91 ////////////////////////////////////////////////////////////////////
@@ -102,11 +111,24 @@ exports.ChromeApi = Montage.create(Object.prototype, {
102 }, 111 },
103 //////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////
104 // 113 //
105 getLocalLibrary: { 114 _listNinjaChromeLibrary: {
106 enumerable: false, 115 enumerable: false,
107 value: function () { 116 value: function () {
117 function parseLibrary (contents) {
118 //
119 var lib = [];
120 //
121
122
123
124 //Dispatching action ready event
125 var libraryEvent = document.createEvent("CustomEvent");
126 libraryEvent.initEvent('library', true, true);
127 libraryEvent.ninjaChromeLibrary = lib;
128 this.dispatchEvent(libraryEvent);
129 };
108 // 130 //
109 return {}; 131 this.directoryContents(this.fileSystem.root, parseLibrary.bind(this));
110 } 132 }
111 } 133 }
112 //////////////////////////////////////////////////////////////////// 134 ////////////////////////////////////////////////////////////////////