This commit is contained in:
Janis Steiner
2024-12-08 13:23:20 +00:00
parent 6ba266b2e9
commit 680f95a1c5

View File

@@ -257,15 +257,12 @@ function updatePrinterData(data) {
if(printer.view==0 || printer.view==2){
if (own_id == printer.userid || cancel_all == "1") {
// Extract the iframe
// Locate the iframe
const iframe = printerCard.querySelector('iframe');
const iframeParent = iframe.parentNode;
if (!iframe) return; // If iframe doesn't exist, exit the function
// Create a temporary container for the new content
const tempContainer = document.createElement('div');
// Set the new content, excluding the iframe
tempContainer.innerHTML = `
// Construct the new HTML content
const data = `
<div class="card-body">
<h5 class="card-title">Drucker ${printer.printer_id}</h5>
</div>
@@ -288,12 +285,17 @@ if (own_id == printer.userid || cancel_all == "1") {
</div>
`;
// Replace the content around the iframe
while (iframeParent.firstChild && printerCard.firstChild !== iframe) {
iframeParent.removeChild(iframeParent.firstChild);
// Insert the new content before the iframe
iframe.insertAdjacentHTML('beforebegin', data);
// Optionally, remove old content that is not part of the new data or iframe
const children = Array.from(printerCard.childNodes);
for (let child of children) {
if (child !== iframe && child !== iframe.previousElementSibling) {
printerCard.removeChild(child);
}
}
printerCard.insertBefore(contentContainer, iframe);
}else{
printerCard.innerHTML = `