()
| 3026 | } |
| 3027 | |
| 3028 | function renderIconGrid() { |
| 3029 | if (!iconGrid) return; |
| 3030 | const icons = filterFileIcons(iconSearchInput ? iconSearchInput.value : ""); |
| 3031 | iconGrid.innerHTML = ""; |
| 3032 | if (iconCountPill) { |
| 3033 | iconCountPill.textContent = `${icons.length} icons`; |
| 3034 | } |
| 3035 | |
| 3036 | const totalPages = Math.max(1, Math.ceil(icons.length / ICONS_PER_PAGE)); |
| 3037 | iconPage = Math.min(totalPages - 1, Math.max(0, iconPage)); |
| 3038 | if (iconPagePill) iconPagePill.textContent = `Page ${iconPage + 1} / ${totalPages}`; |
| 3039 | if (iconPrevBtn) iconPrevBtn.disabled = iconPage <= 0; |
| 3040 | if (iconNextBtn) iconNextBtn.disabled = iconPage >= totalPages - 1; |
| 3041 | |
| 3042 | const start = iconPage * ICONS_PER_PAGE; |
| 3043 | const pageIcons = icons.slice(start, start + ICONS_PER_PAGE); |
| 3044 | |
| 3045 | pageIcons.forEach((ic) => { |
| 3046 | const btn = document.createElement("button"); |
| 3047 | btn.type = "button"; |
| 3048 | btn.className = "icon-tile"; |
| 3049 | btn.title = ic.name; |
| 3050 | const img = document.createElement("img"); |
| 3051 | img.src = withCacheBust(ic.url); |
| 3052 | img.alt = ic.name; |
| 3053 | img.loading = "lazy"; |
| 3054 | btn.appendChild(img); |
| 3055 | |
| 3056 | btn.addEventListener("click", async (e) => { |
| 3057 | await addIconElement(ic); |
| 3058 | if (e.shiftKey) { |
| 3059 | try { |
| 3060 | await navigator.clipboard.writeText(ic.url); |
| 3061 | setIconHint(`Added + copied: ${ic.url}`); |
| 3062 | } catch { |
| 3063 | setIconHint(`Added: ${ic.name}`); |
| 3064 | } |
| 3065 | } else { |
| 3066 | setIconHint(`Added: ${ic.name}`); |
| 3067 | } |
| 3068 | }); |
| 3069 | iconGrid.appendChild(btn); |
| 3070 | }); |
| 3071 | } |
| 3072 | |
| 3073 | |
| 3074 | function createScreen(name, fnName) { |
no test coverage detected