Bestellungen-Suche wieder auf Fragment laden

This commit is contained in:
2026-06-15 16:48:50 +02:00
parent 5080b58db5
commit 76ac5aada8
+34 -6
View File
@@ -603,15 +603,43 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " });";
echo " return url;";
echo " };";
echo " const replaceFragment = (html) => {";
echo " const doc = new DOMParser().parseFromString(html, 'text/html');";
echo " const fragment = doc.querySelector('[data-bestellungen-content]');";
echo " if (!fragment) {";
echo " return false;";
echo " }";
echo " contentRoot.innerHTML = fragment.innerHTML;";
echo " table = getTable();";
echo " return !!table;";
echo " };";
echo " const loadFragment = async (params, updateHistory = true) => {";
echo " if (searchTimer) { window.clearTimeout(searchTimer); searchTimer = null; }";
echo " const url = buildUrl(params);";
echo " const targetUrl = url.toString();";
echo " if (updateHistory) {";
echo " window.location.assign(targetUrl);";
echo " const activeRequest = ++requestToken;";
echo " const currentTable = getTable();";
echo " if (currentTable) { currentTable.setAttribute('aria-busy', 'true'); }";
echo " try {";
echo " const response = await fetch(url.toString(), { credentials: 'same-origin', headers: { 'X-Requested-With': 'XMLHttpRequest' } });";
echo " const html = await response.text();";
echo " if (activeRequest !== requestToken) {";
echo " return;";
echo " }";
echo " window.location.replace(targetUrl);";
echo " const replaced = replaceFragment(html);";
echo " if (replaced && updateHistory) {";
echo " const historyUrl = new URL(url.toString());";
echo " historyUrl.searchParams.delete('bestellungen_fragment');";
echo " window.history.replaceState({}, '', historyUrl);";
echo " }";
echo " bindTable();";
echo " } finally {";
echo " if (activeRequest === requestToken) {";
echo " table = getTable();";
echo " if (table) {";
echo " table.removeAttribute('aria-busy');";
echo " }";
echo " }";
echo " }";
echo " };";
echo " const bindTable = () => {";
echo " table = getTable();";
@@ -629,7 +657,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " bestellungen_sort: getSortColumn(),";
echo " bestellungen_dir: getSortDirection(),";
echo " bestellungen_limit: getPageSize(),";
echo " }, false);";
echo " });";
echo " }, 250);";
echo " });";
echo " }";
@@ -703,7 +731,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $best
echo " bestellungen_sort: getSortColumn(),";
echo " bestellungen_dir: getSortDirection(),";
echo " bestellungen_limit: getPageSize(),";
echo " }, false);";
echo " });";
echo " }, 250);";
echo " });";
echo " document.addEventListener('keydown', (event) => {";