From 1055d4fcdf0332bcbb683e5c6f6ded5cf4038c1c Mon Sep 17 00:00:00 2001 From: Janis Steiner Date: Sun, 8 Dec 2024 13:18:05 +0000 Subject: [PATCH] . --- sys0-code/test/overview.php | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/sys0-code/test/overview.php b/sys0-code/test/overview.php index 060332d..9937522 100644 --- a/sys0-code/test/overview.php +++ b/sys0-code/test/overview.php @@ -257,25 +257,19 @@ function updatePrinterData(data) { if(printer.view==0 || printer.view==2){ if (own_id == printer.userid || cancel_all == "1") { - // Get the current iframe + // Extract the iframe const iframe = printerCard.querySelector('iframe'); + const iframeParent = iframe.parentNode; - // Store necessary iframe attributes if needed - const iframeSrc = iframe ? iframe.src : null; + // Create a temporary container for the new content + const tempContainer = document.createElement('div'); - // Remove iframe temporarily - if (iframe) { - printerCard.removeChild(iframe); - } - - // Update the innerHTML, excluding the iframe initially - printerCard.innerHTML = ` + // Set the new content, excluding the iframe + tempContainer.innerHTML = `
Drucker ${printer.printer_id}
- -
@@ -294,16 +288,15 @@ if (own_id == printer.userid || cancel_all == "1") {
`; - // Create a new iframe element or use the existing one if it was stored - const newIframe = document.createElement('iframe'); - newIframe.height = "230px"; - newIframe.scrolling = "no"; - newIframe.width = "100%"; - newIframe.src = iframeSrc ? iframeSrc : `/app/webcam.php?printer_id=${printer.printer_id}&username=&url=${printer.url}`; + // Replace the content around the iframe + while (iframeParent.firstChild) { + iframeParent.removeChild(iframeParent.firstChild); + } + + // Append the new content and reattach the iframe + iframeParent.appendChild(tempContainer.firstChild); + iframeParent.appendChild(iframe); - // Reattach the iframe at the placeholder - const placeholder = printerCard.querySelector('#iframe-placeholder'); - placeholder.parentNode.replaceChild(newIframe, placeholder); }else{ printerCard.innerHTML = `