Widget: DCTList: Difference between revisions
From LINKS Community Center
Cschwentker (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 79: | Line 79: | ||
const FN_METRICS = 'Metrics'; | const FN_METRICS = 'Metrics'; | ||
const FN_REPORT = 'Report'; | const FN_REPORT = 'Report'; | ||
const fnImages = {}; | |||
fnImages[FN_SEARCH] = '/index.php/Special:FilePath/File:Func_search.svg'; | |||
fnImages[FN_POST] = '/index.php/Special:FilePath/File:Func_post.svg'; | |||
fnImages[FN_ANALYSIS] = '/index.php/Special:FilePath/File:Func_analysis.svg'; | |||
fnImages[FN_METRICS] = '/index.php/Special:FilePath/File:Func_metrics.svg'; | |||
fnImages[FN_REPORT] = '/index.php/Special:FilePath/File:Func_report.svg'; | |||
const getUrl = title => title ? '/index.php/Special:FilePath/' + title : title; | const getUrl = title => title ? '/index.php/Special:FilePath/' + title : title; | ||
Line 145: | Line 152: | ||
'|?Image' + | '|?Image' + | ||
'|?Data Sources' + | '|?Data Sources' + | ||
searchFunctions.map(func => '|?' + func | searchFunctions.map(func => '|?' + func).join('') + | ||
postFunctions.map(func => '|?' + func | postFunctions.map(func => '|?' + func).join('') + | ||
analysisFunctions.map(func => '|?' + func | analysisFunctions.map(func => '|?' + func).join('') + | ||
metricsFunctions.map(func => '|?' + func | metricsFunctions.map(func => '|?' + func).join('') + | ||
reportFunctions.map(func => '|?' + func | reportFunctions.map(func => '|?' + func).join(''); | ||
const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery); | const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery); | ||
const dctResponse = await fetch(dctQueryUrl).then(response => response.json()); | const dctResponse = await fetch(dctQueryUrl).then(response => response.json()); | ||
console.log(dctResponse) | // console.log(dctResponse) | ||
const results = dctResponse.query.results; | const results = dctResponse.query.results; | ||
Line 231: | Line 238: | ||
field: 'name', | field: 'name', | ||
formatter: function (cell) { | formatter: function (cell) { | ||
return cell.getValue().map(func => '<img src="' + fnImages[func] + '">'); | |||
} | } | ||
}, | }, | ||
Line 239: | Line 244: | ||
title: 'Functions', | title: 'Functions', | ||
field: 'functions', | field: 'functions', | ||
formatter: function (cell) { | |||
/** @type {DCT} */ | |||
const dct = cell.getData(); | |||
return '<a href="' + dct.url + '">' + dct.name + '</a>'; | |||
} | |||
}, | }, | ||
{ | { |
Revision as of 14:04, 13 June 2022
Development verstion of the DCT List.
Not ready for production!