From 78abacdadcaca62b9bc099369c5f89009116d07c Mon Sep 17 00:00:00 2001 From: toby Date: Sun, 12 Mar 2017 12:51:04 -0400 Subject: [PATCH 1/2] 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 = "
" + "" + "
Date: Tue, 21 Mar 2017 23:06:51 +0000 Subject: [PATCH 2/2] Removed jQuery and reference to window object from Utils code. --- src/js/core/Utils.js | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/js/core/Utils.js b/src/js/core/Utils.js index abee0c50..405249a1 100755 --- a/src/js/core/Utils.js +++ b/src/js/core/Utils.js @@ -1032,32 +1032,26 @@ var Utils = { [new Uint8Array(file.bytes)], {type: "octet/stream"} ); - var blobUrl = window.URL.createObjectURL(blob); + var blobUrl = URL.createObjectURL(blob); - var downloadAnchorElem = $("") - .html("\u21B4") - .attr("href", blobUrl) - .attr("title", "Download '" + file.fileName + "'") - .attr("download", file.fileName); + var downloadAnchorElem = "\u21B4"; - 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 expandFileContentsElem = "🔍"; var html = "
" + "