Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 20: Line 20:
             }));
             }));


             var images = await getImages(sources.map(source => source.image));
             const imageData = await getImages(sources.map(source => source.image));
             console.log('img', images)
             imageData.forEach(img => {
                sources[sources.findIndex(source => source.image === img.title)].image = img.url;
            })
            // console.log('img', imageData)


             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=' +
                                  encodeURIComponent(sources.map(source => source.image).join('|'));
            //                      encodeURIComponent(sources.map(source => source.image).join('|'));
             const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());
             // const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());


             console.log(logoUrlResponse)
             // console.log(logoUrlResponse)


             Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => {
             // Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => {
                const logoFileName = logoUrlResponse.query.pages[pageId].title;
            //    const logoFileName = logoUrlResponse.query.pages[pageId].title;
                const logoUrl = logoUrlResponse.query.pages[pageId].imageinfo[0].url;
            //    const logoUrl = logoUrlResponse.query.pages[pageId].imageinfo[0].url;
                sources[sources.findIndex(source => source.image === logoFileName)].image = logoUrl;
            //    sources[sources.findIndex(source => source.image === logoFileName)].image = logoUrl;
             });
             // });


             console.log(sources)
             console.log(sources)

Revision as of 14:18, 2 June 2022

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