From 78abacdadcaca62b9bc099369c5f89009116d07c Mon Sep 17 00:00:00 2001 From: toby Date: Sun, 12 Mar 2017 12:51:04 -0400 Subject: [PATCH] Add download button for displayFilesAsHTML files + Added bytes attribute for "file objects" in untar and unzip + Added download button on files displayed by displayFilesAsHTML --- src/js/core/Utils.js | 31 +++++++++++++++++++++++++++---- src/js/operations/Compress.js | 21 +++++++++++++-------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/js/core/Utils.js b/src/js/core/Utils.js index 9ef0b2b1..abee0c50 100755 --- a/src/js/core/Utils.js +++ b/src/js/core/Utils.js @@ -1028,20 +1028,43 @@ var Utils = { }; var formatFile = function(file, i) { + var blob = new Blob( + [new Uint8Array(file.bytes)], + {type: "octet/stream"} + ); + var blobUrl = window.URL.createObjectURL(blob); + + var downloadAnchorElem = $("") + .html("\u21B4") + .attr("href", blobUrl) + .attr("title", "Download '" + file.fileName + "'") + .attr("download", file.fileName); + + var expandFileContentsElem = $("") + .html("🔍") + .addClass("collapsed") + .attr("data-toggle", "collapse") + .attr("aria-expanded", "true") + .attr("aria-controls", "collapse" + i) + .attr("href", "#collapse" + i) + .attr("title", "Show/hide contents of '" + file.fileName + "'"); + var html = "
" + "" + "