Difference between revisions of "Widget:DevGuidelines"
From LINKS Community Center
Line 30: | Line 30: | ||
'use strict'; | 'use strict'; | ||
const getQueryUrl = query => '/api.php?action=ask&format=json&query=' + encodeURIComponent(query); | const getQueryUrl = query => '/api.php?action=ask&format=json&query=' + encodeURIComponent(query); | ||
+ | |||
+ | const PHASE_PROP = 'Disaster Management Phase new'; | ||
+ | const THEME_PROP = 'Covers Thematic'; | ||
+ | const LANG_PROP = 'Language'; | ||
+ | const YEAR_PROP = 'Year Published'; | ||
+ | const EX_PROP = 'Audience Experience Level'; | ||
+ | const TA_PROP = 'Target Audience'; | ||
const guidelineQuery = '[[Category:Guideline]]' | const guidelineQuery = '[[Category:Guideline]]' | ||
− | + '|? | + | + '|?' + PHASE_PROP |
− | + '|? | + | + '|?' + THEME_PROP |
− | + '|? | + | + '|?' + LANG_PROP |
− | + '|? | + | + '|?' + YEAR_PROP |
− | + '|? | + | + '|?' + EX_PROP |
− | + '|? | + | + '|?' + TA_PROP; |
async function getGuidelines() { | async function getGuidelines() { | ||
− | const | + | const guidelinesResponse = await fetch(getQueryUrl(guidelineQuery)).then(response => response.json()); |
− | console.log( | + | |
+ | const guidelines = Object.keys(guidelinesResponse.query.results).map(title => { | ||
+ | const guideline = guidelinesResponse.query.results[title]; | ||
+ | guideline.title = title; | ||
+ | guideline[PHASE_PROP] = guideline.printouts[PHASE_PROP].map(value => value.fulltext); | ||
+ | guideline[THEME_PROP] = guideline.printouts[THEME_PROP].map(value => value.fulltext); | ||
+ | guideline[LANG_PROP] = guideline.printouts[LANG_PROP].map(value => value.fulltext); | ||
+ | guideline[TA_PROP] = guideline.printouts[TA_PROP].map(value => value.fulltext); | ||
+ | guideline[EX_PROP] = guideline.printouts[EX_PROP].map(value => value.fulltext); | ||
+ | guideline[YEAR_PROP] = guideline.printouts[YEAR_PROP][0] && guideline.printouts[YEAR_PROP][0].raw; | ||
+ | }); | ||
+ | console.log(guidelines); | ||
} | } | ||
Revision as of 10:39, 1 September 2022
Development version of the List of Guidelines.
Not ready for production!