MCPcopy Create free account
hub / github.com/error311/FileRise / wireAdminPanelSearch

Function wireAdminPanelSearch

public/js/adminPanel.js:5718–5847  ·  view source on GitHub ↗
(sectionIds)

Source from the content-addressed store, hash-verified

5716}
5717
5718function wireAdminPanelSearch(sectionIds) {
5719 const input = document.getElementById("adminSettingsSearch");
5720 const emptyState = document.getElementById("adminSettingsSearchEmpty");
5721 const wrap = document.getElementById("adminSettingsSearchWrap");
5722 const toggleBtn = document.getElementById("adminSearchToggle");
5723 const clearBtn = document.getElementById("adminSearchClear");
5724 if (!input || !Array.isArray(sectionIds)) return;
5725
5726 const ids = sectionIds.filter(Boolean);
5727
5728 const setOpen = (open, opts = {}) => {
5729 if (!wrap || !toggleBtn) return;
5730 wrap.classList.toggle("is-collapsed", !open);
5731 toggleBtn.setAttribute("aria-expanded", open ? "true" : "false");
5732 if (open && opts.focus) {
5733 input.focus();
5734 }
5735 };
5736
5737 const updateToggleState = () => {
5738 const hasQuery = !!normalizeAdminSearchText(input.value);
5739 if (toggleBtn) {
5740 toggleBtn.classList.toggle("is-active", hasQuery);
5741 }
5742 if (clearBtn) {
5743 clearBtn.hidden = !hasQuery;
5744 clearBtn.disabled = !hasQuery;
5745 }
5746 };
5747
5748 const restoreState = () => {
5749 ids.forEach(id => {
5750 const hdr = document.getElementById(id + "Header");
5751 const cnt = document.getElementById(id + "Content");
5752 if (!hdr || !cnt) return;
5753 const saved = hdr.dataset.prevCollapsed;
5754 hdr.style.display = "";
5755 cnt.style.display = "";
5756 if (saved !== undefined) {
5757 const wasCollapsed = saved === "1";
5758 hdr.classList.toggle("collapsed", wasCollapsed);
5759 setSectionContentImmediate(cnt, !wasCollapsed);
5760 delete hdr.dataset.prevCollapsed;
5761 }
5762 });
5763 if (emptyState) emptyState.style.display = "none";
5764 };
5765
5766 const applyFilter = () => {
5767 const query = normalizeAdminSearchText(input.value);
5768 if (!query) {
5769 restoreState();
5770 updateToggleState();
5771 return;
5772 }
5773
5774 let matches = 0;
5775 ids.forEach(id => {

Callers 1

openAdminPanelFunction · 0.85

Calls 5

clearSearchFunction · 0.85
setOpenFunction · 0.85
normalizeAdminSearchTextFunction · 0.85
updateToggleStateFunction · 0.85
applyFilterFunction · 0.70

Tested by

no test coverage detected