|
|
Line 103: |
Line 103: |
| } | | } |
| </style> | | </style> |
|
| |
| <script>
| |
| 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,
| |
| image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '')
| |
| }));
| |
|
| |
| const logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' +
| |
| encodeURIComponent(sources.map(source => source.image).join('|'));
| |
| const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());
| |
|
| |
| Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => {
| |
| const logoFileName = logoUrlResponse.query.pages[pageId].title;
| |
| const logoUrl = logoUrlResponse.query.pages[pageId].imageinfo[0].url;
| |
| sources[sources.findIndex(source => source.image === logoFileName)].image = logoUrl;
| |
| });
| |
|
| |
| console.log(sources)
| |
| }
| |
|
| |
| getData();
| |
| </script>
| |
|
| |
|
| <div id="hp-wrapper"> | | <div id="hp-wrapper"> |
Revision as of 13:35, 2 June 2022
Development verstion of the DCT Homepage.
Not ready for production!