aboutsummaryrefslogtreecommitdiff
path: root/js/io/system
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-05 22:46:24 -0800
committerJose Antonio Marquez2012-02-05 22:46:24 -0800
commit20803c71179bcffeaeaba4375bd06155d21dafe6 (patch)
tree7a76693bff06a293647d71f7ce5d10aae9818e6d /js/io/system
parent8c530e9291721083ba11746fc5b3da66dc692120 (diff)
downloadninja-20803c71179bcffeaeaba4375bd06155d21dafe6.tar.gz
Setting up Chrome IO class
Diffstat (limited to 'js/io/system')
-rw-r--r--js/io/system/chromeapi.js17
-rwxr-xr-xjs/io/system/coreioapi.js46
2 files changed, 53 insertions, 10 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index 04e62b11..6bf6b9fe 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -25,8 +25,14 @@ exports.ChromeApi = Montage.create(Object.prototype, {
25 if (window.webkitRequestFileSystem) { 25 if (window.webkitRequestFileSystem) {
26 //Current way to init Chrome's fileSystem API 26 //Current way to init Chrome's fileSystem API
27 window.webkitRequestFileSystem(window.PERSISTENT, size*1024*1024, function (fs) { 27 window.webkitRequestFileSystem(window.PERSISTENT, size*1024*1024, function (fs) {
28 //Storing reference to instance
28 this.fileSystem = fs; 29 this.fileSystem = fs;
29 }.bind(this)); 30 //Dispatching action ready event
31 var readyEvent = document.createEvent("CustomEvent");
32 readyEvent.initEvent('ready', true, true);
33 this.dispatchEvent(readyEvent);
34 }.bind(this), function (e) {return false}); //Returns false on error (not able to init)
35 //
30 return true; 36 return true;
31 } else { 37 } else {
32 //No fileSystem API 38 //No fileSystem API
@@ -93,6 +99,15 @@ exports.ChromeApi = Montage.create(Object.prototype, {
93 enumerable: true, 99 enumerable: true,
94 value: function() { 100 value: function() {
95 } 101 }
102 },
103 ////////////////////////////////////////////////////////////////////
104 //
105 getLocalLibrary: {
106 enumerable: false,
107 value: function () {
108 //
109 return {};
110 }
96 } 111 }
97 //////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////
98 //////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 73d9fa76..3fb9374a 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -26,15 +26,6 @@ exports.CoreIoApi = Montage.create(Component, {
26 enumerable: false, 26 enumerable: false,
27 value: function () { 27 value: function () {
28 //////////////////////////////////////////////////////////// 28 ////////////////////////////////////////////////////////////
29 //Getting reference of chrome file system API
30 this.chromeFileSystem = ChromeApi;
31 //Sending size in MBs for file system storage
32 if (this.chromeFileSystem.init(20)) {
33 //Available
34 } else {
35 //Not available
36 }
37 ////////////////////////////////////////////////////////////
38 //Checking for local storage of URL for IO 29 //Checking for local storage of URL for IO
39 if (window.localStorage['ioRootUrl']) { 30 if (window.localStorage['ioRootUrl']) {
40 //Getting URL from local storage 31 //Getting URL from local storage
@@ -46,8 +37,45 @@ exports.CoreIoApi = Montage.create(Component, {
46 this.ioServiceDetected = false; 37 this.ioServiceDetected = false;
47 } 38 }
48 //////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////
40 //Getting reference of chrome file system API
41 this.chromeFileSystem = ChromeApi;
42 //Sending size in MBs for file system storage
43 var chromeFs = this.chromeFileSystem.init(20);
44 //Checking for availability of API
45 if (chromeFs) {
46 this.chromeFileSystem.addEventListener('ready', this, false);
47 } else {
48 //Error, Chrome File System API not detected
49 }
50 ////////////////////////////////////////////////////////////
49 } 51 }
50 }, 52 },
53 ////////////////////////////////////////////////////////////////////
54 //
55 handleReady: {
56 enumerable: false,
57 value: function (e) {
58 this.chromeFileSystem.removeEventListener('ready', this, false);
59 this.chromeNinjaLibrary = this.chromeFileSystem.getLocalLibrary();
60 }
61 },
62 ////////////////////////////////////////////////////////////////////
63 //
64 _chromeNinjaLibrary: {
65 enumerable: false,
66 value: null
67 },
68 ////////////////////////////////////////////////////////////////////
69 //
70 chromeNinjaLibrary: {
71 enumerable: false,
72 get: function() {
73 return this._chromeNinjaLibrary;
74 },
75 set: function(value) {
76 this._chromeNinjaLibrary = value;
77 }
78 },
51 //////////////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////////////
52 // 80 //
53 _chromeFileSystem: { 81 _chromeFileSystem: {