This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
nav/assets/js/data.js

17 lines
545 B
JavaScript
Raw Normal View History

2022-11-03 17:02:36 +08:00
function fetchAndRender (name) {
fetch(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');
fetchAndRender('providers');
});