Browse Source

Need to provide custom "readFile" and "loadXML" functions.

pull/118/head
Joachim Bauch 11 years ago
parent
commit
f7a8856143
  1. 36
      static/js/directives/odfcanvas.js

36
static/js/directives/odfcanvas.js

@ -54,6 +54,38 @@ define(['require', 'underscore', 'jquery'], function(require, _, $) { @@ -54,6 +54,38 @@ define(['require', 'underscore', 'jquery'], function(require, _, $) {
console.error("TODO(fancycode): implement read for", path);
};
var ODFCanvas_readFile = function(path, encoding, callback) {
if (typeof path === "string") {
webodf.runtime.orig_readFile.call(webodf.runtime, path, encoding, callback);
return;
}
var fp = path.file || path;
if (typeof URL !== "undefined" && URL.createObjectURL) {
var url = URL.createObjectURL(fp);
webodf.runtime.orig_readFile.call(webodf.runtime, url, encoding, callback);
return;
}
console.error("TODO(fancycode): implement readFile for", path);
};
var ODFCanvas_loadXML = function(path, callback) {
if (typeof path === "string") {
webodf.runtime.orig_loadXML.call(webodf.runtime, path, callback);
return;
}
var fp = path.file || path;
if (typeof URL !== "undefined" && URL.createObjectURL) {
var url = URL.createObjectURL(fp);
webodf.runtime.orig_loadXML.call(webodf.runtime, url, callback);
return;
}
console.error("TODO(fancycode): implement loadXML for", path);
};
var ODFCanvas_getFileSize = function(path, callback) {
if (typeof path === "string") {
webodf.runtime.orig_getFileSize.call(webodf.runtime, path, callback);
@ -162,6 +194,10 @@ define(['require', 'underscore', 'jquery'], function(require, _, $) { @@ -162,6 +194,10 @@ define(['require', 'underscore', 'jquery'], function(require, _, $) {
// monkey-patch IO functions
webodf.runtime.orig_read = webodf.runtime.read;
webodf.runtime.read = ODFCanvas_read;
webodf.runtime.orig_readFile = webodf.runtime.readFile;
webodf.runtime.readFile = ODFCanvas_readFile;
webodf.runtime.orig_loadXML = webodf.runtime.loadXML;
webodf.runtime.loadXML = ODFCanvas_loadXML;
webodf.runtime.orig_getFileSize = webodf.runtime.getFileSize;
webodf.runtime.getFileSize = ODFCanvas_getFileSize;

Loading…
Cancel
Save