aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
authorValerio Virgillito2012-08-09 12:51:01 -0700
committerValerio Virgillito2012-08-09 12:51:01 -0700
commitfae3f9f0b3f8257208c64a32f8b6f5c9b0082bf9 (patch)
tree1edab7a6311648a7052ae7ca92b3fd7d65cd4b7c /js/io
parent63e45de6eb9c19be9e262ffdda87edc6867ecef3 (diff)
parente2200a5545d6125b4c7f760cbfd39b90dea5ccb4 (diff)
downloadninja-fae3f9f0b3f8257208c64a32f8b6f5c9b0082bf9.tar.gz
Merge branch 'Document' of https://github.com/joseeight/ninja into v0.7.2
Diffstat (limited to 'js/io')
-rw-r--r--js/io/system/chromeapi.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index e33406ee..b13dd9de 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -96,7 +96,7 @@ exports.ChromeApi = Montage.create(Object.prototype, {
96 // 96 //
97 f.createWriter(function(writer) { 97 f.createWriter(function(writer) {
98 // 98 //
99 var mime, blob, type = filePath.split('.'); 99 var mime, blob, type = filePath.split('.'), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
100 type = type[type.length-1]; 100 type = type[type.length-1];
101 switch (type) { 101 switch (type) {
102 case 'bmp': 102 case 'bmp':
@@ -136,8 +136,12 @@ exports.ChromeApi = Montage.create(Object.prototype, {
136 mime = 'text/'+type; 136 mime = 'text/'+type;
137 break; 137 break;
138 } 138 }
139 // 139 //TODO: Remove version checking once Chrome version 22 is stable
140 blob = new Blob([content], {type: type}); 140 if (version > 21) {
141 blob = new Blob([new Uint8Array(content)], {type: type});
142 } else {
143 blob = new Blob([content], {type: type});
144 }
141 // 145 //
142 writer.write(blob); 146 writer.write(blob);
143 // 147 //
@@ -166,10 +170,15 @@ exports.ChromeApi = Montage.create(Object.prototype, {
166 // 170 //
167 this.fileSystem.root.getFile(filePath, {}, function(f) { 171 this.fileSystem.root.getFile(filePath, {}, function(f) {
168 f.file(function(file) { 172 f.file(function(file) {
169 var reader = new FileReader(); 173 var reader = new FileReader(), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
170 reader.onloadend = function(e) { 174 reader.onloadend = function(e) {
171 if (callback) { 175 if (callback) {
172 callback({content: this.result, data: file, file: f, url: f.toURL()}); 176 //TODO: Remove version checking once Chrome version 22 is stable
177 if (version > 21) {
178 callback({content: new Uint8Array(this.result), data: file, file: f, url: f.toURL()});
179 } else {
180 callback({content: this.result, data: file, file: f, url: f.toURL()});
181 }
173 } 182 }
174 }; 183 };
175 reader.readAsArrayBuffer(file); 184 reader.readAsArrayBuffer(file);