Files
web-framework-resources/plugins/queues/static/queues.js
T

16 lines
716 B
JavaScript

// Replace the queue panel only; retain keyboard focus and scroll position.
const refreshQueue = async () => {
const panel = document.querySelector('[data-queue-refresh]');
if (!panel || document.hidden || panel.contains(document.activeElement)) return;
try {
const response = await fetch(window.location.href, {redirect: 'error'});
if (!response.ok) return;
const documentNext = new DOMParser().parseFromString(await response.text(), 'text/html');
const nextPanel = documentNext.querySelector('.queue-panel');
if (nextPanel) panel.replaceWith(nextPanel);
} catch (_) {
// Manual refresh remains available when a connection or session expires.
}
};
setInterval(refreshQueue, 5000);