From 91c7c00a32bc9e5b6ecfd47e4c80d558540fa2c1 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Tue, 12 Jun 2012 08:58:26 +0200 Subject: [PATCH] Start implementing native zip reading on android. --- programs/ios/www/nativezip.js | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/programs/ios/www/nativezip.js b/programs/ios/www/nativezip.js index 89511268..d81f565c 100644 --- a/programs/ios/www/nativezip.js +++ b/programs/ios/www/nativezip.js @@ -1,15 +1,5 @@ -/*global PhoneGap, core, XMLHttpRequest*/ +/*global runtime, core, XMLHttpRequest*/ -var ZipPlugin = { - loadAsString: function (zippath, entrypath, success, fail) { - "use strict"; - return PhoneGap.exec(success, fail, "ZipClass", "loadAsString", [zippath, entrypath]); - }, - loadAsDataURL: function (zippath, entrypath, mimetype, success, fail) { - "use strict"; - return PhoneGap.exec(success, fail, "ZipClass", "loadAsDataURL", [zippath, entrypath, mimetype]); - } -}; core.Zip = function (url, entriesReadCallback) { "use strict"; // remove 'odf:' prefix @@ -26,20 +16,20 @@ core.Zip = function (url, entriesReadCallback) { var xhr = new XMLHttpRequest(); function handleResult() { var xml; - console.log("loading " + filename + " status " + xhr.status + " readyState " + xhr.readyState); + runtime.log("loading " + filename + " status " + xhr.status + " readyState " + xhr.readyState); if (xhr.readyState === 4) { xml = xhr.responseXML; - console.log("done accessing responseXML " + xml + " " + (xhr.responseText && xhr.responseText.length) + runtime.log("done accessing responseXML " + xml + " " + (xhr.responseText && xhr.responseText.length) + " " + xhr.statusText); - console.log("statusText " + xhr.statusText); + runtime.log("statusText " + xhr.statusText); if (xhr.status === 0 && !xml) { // empty files are considered as errors - callback("File " + path + " is not valid XML."); + callback("File " + filename + " is not valid XML."); } else if (xhr.status === 200 || xhr.status === 0) { try { callback(null, xml); } catch (e) { - console.log(e); + runtime.log(e); } } else { // report error @@ -53,14 +43,6 @@ core.Zip = function (url, entriesReadCallback) { }; this.loadAsDataURL = function (filename, mimetype, callback) { callback(null, "http://zipserver" + url + "?" + filename); - /* - ZipPlugin.loadAsDataURL(url, filename, mimetype, - function (content) { - callback(null, content); - }, - function (err) { callback(err, null); } - ); - */ }; this.getEntries = function () { alert("getEntries");