Widget: Homepage: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 108: Line 108:
             var platformQuery = '/api.php?action=ask&format=json&query=' + encodeURIComponent('[[Category:Social media platform]]|?IMAGE');
             var platformQuery = '/api.php?action=ask&format=json&query=' + encodeURIComponent('[[Category:Social media platform]]|?IMAGE');
             var platformResponse = await fetch(platformQuery).then(response => response.json());
             var platformResponse = await fetch(platformQuery).then(response => response.json());
            console.log(platformResponse)
 
             var platformData = Object.getOwnPropertyNames(platformResponse.query.results).map(pName => {
             var platformData = Object.getOwnPropertyNames(platformResponse.query.results).map(pName => {
                 return {  
                 return {
                     name: pName,  
                     name: pName,
                     image: platformResponse.query.results[pName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '')
                     image: platformResponse.query.results[pName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '')
                 };
                 };
             });
             });


             var imageUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' +  
            console.log(platformData)
                                encodeURIComponent(platformData.map(platform => platform.image).join('|'));
 
            console.log(imageUrlQuery)
             var imageUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' +
                encodeURIComponent(platformData.map(platform => platform.image).join('|'));
             var res = await fetch(imageUrlQuery).then(response => response.json());
             var res = await fetch(imageUrlQuery).then(response => response.json());
             console.log(res)
             console.log(res.query.pages)
         }
         }



Revision as of 12:47, 2 June 2022

Development verstion of the DCT Homepage.
Not ready for production!