Widget: Homepage: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 106: | Line 106: | ||
<script> | <script> | ||
async function getData() { | async function getData() { | ||
const sourceQuery = '/api.php?action=ask&format=json&query=' + encodeURIComponent('[[Category:Social media platform]]|?IMAGE'); | |||
const sourceResponse = await fetch(sourceQuery).then(response => response.json()); | |||
const sources = Object.getOwnPropertyNames(sourceResponse.query.results).map(platformName => ({ | |||
name: platformName, | |||
name: | image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '') | ||
image: | })); | ||
}); | |||
var logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + | |||
encodeURIComponent(sources.map(source => source.image).join('|')); | |||
var logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json()); | |||
for (const page of logoUrlResponse.query.pages) { | |||
console.log(page) | |||
} | |||
Object.getOwnPropertyNames( | // Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => { | ||
// var filename = logoUrlResponse.query.pages[pageId].title; | |||
// var url = logoUrlResponse.query.pages[pageId].imageinfo[0].url; | |||
// sources[sources.findIndex(platform => platform.image === filename)].image = url; | |||
}); | // }); | ||
console.log( | // console.log(sources) | ||
Revision as of 13:15, 2 June 2022
Development verstion of the DCT Homepage.
Not ready for production!