Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 12: | Line 12: | ||
'use strict'; | 'use strict'; | ||
/** | |||
* @typedef {Object} DCT | |||
* @property {string} name | |||
* @property {string} url | |||
* @property {string[]} dataSources | |||
* @property {string} logo | |||
*/ | |||
/** | |||
* @param {string} title | |||
* @returns {string} | |||
*/ | |||
function getUrl(title) { | function getUrl(title) { | ||
return title ? '/index.php/Special:FilePath/' + title : title; | return title ? '/index.php/Special:FilePath/' + title : title; | ||
Line 39: | Line 51: | ||
const results = dctResponse.query.results; | const results = dctResponse.query.results; | ||
const dctList = Object.getOwnPropertyNames(results).map(dctKey => { | const dctList = Object.getOwnPropertyNames(results).map(dctKey => { | ||
/** @type {DCT} */ | |||
const dct = {}; | const dct = {}; | ||
dct.name = dctKey; | dct.name = dctKey; | ||
dct.url = results[dctKey].fullurl; | dct.url = results[dctKey].fullurl; | ||
dct.dataSources = results[dctKey].printouts['Data Sources'].map( | dct.dataSources = results[dctKey].printouts['Data Sources'].map(source => source.fulltext); | ||
dct.logo = results[dctKey].printouts['Image'][0] ? getUrl(results[dctKey].printouts['Image'][0].fulltext) : void 0; | dct.logo = results[dctKey].printouts['Image'][0] ? getUrl(results[dctKey].printouts['Image'][0].fulltext) : void 0; | ||
return dct; | return dct; | ||
Line 63: | Line 76: | ||
field: 'name', | field: 'name', | ||
formatter: function (cell) { | formatter: function (cell) { | ||
/** @type {DCT} */ | |||
const dct = cell.getData(); | const dct = cell.getData(); | ||
return '<a href="' + dct.url + '">' + dct.name + '</a>'; | return '<a href="' + dct.url + '">' + dct.name + '</a>'; |
Revision as of 14:54, 7 June 2022
Development verstion of the DCT List.
Not ready for production!