Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 252: | Line 252: | ||
<script> | <script> | ||
'use strict'; | 'use strict'; | ||
const FUNC_KEY = 'functions'; | |||
const DESC_KEY = 'description'; | |||
/** @typedef {Map<string, { [DESC_KEY]: string, [FUNC_KEY]: string[] }>} FuncData */ | |||
/** @type FuncData */ | |||
const functionsData = new Map(); | |||
/** | /** | ||
Line 315: | Line 323: | ||
// Fetches DCTs and their functions. | // Fetches DCTs and their functions. | ||
async function getDcts() { | async function getDcts() { | ||
const functionsQuery = '[[Category:Function_category]]' | const functionsQuery = '[[Category:Function_category]]' | ||
+ '|?-Subproperty_of=' + FUNC_KEY | + '|?-Subproperty_of=' + FUNC_KEY | ||
Line 370: | Line 372: | ||
dct.functions = []; | dct.functions = []; | ||
functionsData.forEach(( | functionsData.forEach((categoryData, funcCategory) => { | ||
if ( | if (categoryData[FUNC_KEY].some( | ||
func => dctResult.printouts[func][0] && dctResult.printouts[func][0].fulltext.toLowerCase() === 'yes' | func => dctResult.printouts[func][0] && dctResult.printouts[func][0].fulltext.toLowerCase() === 'yes' | ||
)) { | )) { | ||
dct.functions.push( | dct.functions.push(funcCategory); | ||
} | } | ||
}); | }); | ||
Line 381: | Line 383: | ||
}); | }); | ||
return | return dctList; | ||
} | } | ||
Line 439: | Line 441: | ||
// Load data and build page. | // Load data and build page. | ||
Promise.all([getSources(), getDcts()]).then(data => { | Promise.all([getSources(), getDcts()]).then(data => { | ||
const dataSources | const [dataSources, dcts] = data; | ||
// Set up functions filter | // Set up functions filter | ||
let funcFilterHtml = ''; | let funcFilterHtml = ''; | ||
Array.from( | Array.from(functionsData).forEach(([fnCat, fnInfo], index) => { | ||
const identifier = 'func-filter-' + escapeAttr(fnCat); | const identifier = 'func-filter-' + escapeAttr(fnCat); | ||
funcFilterHtml += | funcFilterHtml += |
Revision as of 15:15, 17 November 2022
Development verstion of the DCT List.
Not ready for production!