Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 34: | Line 34: | ||
imageData.forEach(img => sources[sources.findIndex(source => source.image === img.title)].image = img.url); | imageData.forEach(img => sources[sources.findIndex(source => source.image === img.title)].image = img.url); | ||
console.log('Sources:', sources); | // console.log('Sources:', sources); | ||
return sources; | return sources; | ||
} | } | ||
Line 44: | Line 44: | ||
const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery); | const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery); | ||
const dctResponse = await fetch(dctQueryUrl).then(response => response.json()); | const dctResponse = await fetch(dctQueryUrl).then(response => response.json()); | ||
console.log('Response:', dctResponse); | console.log('DCT Response:', dctResponse); | ||
const dctList = Object.getOwnPropertyNames(dctResponse.query.results).map(dctKey => { | const dctList = Object.getOwnPropertyNames(dctResponse.query.results).map(dctKey => { | ||
Line 63: | Line 63: | ||
} | } | ||
Promise.all([getSources(), getDcts()]).then(data => { | Promise.all([getSources(), getDcts()]).then(data => { | ||
const sources = data[0]; | const sources = data[0]; | ||
Line 70: | Line 69: | ||
const table = new Tabulator("#dct-tabulator", { | const table = new Tabulator("#dct-tabulator", { | ||
autoColumns: true, | autoColumns: true, | ||
columns: [ | |||
{ | |||
title: 'Name', | |||
field: 'name', | |||
formatter: function (cell) { | |||
const data = cell.getData(); | |||
console.log(data) | |||
} | |||
} | |||
] | |||
}); | }); | ||
table.on("tableBuilt", () => { | table.on("tableBuilt", () => { table.setData(dcts); }); | ||
}) | }) | ||
Revision as of 13:43, 7 June 2022
Development verstion of the DCT List.
Not ready for production!