diff options
| author | Jeroen <jeroenpardon@users.noreply.github.com> | 2020-08-07 03:12:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-07 03:12:38 +0200 |
| commit | 42971a3cae06eed7a67f893930578c675c615a15 (patch) | |
| tree | 712f80f319f667d181f917969f9607f79e1c812c /assets/js/data.js | |
| parent | 3cbb7a78a76bccb1036cd339f39eb88867a50710 (diff) | |
| parent | 9880643655973f68092dd3ae278ff76a47f5c2a0 (diff) | |
Merge pull request #11 from tionis/master
Removed jQuery Dependency and Added Scrollbar for Options
Diffstat (limited to 'assets/js/data.js')
| -rwxr-xr-x | assets/js/data.js | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/assets/js/data.js b/assets/js/data.js index e89b2de..cf8b9c9 100755 --- a/assets/js/data.js +++ b/assets/js/data.js @@ -1,35 +1,50 @@ var data_links = "links.json"; - -$(document).ready(function(){ - $.getJSON(data_links, - function (data) { - var mysource = $('#links-template').html(); - var mytemplate = Handlebars.compile(mysource); - var myresult = mytemplate(data) - $('#links').html(myresult); - }); +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 () { + if (!bookmarks) { + fetch(data_links) + .then(response => response.json()) + .then(function (data) { + handleLinks(data); + localStorage.setItem("links", JSON.stringify(data)); + }); + } else { + handleLinks(bookmarks); + } }); var data_apps = "apps.json"; - -$(document).ready(function(){ - $.getJSON(data_apps, + +document.addEventListener("DOMContentLoaded", function () { + fetch(data_apps) + .then( response => response.json()) + .then( function (data) { - var mysource = $('#apps-template').html(); + var mysource = document.getElementById("apps-template").innerHTML; var mytemplate = Handlebars.compile(mysource); var myresult = mytemplate(data) - $('#apps').html(myresult); - }); + document.getElementById("apps").innerHTML = myresult; + }); }); var data_providers = "providers.json"; - -$(document).ready(function(){ - $.getJSON(data_providers, + +document.addEventListener("DOMContentLoaded", function () { + fetch(data_providers) + .then( response => response.json()) + .then( function (data) { - var mysource = $('#providers-template').html(); + var mysource = document.getElementById("providers-template").innerHTML; var mytemplate = Handlebars.compile(mysource); var myresult = mytemplate(data) - $('#providers').html(myresult); - }); + document.getElementById("providers").innerHTML = myresult; + }); });
\ No newline at end of file |