Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 11: | Line 11: | ||
<script> | <script> | ||
'use strict'; | 'use strict'; | ||
function getUrl(title) { | |||
return title ? '/Special:FilePath/' + title : title; | |||
} | |||
/** | /** | ||
Line 33: | Line 37: | ||
name: platformName, | name: platformName, | ||
/** @type {string} */ | /** @type {string} */ | ||
image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '') | image: getUrl(sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '')) | ||
})); | })); | ||
const imageData = await getImages(sources.map(source => source.image)); | // const imageData = await getImages(sources.map(source => source.image)); | ||
imageData.forEach(img => sources[sources.findIndex(source => source.image === img.title)].image = img.url); | // imageData.forEach(img => sources[sources.findIndex(source => source.image === img.title)].image = img.url); | ||
// console.log('Sources:', sources); | // console.log('Sources:', sources); | ||
Line 91: | Line 95: | ||
const src = dataSources.find(src => src.name === curr); | const src = dataSources.find(src => src.name === curr); | ||
const url = src ? src.image : ''; | const url = src ? src.image : ''; | ||
return url ? prev + '<img class="data-source-img" src="' + url + '">' : prev + ' ' + curr; | |||
return url ? prev + '<img class="data-source-img" src="' + | |||
}, ''); | }, ''); | ||
return output; | return output; |
Revision as of 14:27, 7 June 2022
Development verstion of the DCT List.
Not ready for production!