Widget: DevGuidelines: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
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]]'
                         + '|?Disaster Management Phase new'  
                         + '|?' + PHASE_PROP
                         + '|?Covers Thematic'
                         + '|?' + THEME_PROP
                         + '|?Audience Experience Level'
                         + '|?' + LANG_PROP
                         + '|?Target Audience'
                         + '|?' + YEAR_PROP
                         + '|?Language'
                         + '|?' + EX_PROP
                         + '|?Year Published';
                         + '|?' + TA_PROP;


     async function getGuidelines() {
     async function getGuidelines() {
         const resp = await fetch(getQueryUrl(guidelineQuery)).then(response => response.json());
         const guidelinesResponse = await fetch(getQueryUrl(guidelineQuery)).then(response => response.json());
         console.log(resp);
 
        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 09:39, 1 September 2022

Development version of the List of Guidelines.
Not ready for production!