MCPcopy Index your code
hub / github.com/github/awesome-copilot / initHooksPage

Function initHooksPage

website/src/scripts/pages/hooks.ts:212–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210}
211
212export async function initHooksPage(): Promise<void> {
213 const list = document.getElementById('resource-list');
214 const clearFiltersBtn = document.getElementById('clear-filters');
215 const sortSelect = document.getElementById('sort-select') as HTMLSelectElement | null;
216
217 if (!modalReady) {
218 setupModal();
219 modalReady = true;
220 }
221
222 setupResourceListHandlers(list as HTMLElement | null);
223
224 const data = await fetchData<HooksData>('hooks.json');
225 if (!data || !data.items) {
226 if (list) list.innerHTML = '<div class="empty-state"><h3>Failed to load data</h3></div>';
227 return;
228 }
229
230 allItems = data.items;
231 hookById = new Map(allItems.map((item) => [item.id, item]));
232
233 tagSelectEl = document.getElementById('filter-tag') as HTMLSelectElement | null;
234 if (tagSelectEl) {
235 tagSelectEl.innerHTML = '';
236 data.filters.tags.forEach((tag) => {
237 const option = document.createElement('option');
238 option.value = tag;
239 option.textContent = tag;
240 tagSelectEl?.appendChild(option);
241 });
242 }
243
244 const initialTags = getQueryParamValues('tag').filter((tag) => data.filters.tags.includes(tag));
245 const initialSort = getQueryParam('sort');
246
247 if (initialTags.length > 0) {
248 currentFilters.tags = initialTags;
249 setSelectValues(tagSelectEl, initialTags);
250 }
251 if (initialSort === 'lastUpdated') {
252 currentSort = initialSort;
253 if (sortSelect) sortSelect.value = initialSort;
254 }
255
256 tagSelectEl?.addEventListener('change', () => {
257 currentFilters.tags = getSelectValues(tagSelectEl);
258 applyFiltersAndRender();
259 syncUrlState();
260 });
261
262 sortSelect?.addEventListener('change', () => {
263 currentSort = sortSelect.value as HookSortOption;
264 applyFiltersAndRender();
265 syncUrlState();
266 });
267
268 clearFiltersBtn?.addEventListener('click', () => {
269 currentFilters = { tags: [] };

Callers

nothing calls this directly

Calls 10

setupModalFunction · 0.90
getQueryParamValuesFunction · 0.90
getQueryParamFunction · 0.90
setSelectValuesFunction · 0.90
getSelectValuesFunction · 0.90
clearSelectValuesFunction · 0.90
addEventListenerMethod · 0.80
applyFiltersAndRenderFunction · 0.70
syncUrlStateFunction · 0.70

Tested by

no test coverage detected