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 114: Line 114:
             }));
             }));


             var 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=' +
                 encodeURIComponent(sources.map(source => source.image).join('|'));
                 encodeURIComponent(sources.map(source => source.image).join('|'));
             var logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());
             const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());
 
            for (const page of logoUrlResponse.query.pages) {
                console.log(page)
            }
 
            // 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(sources)


            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)
         }
         }



Revision as of 13:18, 2 June 2022

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