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]), password: Utils.strToByteArray(args[0]),
verify: args[1] verify: args[1]
}, },
file = "",
unzip = new Zlib.Unzip(input, options), unzip = new Zlib.Unzip(input, options),
filenames = unzip.getFilenames(), 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; contents = Utils.byteArrayToUtf8(contents);
for (var i = 0; i < filenames.length; i++) {
file = Utils.byteArrayToUtf8(unzip.decompress(filenames[i])); var file = {
output += "<div class='panel panel-default'>" + fileName: fileName,
"<div class='panel-heading' role='tab' id='heading" + i + "'>" + size: contents.length,
"<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 + "'>" + var isDir = contents.length === 0 && fileName.endsWith("/");
filenames[i] + "<span class='pull-right'>" + file.length.toLocaleString() + " bytes</span></a></h4></div>" + if (!isDir) {
"<div id='collapse" + i + "' class='panel-collapse collapse' role='tabpanel' aria-labelledby='heading" + i + "'>" + file.contents = contents;
"<div class='panel-body'>" +
Utils.escapeHtml(file) + "</div></div></div>";
} }
return output + "</div>"; files.push(file);
});
return Utils.displayFilesAsHTML(files);
}, },