Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 86: | Line 86: | ||
return text ? text.replace(/\s/g, '-') : text; | return text ? text.replace(/\s/g, '-') : text; | ||
} | } | ||
const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => { | |||
const printoutValue = dctResult.printouts[func][0]; | |||
return printoutValue && printoutValue.fulltext.toLowerCase() === 'yes'; | |||
}); | |||
async function getSources() { | async function getSources() { | ||
Line 130: | Line 135: | ||
const results = dctResponse.query.results; | const results = dctResponse.query.results; | ||
const dctList = Object.getOwnPropertyNames(results).map(dctKey => { | const dctList = Object.getOwnPropertyNames(results).map(dctKey => { | ||
const dctResult = results[dctKey]; | |||
/** @type {DCT} */ | /** @type {DCT} */ | ||
const dct = {}; | const dct = {}; | ||
dct.name = dctKey; | dct.name = dctKey; | ||
dct.url = | dct.url = dctResult.fullurl; | ||
dct.dataSources = | dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort(); | ||
dct.logo = | dct.logo = dctResult.printouts['Image'][0] ? getUrl(dctResult.printouts['Image'][0].fulltext) : void 0; | ||
dct.functions = []; | dct.functions = []; | ||
if (hasFunction(dctResult, searchFunctions)) dct.functions.push(FN_SEARCH); | |||
if (hasFunction(dctResult, postFunctions)) dct.functions.push(FN_POST); | |||
return dct; | return dct; | ||
}) | }) | ||
Line 212: | Line 210: | ||
return '<a href="' + dct.url + '">' + dct.name + '</a>'; | return '<a href="' + dct.url + '">' + dct.name + '</a>'; | ||
} | } | ||
}, | |||
{ | |||
title: 'Functions', | |||
field: 'functions', | |||
// formatter: function (cell) { | |||
// /** @type {DCT} */ | |||
// const dct = cell.getData(); | |||
// return '<a href="' + dct.url + '">' + dct.name + '</a>'; | |||
// } | |||
}, | }, | ||
{ | { |
Revision as of 15:47, 9 June 2022
Development verstion of the DCT List.
Not ready for production!