This commit is contained in:
Janis Steiner
2024-12-08 13:18:05 +00:00
parent da6cad4984
commit 1055d4fcdf

View File

@@ -257,25 +257,19 @@ function updatePrinterData(data) {
if(printer.view==0 || printer.view==2){ if(printer.view==0 || printer.view==2){
if (own_id == printer.userid || cancel_all == "1") { if (own_id == printer.userid || cancel_all == "1") {
// Get the current iframe // Extract the iframe
const iframe = printerCard.querySelector('iframe'); const iframe = printerCard.querySelector('iframe');
const iframeParent = iframe.parentNode;
// Store necessary iframe attributes if needed // Create a temporary container for the new content
const iframeSrc = iframe ? iframe.src : null; const tempContainer = document.createElement('div');
// Remove iframe temporarily // Set the new content, excluding the iframe
if (iframe) { tempContainer.innerHTML = `
printerCard.removeChild(iframe);
}
// Update the innerHTML, excluding the iframe initially
printerCard.innerHTML = `
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Drucker ${printer.printer_id}</h5> <h5 class="card-title">Drucker ${printer.printer_id}</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<!-- Placeholder for iframe reattachment -->
<div id="iframe-placeholder"></div>
<div class="progress"> <div class="progress">
<div class="progress-bar" role="progressbar" style="width: ${printer.progress}%" aria-valuenow="${printer.progress}" aria-valuemin="0" aria-valuemax="100"></div> <div class="progress-bar" role="progressbar" style="width: ${printer.progress}%" aria-valuenow="${printer.progress}" aria-valuemin="0" aria-valuemax="100"></div>
</div> </div>
@@ -294,16 +288,15 @@ if (own_id == printer.userid || cancel_all == "1") {
</div> </div>
`; `;
// Create a new iframe element or use the existing one if it was stored // Replace the content around the iframe
const newIframe = document.createElement('iframe'); while (iframeParent.firstChild) {
newIframe.height = "230px"; iframeParent.removeChild(iframeParent.firstChild);
newIframe.scrolling = "no"; }
newIframe.width = "100%";
newIframe.src = iframeSrc ? iframeSrc : `/app/webcam.php?printer_id=${printer.printer_id}&username=<?php echo($username); ?>&url=${printer.url}`; // 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{ }else{
printerCard.innerHTML = ` printerCard.innerHTML = `