aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/io/system/chromeapi.js43
-rwxr-xr-xjs/io/system/coreioapi.js13
-rw-r--r--js/io/system/ninjalibrary.js77
3 files changed, 127 insertions, 6 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index 2fc8769c..fc93b22a 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -7,11 +7,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7/* ///////////////////////////////////////////////////////////////////// 7/* /////////////////////////////////////////////////////////////////////
8//////////////////////////////////////////////////////////////////////// 8////////////////////////////////////////////////////////////////////////
9NOTES: 9NOTES:
10
10 The init function starts up the file system API, and a size must be 11 The init function starts up the file system API, and a size must be
11 set, no unlimited available as of now. 12 set, no unlimited available as of now.
12 13
13 Core API reference in NINJA: this.application.ninja.coreIoApi
14
15//////////////////////////////////////////////////////////////////////// 14////////////////////////////////////////////////////////////////////////
16///////////////////////////////////////////////////////////////////// */ 15///////////////////////////////////////////////////////////////////// */
17// 16//
@@ -123,6 +122,46 @@ exports.ChromeApi = Montage.create(Object.prototype, {
123 } 122 }
124 }, 123 },
125 //////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////
125 //
126 fileDelete: {
127 enumerable: true,
128 value: function(filePath, callback) {
129 this.fileSystem.root.getFile(filePath, {create: false}, function(file) {
130 file.remove(function() {
131 if (callback) callback(true);
132 });
133 }, function (e) {if (callback) callback(false)});
134 }
135 },
136 ////////////////////////////////////////////////////////////////////
137 //
138 fileContent: {
139 enumerable: true,
140 value: function() {
141 }
142 },
143 ////////////////////////////////////////////////////////////////////
144 //
145 fileCopy: {
146 enumerable: true,
147 value: function() {
148 }
149 },
150 ////////////////////////////////////////////////////////////////////
151 //
152 fileRename: {
153 enumerable: true,
154 value: function() {
155 }
156 },
157 ////////////////////////////////////////////////////////////////////
158 //
159 fileMove: {
160 enumerable: true,
161 value: function() {
162 }
163 },
164 ////////////////////////////////////////////////////////////////////
126 //Creating directory from path, callback optional 165 //Creating directory from path, callback optional
127 directoryNew: { 166 directoryNew: {
128 enumerable: true, 167 enumerable: true,
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 005eabf2..7edb469b 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -83,10 +83,21 @@ exports.CoreIoApi = Montage.create(Component, {
83 handleSync: { 83 handleSync: {
84 enumerable: false, 84 enumerable: false,
85 value: function (e) { 85 value: function (e) {
86 //Removing events
87 console.log('Ninja Local Library: Ready'); 86 console.log('Ninja Local Library: Ready');
87 //Removing events
88 this.ninjaLibrary.removeEventListener('sync', this, false); 88 this.ninjaLibrary.removeEventListener('sync', this, false);
89 this.ninjaLibrary.coreApi = this;
89 //TODO: Add sync loading screen logic 90 //TODO: Add sync loading screen logic
91
92
93
94
95 //TODO: Remove test
96 this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0');
97
98
99
100
90 } 101 }
91 }, 102 },
92 //////////////////////////////////////////////////////////////////// 103 ////////////////////////////////////////////////////////////////////
diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js
index fa2e7d1f..0ab19401 100644
--- a/js/io/system/ninjalibrary.js
+++ b/js/io/system/ninjalibrary.js
@@ -8,8 +8,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
8//////////////////////////////////////////////////////////////////////// 8////////////////////////////////////////////////////////////////////////
9NOTES: 9NOTES:
10 10
11 Core API reference in NINJA: this.application.ninja.coreIoApi
12
13//////////////////////////////////////////////////////////////////////// 11////////////////////////////////////////////////////////////////////////
14///////////////////////////////////////////////////////////////////// */ 12///////////////////////////////////////////////////////////////////// */
15// 13//
@@ -36,6 +34,23 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
36 }, 34 },
37 //////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////
38 // 36 //
37 _coreApi: {
38 enumerable: false,
39 value: null
40 },
41 ////////////////////////////////////////////////////////////////////
42 //
43 coreApi: {
44 enumerable: false,
45 get: function() {
46 return this._coreApi;
47 },
48 set: function(value) {
49 this._coreApi = value;
50 }
51 },
52 ////////////////////////////////////////////////////////////////////
53 //
39 _libsToSync: { 54 _libsToSync: {
40 enumerable: false, 55 enumerable: false,
41 value: 0 56 value: 0
@@ -46,6 +61,62 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
46 enumerable: false, 61 enumerable: false,
47 value: 0 62 value: 0
48 }, 63 },
64 ////////////////////////////////////////////////////////////////////
65 //
66 copyLibToCloud: {
67 enumerable: false,
68 value: function (path, libName) {
69 //
70 if(this.coreApi.directoryExists({uri: '/'+path+'/'+libName+'/'}).status === 404) {
71 this.chromeApi.directoryContents(this.chromeApi.fileSystem.root, function (contents) {
72 for (var i in contents) {
73 if (libName === contents[i].name) {
74 //Getting contents of library to be copied
75 this.chromeApi.directoryContents(contents[i], function (lib) {
76 //Creating directory structure from subfolders
77 this.copyDirectoryToCloud(path, contents[i], function (status) {console.log(status)});
78 }.bind(this));
79 break;
80 }
81 }
82 }.bind(this));
83 } else {
84 //Error
85 }
86 }
87 },
88 ////////////////////////////////////////////////////////////////////
89 //
90 copyDirectoryToCloud: {
91 enumerable: true,
92 value: function(root, folder, callback) {
93 if (folder.name) {
94 var dir;
95 if (root) {
96 dir = root+'/'+folder.name;
97 } else {
98 dir = folder.name;
99 }
100 //
101 if (!this.coreApi.createDirectory({uri: '/'+dir+'/'})) {
102 //Error occured while creating folders
103 return;
104 }
105 }
106 //
107 if (folder.isDirectory) {
108 this.chromeApi.directoryContents(folder, function (contents) {
109 for (var i in contents) {
110 if (contents[i].isDirectory) {
111 this.copyDirectoryToCloud(dir, contents[i]);
112 } else if (contents[i].isFile){
113 //File to copy
114 }
115 }
116 }.bind(this));
117 }
118 }
119 },
49 //////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////
50 // 121 //
51 synchronize: { 122 synchronize: {
@@ -81,7 +152,7 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
81 } 152 }
82 } else { 153 } else {
83 //TODO: Remove, currently manually removing copied libraries 154 //TODO: Remove, currently manually removing copied libraries
84 this.chromeApi.directoryDelete(chromeLibs[i]); 155 //this.chromeApi.directoryDelete(chromeLibs[i]);
85 } 156 }
86 } 157 }
87 158