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(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>
@@ -283,17 +280,22 @@ if (own_id == printer.userid || cancel_all == "1") {
<tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</td></tr> <tr><td>Vergangene Druckzeit</td><td>${printer.print_time}</td></tr>
<tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr> <tr><td>Datei</td><td><div class='hover-element'>${printer.file}<div class='description'>${printer.full_file}</div></div></td></tr>
</thead> </thead>
<tr><td><a class='btn btn-success' href='overview.php?free=${printer.printer_id}&rid=<?php echo($_SESSION["rid"]); ?>'>Freigeben</a></td></tr> <tr><td><a class='btn btn-success' href='overview.php?free=${printer.printer_id}&rid=<?php echo($_SESSION["rid"]); ?>'>Freigeben</a></td></tr>
</table> </table>
</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 = `