Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 73: | Line 73: | ||
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()); | ||
const results = dctResponse.query.results; | const results = dctResponse.query.results; | ||
Line 89: | Line 88: | ||
} | } | ||
/** @param {DCT} dct */ | |||
function dctFilter(dct, params) { | |||
return true; | |||
} | |||
// Load data and build page. | |||
Promise.all([getSources(), getDcts()]).then(data => { | Promise.all([getSources(), getDcts()]).then(data => { | ||
const dataSources = data[0]; | const dataSources = data[0]; | ||
const dcts = data[1]; | const dcts = data[1]; | ||
// Set up filters. | |||
const filterHtml = dataSources.reduce((prev, curr) => { | const filterHtml = dataSources.reduce((prev, curr) => { | ||
const identifier = escapeAttr(curr.name); | const identifier = escapeAttr(curr.name); | ||
Line 103: | Line 107: | ||
document.getElementById('data-source-filter').innerHTML = filterHtml; | document.getElementById('data-source-filter').innerHTML = filterHtml; | ||
// Set up table. | |||
const table = new Tabulator("#dct-tabulator", { | const table = new Tabulator("#dct-tabulator", { | ||
layout: 'fitColumns', | layout: 'fitColumns', | ||
Line 130: | Line 135: | ||
}); | }); | ||
table.on("tableBuilt", () => { table.setData(dcts); }); | table.on("tableBuilt", () => { | ||
table.setData(dcts); | |||
table.setFilter(dctFilter, { foo:3 }); | |||
console.log(table.getFilters()) | |||
}); | |||
}) | }) | ||
</script> | </script> | ||
<div id="dct-list-wrapper"> | <div id="dct-list-wrapper"> | ||
<h1>Social Media and Crowdsourcing Technologies</h1> | <h1>Social Media and Crowdsourcing Technologies</h1> |
Revision as of 10:53, 8 June 2022
Development verstion of the DCT List.
Not ready for production!