blob: 087e6c227c49b5679add9ef30ddca35d17eecce8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
function sidebar_close() {
$("#sidebar").fadeOut();
}
function sidebar_open() {
$("#sidebar").fadeIn();
}
function show_loading() {
$("#content").html(("<div class='spinner centered'></div>"));
}
function load(file, title) {
show_loading();
$("#header").text(title);
document.title = 'IcHTML - ' + title;
$.get("content/"+file, function(data) {
$("#content").html(data);
}, "text");
}
function onload() {
$.getJSON("content/content.json", function(data){
var el = $("#sidebar")[0];
data.forEach((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"){
atag.href = "#";
atag.onclick = function(){
sidebar_close();
load(item.url, item.name);
};
}
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');
});
}
|