home-dashboard/static/js/data.js
Carlo Mandelli 76b0a81b07 first commit
2021-08-08 09:45:36 +02:00

15 lines
523 B
JavaScript

function fetchAndRender(name) {
fetch('./conf/' + name + '.json')
.then(response => response.json())
.then(data => {
const mysource = document.getElementById(name + '-template').innerHTML;
const mytemplate = Handlebars.compile(mysource);
const myresult = mytemplate(data);
document.getElementById(name).innerHTML = myresult;
});
}
document.addEventListener('DOMContentLoaded', () => {
fetchAndRender('apps');
fetchAndRender('links');
});