Update index.html
Browse files- index.html +22 -0
index.html
CHANGED
|
@@ -2516,13 +2516,29 @@
|
|
| 2516 |
syncUrlParams();
|
| 2517 |
}
|
| 2518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2519 |
function readUrlParams() {
|
| 2520 |
const params = new URLSearchParams(window.location.search);
|
|
|
|
| 2521 |
const size = params.get('size');
|
| 2522 |
const arch = params.get('arch');
|
| 2523 |
const tab = params.get('tab');
|
| 2524 |
const metric = params.get('metric');
|
| 2525 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2526 |
if (['all', '<100M', '<50M', '<10M', '<3M'].includes(size)) State.sizeFilter = size;
|
| 2527 |
if (['all', 'native', 'custom'].includes(arch)) State.archFilter = arch;
|
| 2528 |
if (tab && document.getElementById(tab)) State.activeTab = tab;
|
|
@@ -2539,7 +2555,12 @@
|
|
| 2539 |
}
|
| 2540 |
|
| 2541 |
function syncUrlParams() {
|
|
|
|
|
|
|
| 2542 |
const params = new URLSearchParams();
|
|
|
|
|
|
|
|
|
|
| 2543 |
if (State.sizeFilter !== 'all') params.set('size', State.sizeFilter);
|
| 2544 |
if (State.archFilter !== 'all') params.set('arch', State.archFilter);
|
| 2545 |
if (State.activeTab !== 'tab-leaderboard') params.set('tab', State.activeTab);
|
|
@@ -2573,6 +2594,7 @@
|
|
| 2573 |
document.getElementById('global-search').addEventListener('input', (e) => {
|
| 2574 |
State.searchQuery = e.target.value;
|
| 2575 |
updateAllViews();
|
|
|
|
| 2576 |
});
|
| 2577 |
|
| 2578 |
document.getElementById('size-filters').addEventListener('click', (e) => {
|
|
|
|
| 2516 |
syncUrlParams();
|
| 2517 |
}
|
| 2518 |
|
| 2519 |
+
let urlSyncDebounceTimer = null;
|
| 2520 |
+
|
| 2521 |
+
function debouncedSyncUrlParams(delay = 300) {
|
| 2522 |
+
clearTimeout(urlSyncDebounceTimer);
|
| 2523 |
+
urlSyncDebounceTimer = setTimeout(() => {
|
| 2524 |
+
syncUrlParams();
|
| 2525 |
+
}, delay);
|
| 2526 |
+
}
|
| 2527 |
+
|
| 2528 |
function readUrlParams() {
|
| 2529 |
const params = new URLSearchParams(window.location.search);
|
| 2530 |
+
const query = params.get('q') ?? params.get('search');
|
| 2531 |
const size = params.get('size');
|
| 2532 |
const arch = params.get('arch');
|
| 2533 |
const tab = params.get('tab');
|
| 2534 |
const metric = params.get('metric');
|
| 2535 |
|
| 2536 |
+
if (query !== null) {
|
| 2537 |
+
State.searchQuery = query;
|
| 2538 |
+
const searchInput = document.getElementById('global-search');
|
| 2539 |
+
if (searchInput) searchInput.value = query;
|
| 2540 |
+
}
|
| 2541 |
+
|
| 2542 |
if (['all', '<100M', '<50M', '<10M', '<3M'].includes(size)) State.sizeFilter = size;
|
| 2543 |
if (['all', 'native', 'custom'].includes(arch)) State.archFilter = arch;
|
| 2544 |
if (tab && document.getElementById(tab)) State.activeTab = tab;
|
|
|
|
| 2555 |
}
|
| 2556 |
|
| 2557 |
function syncUrlParams() {
|
| 2558 |
+
clearTimeout(urlSyncDebounceTimer);
|
| 2559 |
+
|
| 2560 |
const params = new URLSearchParams();
|
| 2561 |
+
const trimmedQuery = State.searchQuery.trim();
|
| 2562 |
+
|
| 2563 |
+
if (trimmedQuery) params.set('q', trimmedQuery);
|
| 2564 |
if (State.sizeFilter !== 'all') params.set('size', State.sizeFilter);
|
| 2565 |
if (State.archFilter !== 'all') params.set('arch', State.archFilter);
|
| 2566 |
if (State.activeTab !== 'tab-leaderboard') params.set('tab', State.activeTab);
|
|
|
|
| 2594 |
document.getElementById('global-search').addEventListener('input', (e) => {
|
| 2595 |
State.searchQuery = e.target.value;
|
| 2596 |
updateAllViews();
|
| 2597 |
+
debouncedSyncUrlParams(300);
|
| 2598 |
});
|
| 2599 |
|
| 2600 |
document.getElementById('size-filters').addEventListener('click', (e) => {
|