From 02bda3250b120cbdb19c4ba0eff9599d61ed4b2a Mon Sep 17 00:00:00 2001 From: j433866 Date: Wed, 1 May 2019 14:46:05 +0100 Subject: [PATCH] Fix magic button. Fix download all files not working --- src/web/OutputWaiter.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/web/OutputWaiter.mjs b/src/web/OutputWaiter.mjs index a0d8c892..e7cd0d2f 100755 --- a/src/web/OutputWaiter.mjs +++ b/src/web/OutputWaiter.mjs @@ -414,9 +414,10 @@ class OutputWaiter { const fileName = window.prompt("Please enter a filename: ", "download.zip"); const fileExt = window.prompt("Please enter a file extension for the files: ", ".txt"); const zip = new Zlib.Zip(); - for (let i = 0; i < this.outputs.length; i++) { - const name = Utils.strToByteArray(this.outputs[i].inputNum + fileExt); - let out = this.getOutput(this.outputs[i].inputNum); + const inputNums = Object.keys(this.outputs); + for (let i = 0; i < inputNums.length; i++) { + const name = Utils.strToByteArray(inputNums[i] + fileExt); + let out = this.getOutput(inputNums[i]); if (typeof out === "string") { out = Utils.strToUtf8ByteArray(out); } @@ -479,6 +480,7 @@ class OutputWaiter { changeTab(inputNum, changeInput = false) { const currentNum = this.getActiveTab(); if (this.getOutput(inputNum) === -1) return; + this.hideMagicButton(); const tabsWrapper = document.getElementById("output-tabs"); const tabs = tabsWrapper.children; @@ -828,10 +830,9 @@ class OutputWaiter { */ backgroundMagic() { this.hideMagicButton(); - if (!this.app.options.autoMagic || this.getActive()) return; + if (!this.app.options.autoMagic || !this.getActive()) return; const sample = this.getActive().slice(0, 1000) || ""; - - if (sample.length) { + if (sample.length || sample.byteLength) { this.manager.background.magic(sample); } }