Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
<script> | <script> | ||
async function getImages(imageTitles) { | async function getImages(imageTitles) { | ||
const imageUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + | const imageUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + encodeURIComponent(imageTitles.join('|')); | ||
const imageUrlResponse = await fetch(imageUrlQuery).then(response => response.json()); | const imageUrlResponse = await fetch(imageUrlQuery).then(response => response.json()); | ||
return Object.getOwnPropertyNames(imageUrlResponse.query.pages).map(page => ({ | |||
title: imageUrlResponse.query.pages[pageId].title, | |||
url: imageUrlResponse.query.pages[pageId].imageinfo[0].url | |||
})); | |||
} | } | ||
Line 16: | Line 19: | ||
image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '') | image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '') | ||
})); | })); | ||
var images = await getImages(sources.map(source => source.image)); | |||
console.log('img', images) | |||
const logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + | const logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + |
Revision as of 14:14, 2 June 2022
Development verstion of the DCT List.
Not ready for production!