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

Function initPluginsPage

website/src/scripts/pages/plugins.ts:227–294  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225}
226
227export async function initPluginsPage(): Promise<void> {
228 const list = document.getElementById('resource-list');
229 const clearFiltersBtn = document.getElementById('clear-filters');
230 const sortSelect = document.getElementById('sort-select') as HTMLSelectElement | null;
231
232 if (!modalReady) {
233 setupModal();
234 modalReady = true;
235 }
236
237 setupResourceListHandlers(list as HTMLElement | null);
238
239 const data = await fetchData<PluginsData>('plugins.json');
240 if (!data || !data.items) {
241 if (list) list.innerHTML = '<div class="empty-state"><h3>Failed to load data</h3></div>';
242 return;
243 }
244
245 allItems = data.items;
246 pluginByPath = new Map(allItems.map((item) => [item.path, item]));
247
248 tagSelectEl = document.getElementById('filter-tag') as HTMLSelectElement | null;
249 if (tagSelectEl) {
250 tagSelectEl.innerHTML = '';
251 data.filters.tags.forEach((tag) => {
252 const option = document.createElement('option');
253 option.value = tag;
254 option.textContent = tag;
255 tagSelectEl?.appendChild(option);
256 });
257 }
258
259 const initialTags = getQueryParamValues('tag').filter((tag) => data.filters.tags.includes(tag));
260 const initialSort = getQueryParam('sort');
261
262 if (initialTags.length > 0) {
263 currentFilters.tags = initialTags;
264 setSelectValues(tagSelectEl, initialTags);
265 }
266
267 tagSelectEl?.addEventListener('change', () => {
268 currentFilters.tags = getSelectValues(tagSelectEl);
269 applyFiltersAndRender();
270 syncUrlState();
271 });
272
273 if (initialSort === 'lastUpdated') {
274 currentSort = initialSort;
275 if (sortSelect) sortSelect.value = initialSort;
276 }
277 sortSelect?.addEventListener('change', () => {
278 currentSort = sortSelect.value as PluginSortOption;
279 applyFiltersAndRender();
280 syncUrlState();
281 });
282
283 clearFiltersBtn?.addEventListener('click', () => {
284 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