From de1b1a97b2991fe96495fe07bcde74efb57eb3ff Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Sun, 1 Aug 2021 13:38:44 +0200 Subject: [PATCH] Only load qr code when popup is open --- res/include/script/file_viewer/QRCodeWindow.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/res/include/script/file_viewer/QRCodeWindow.js b/res/include/script/file_viewer/QRCodeWindow.js index f4b8e2f..b0d7cec 100644 --- a/res/include/script/file_viewer/QRCodeWindow.js +++ b/res/include/script/file_viewer/QRCodeWindow.js @@ -1,6 +1,7 @@ function QRCodeWindow(viewer) { this.viewer = viewer this.visible = false + this.src = "" this.modal = new Modal( document.getElementById("file_viewer"), () => { this.toggle() }, @@ -27,9 +28,14 @@ QRCodeWindow.prototype.toggle = function () { this.modal.open() this.btnQRCode.classList.add("button_highlight") this.visible = true + this.setFile() } } QRCodeWindow.prototype.setFile = function () { - this.img.src = "/api/misc/qr?text=" + encodeURIComponent(window.location.href) + this.src = "/api/misc/qr?text=" + encodeURIComponent(window.location.href) + + if (this.visible) { + this.img.src = this.src + } }