.
This commit is contained in:
@@ -257,15 +257,12 @@ 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") {
|
||||||
// Extract the iframe
|
// Locate the iframe
|
||||||
const iframe = printerCard.querySelector('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
|
// Construct the new HTML content
|
||||||
const tempContainer = document.createElement('div');
|
const data = `
|
||||||
|
|
||||||
// Set the new content, excluding the iframe
|
|
||||||
tempContainer.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>
|
||||||
@@ -288,12 +285,17 @@ if (own_id == printer.userid || cancel_all == "1") {
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Replace the content around the iframe
|
// Insert the new content before the iframe
|
||||||
while (iframeParent.firstChild && printerCard.firstChild !== iframe) {
|
iframe.insertAdjacentHTML('beforebegin', data);
|
||||||
iframeParent.removeChild(iframeParent.firstChild);
|
|
||||||
|
// 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{
|
}else{
|
||||||
printerCard.innerHTML = `
|
printerCard.innerHTML = `
|
||||||
|
|||||||
Reference in New Issue
Block a user