aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Gräf <roman.graef@gmail.com>2017-11-01 13:13:28 +0100
committerGitHub <noreply@github.com>2017-11-01 13:13:28 +0100
commita02ff72273dd19249eb6b88c3d733a483860040d (patch)
tree7ad265c9a101af6bf9074087705071f9fa73a375
parent04b5a749eb66a013a59ada41e4dc046595c9b3ea (diff)
downloadichtml-a02ff72273dd19249eb6b88c3d733a483860040d.tar.gz
ichtml-a02ff72273dd19249eb6b88c3d733a483860040d.tar.bz2
ichtml-a02ff72273dd19249eb6b88c3d733a483860040d.zip
Update default.js
-rw-r--r--res/default.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/res/default.js b/res/default.js
index 96ffd65..b918977 100644
--- a/res/default.js
+++ b/res/default.js
@@ -19,8 +19,45 @@ function load(file, title) {
}, "text");
}
+var contentid = 0;
+var contents = [];
+
function open_timetable() {
sidebar_close();
load('timetable.html', 'Stundenplan');
}
+function onload() {
+ $.getJSON("content/content.json", function(data){
+ var el = $("#sidebar");
+ data.forEach(function(item){
+ var load = item.load;
+ var url = item.url;
+ var name = item.name;
+ var img = item.img;
+ var atag = document.createElement("a");
+ if(load=="href"){
+ atag.href = url;
+ atag.target = "_blank";
+ atag.onclick = "sidebar_close()";
+ }
+ if(load=="content"){
+ contents[contentid] = item;
+ atag.href = "#";
+ atag.onclick = "load("+contentid+")";
+ contentid++;
+ }
+ var texttag = document.createTextNode(name);
+ if(img) {
+ var imgtag = document.createElement("img");
+ imgtag.src = img;
+ atag.appendChild(imgtag);
+ }
+ atag.appendChild(texttag);
+ atag.classList.add('button');
+ atag.classList.add('sidebar-button');
+ el.appendChild(atag);
+ });
+ el.lastChild.classList.add('sidebar-last');
+ });
+}