1
0
mirror of synced 2024-11-15 18:53:22 +01:00

Update Unzip to use displayFilesAsHTML

This commit is contained in:
toby 2017-02-09 12:00:36 -05:00
parent 6b8ab2bf16
commit 3bd585cabf

View File

@ -304,28 +304,29 @@ var Compress = {
password: Utils.strToByteArray(args[0]),
verify: args[1]
},
file = "",
unzip = new Zlib.Unzip(input, options),
filenames = unzip.getFilenames(),
output = "<div style='padding: 5px;'>" + filenames.length + " file(s) found</div>\n";
files = [];
output += "<div class='panel-group' id='zip-accordion' role='tablist' aria-multiselectable='true'>";
filenames.forEach(function(fileName) {
var contents = unzip.decompress(fileName);
window.uzip = unzip;
for (var i = 0; i < filenames.length; i++) {
file = Utils.byteArrayToUtf8(unzip.decompress(filenames[i]));
output += "<div class='panel panel-default'>" +
"<div class='panel-heading' role='tab' id='heading" + i + "'>" +
"<h4 class='panel-title'>" +
"<a class='collapsed' role='button' data-toggle='collapse' data-parent='#zip-accordion' href='#collapse" + i +
"' aria-expanded='true' aria-controls='collapse" + i + "'>" +
filenames[i] + "<span class='pull-right'>" + file.length.toLocaleString() + " bytes</span></a></h4></div>" +
"<div id='collapse" + i + "' class='panel-collapse collapse' role='tabpanel' aria-labelledby='heading" + i + "'>" +
"<div class='panel-body'>" +
Utils.escapeHtml(file) + "</div></div></div>";
}
contents = Utils.byteArrayToUtf8(contents);
return output + "</div>";
var file = {
fileName: fileName,
size: contents.length,
};
var isDir = contents.length === 0 && fileName.endsWith("/");
if (!isDir) {
file.contents = contents;
}
files.push(file);
});
return Utils.displayFilesAsHTML(files);
},