MCPcopy
hub / github.com/github/awesome-copilot / initExtensionsPage

Function initExtensionsPage

website/src/scripts/pages/extensions.ts:410–492  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

408}
409
410export async function initExtensionsPage(): Promise<void> {
411 const list = document.getElementById("resource-list");
412 const clearFiltersBtn = document.getElementById("clear-filters");
413 const sortSelect = document.getElementById(
414 "sort-select"
415 ) as HTMLSelectElement;
416
417 if (!modalReady) {
418 setupModal();
419 modalReady = true;
420 }
421
422 setupActionHandlers(list as HTMLElement | null);
423
424 const data = await fetchData<ExtensionsData>("extensions.json");
425 if (!data || !data.items) {
426 if (list)
427 list.innerHTML =
428 '<div class="empty-state"><h3>Failed to load data</h3></div>';
429 return;
430 }
431
432 allItems = data.items;
433 extensionById = new Map(allItems.map((item) => [item.id, item]));
434
435 const availableKeywords = (
436 data.filters?.keywords ||
437 Array.from(
438 new Set(
439 data.items.flatMap((item) =>
440 Array.isArray(item.keywords) ? item.keywords : []
441 )
442 )
443 )
444 ).sort((a, b) => a.localeCompare(b));
445
446 keywordSelect = createChoices("#filter-keyword", {
447 placeholderValue: "All Keywords",
448 });
449 keywordSelect.setChoices(
450 availableKeywords.map((keyword) => ({ value: keyword, label: keyword })),
451 "value",
452 "label",
453 true
454 );
455
456 const initialKeywords = getQueryParamValues("keyword").filter((keyword) =>
457 availableKeywords.includes(keyword)
458 );
459 const initialSort = getQueryParam("sort");
460 if (initialKeywords.length > 0) {
461 currentFilters.keywords = initialKeywords;
462 setChoicesValues(keywordSelect, initialKeywords);
463 }
464 if (initialSort === "lastUpdated") {
465 currentSort = initialSort;
466 if (sortSelect) sortSelect.value = initialSort;
467 }

Callers

nothing calls this directly

Calls 10

setupModalFunction · 0.90
createChoicesFunction · 0.90
getQueryParamValuesFunction · 0.90
getQueryParamFunction · 0.90
setChoicesValuesFunction · 0.90
getChoicesValuesFunction · 0.90
applySortAndRenderFunction · 0.85
addEventListenerMethod · 0.80
setupActionHandlersFunction · 0.70
syncUrlStateFunction · 0.70

Tested by

no test coverage detected