Added loading of bookmark links from localStorage
This commit is contained in:
parent
531524d192
commit
9880643655
1 changed files with 18 additions and 9 deletions
|
@ -1,15 +1,24 @@
|
||||||
var data_links = "links.json";
|
var data_links = "links.json";
|
||||||
|
var bookmarks = JSON.parse(localStorage.getItem("links"));
|
||||||
|
|
||||||
|
function handleLinks(data) {
|
||||||
|
var mysource = document.getElementById("links-template").innerHTML;
|
||||||
|
var mytemplate = Handlebars.compile(mysource);
|
||||||
|
var myresult = mytemplate(data)
|
||||||
|
document.getElementById("links").innerHTML = myresult;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
fetch(data_links)
|
if (!bookmarks) {
|
||||||
.then( response => response.json())
|
fetch(data_links)
|
||||||
.then(
|
.then(response => response.json())
|
||||||
function (data) {
|
.then(function (data) {
|
||||||
var mysource = document.getElementById("links-template").innerHTML;
|
handleLinks(data);
|
||||||
var mytemplate = Handlebars.compile(mysource);
|
localStorage.setItem("links", JSON.stringify(data));
|
||||||
var myresult = mytemplate(data)
|
});
|
||||||
document.getElementById("links").innerHTML = myresult;
|
} else {
|
||||||
});
|
handleLinks(bookmarks);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var data_apps = "apps.json";
|
var data_apps = "apps.json";
|
||||||
|
|
Loading…
Reference in a new issue