aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/ninjalibrary.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-08 13:11:48 -0800
committerJose Antonio Marquez2012-02-08 13:11:48 -0800
commit4bfac53c9a77a3af35d029757eece53f4b7212ed (patch)
tree60c9881df445ada5c02ba22e5091b0bab0f92d1b /js/io/system/ninjalibrary.js
parent95808eb6ac82b8bf33de658bd135340b66a8fa29 (diff)
downloadninja-4bfac53c9a77a3af35d029757eece53f4b7212ed.tar.gz
Fixed data type issue on copying library files
Fixed the methods to allow for ArrayBuffer data to be sent, fixes saving files that are not plain text.
Diffstat (limited to 'js/io/system/ninjalibrary.js')
-rw-r--r--js/io/system/ninjalibrary.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js
index 3914ec29..7b524189 100644
--- a/js/io/system/ninjalibrary.js
+++ b/js/io/system/ninjalibrary.js
@@ -114,8 +114,18 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
114 //File to copy 114 //File to copy
115 this.chromeApi.fileContent(contents[i].fullPath, function (result) { 115 this.chromeApi.fileContent(contents[i].fullPath, function (result) {
116 // 116 //
117 this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content, contentType: result.data.type}); 117
118 //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content}); 118 /*
119var ui8a = new Uint8Array(result.content);
120 console.log(ui8a);
121
122 var blob = new window.WebKitBlobBuilder;
123 blob.append(result.content);
124*/
125 //console.log(blob.getBlob(result.data.type));
126 //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content, contentType: result.data.type});
127 //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: blob.getBlob(result.data.type), contentType: result.data.type});
128 this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content});
119 }.bind(this)); 129 }.bind(this));
120 } 130 }
121 } 131 }
@@ -187,11 +197,12 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
187 //Getting file contents 197 //Getting file contents
188 xhr = new XMLHttpRequest(); 198 xhr = new XMLHttpRequest();
189 xhr.open("GET", tocopylibs[i].path, false); 199 xhr.open("GET", tocopylibs[i].path, false);
200 xhr.responseType = "arraybuffer";
190 xhr.send(); 201 xhr.send();
191 //Checking for status 202 //Checking for status
192 if (xhr.readyState === 4) { //TODO: add check for mime type 203 if (xhr.readyState === 4) { //TODO: add check for mime type
193 //Creating new file from loaded content 204 //Creating new file from loaded content
194 //this.chromeApi.fileNew('/'+tocopylibs[i].name+'/'+tocopylibs[i].file, xhr.response, function (status) {if(status) this.libraryCopied()}.bind(this)); 205 this.chromeApi.fileNew('/'+tocopylibs[i].name+'/'+tocopylibs[i].file, xhr.response, function (status) {if(status) this.libraryCopied()}.bind(this));
195 } else { 206 } else {
196 //Error creating single file library 207 //Error creating single file library
197 } 208 }
@@ -225,6 +236,7 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
225 for (i=0; this.files[i]; i++) { 236 for (i=0; this.files[i]; i++) {
226 xhr = new XMLHttpRequest(); 237 xhr = new XMLHttpRequest();
227 xhr.open("GET", this.root+this.files[i], false); 238 xhr.open("GET", this.root+this.files[i], false);
239 xhr.responseType = "arraybuffer";
228 xhr.send(); 240 xhr.send();
229 //Checking for status 241 //Checking for status
230 if (xhr.readyState === 4) { 242 if (xhr.readyState === 4) {