我正在寻找一个PhoneGap的2.3插件机器人能解压的文件夹。我发现这个插件在PhoneGap的官方repositry 但它是在PhoneGap的1.3只工作,它仅解压缩文件的一半我有一个包含50 60 HTML文件的zip文件夹。但它只能提取5至10个文件,并返回IO错误。请帮我找到的Android的解压缩插件的PhoneGap 2.3或更高版本。
I am searching for a phonegap 2.3 plugin for android which can UnZip the folder . I found this plugin at phonegap official repositry but it is working only in phonegap 1.3 And it is unzipping only half of the file i have a zip folder containing 50 60 html files . but it is extracting only 5 to 10 files and returning "IO error" . Please help me finding a unzip plugin of android for PhoneGap 2.3 or higher
我编这个插件还可以从
https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin
推荐答案
(答案更改)
临时替代的方式做,这是由JavaScript。这里的code -
Temporary alternate way to do this is by JavaScript. Here's the code-
var readFile = function(){
$("#status").html("<br/>");
var url= $("#urlToLoad").val();
var doneReading = function(zip){
extractEntries(zip);
};
var zipFile = new ZipFile(url, doneReading);
};
// this function extracts the entries from an instantiated zip
function extractEntries(zip){
$('#report').accordion('destroy');
// clear
$("#report").html('');
var extractCb = function(id) {
// this callback is invoked with the entry name, and entry text
// in my demo, the text is just injected into an accordion panel.
return (function(entryName, entryText){
var content = entryText.replace(new RegExp( "n", "g" ), "<br/>");
$("#"+id).html(content);
$("#status").append("extract cb, entry(" + entryName + ") id(" + id + ")<br/>");
$('#report').accordion('destroy');
$('#report').accordion({collapsible:true, active:false});
});
}
// for each entry in the zip, extract it.
for (var i=0; i<zip.entries.length; i++) {
var entry = zip.entries[i];
var entryInfo = "<h4><a>" + entry.name + "</a></h4>n<div>";
// contrive an id for the entry, make it unique
var randomId = "id-"+ Math.floor((Math.random() * 1000000000));
entryInfo += "<span class='inputDiv'><h4>Content:</h4><span id='" + randomId +
"'></span></span></div>n";
// insert the info for one entry as the last child within the report div
$("#report").append(entryInfo);
// extract asynchronously
entry.extract(extractCb(randomId));
}
}
附加这Click事件,也可能需要一定时间的较大的zip文件。它的工作原理与node.js的
Attach this to Click event, also it may take time for large zip files. It works with node.js
相关推荐
最新文章