forked from Luxato/Final-team-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
69 lines (68 loc) · 2.72 KB
/
menu.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
var menu = [
{ label: "Úloha 2", href: "#", class: "fa fa-level-down", items:
[
{ label: "Level 2", href: "#", class: "fa fa-home" },
{ label: "Level 2 s childami", href: "#", class: "fa fa-level-down", items:
[
{ label: "Level 3", href: "#", class: "fa fa-home" },
{ label: "Level 3", href: "#", class: "fa fa-home" }
]
}
]
},
{ label: "Úloha 3", href: "uloha3.html", class: "fa fa-calendar" },
{ label: "Úloha 4", href: "uloha4.html", class: "fa fa-bell" },
{ label: "Úloha 5", href: "uloha5.html", class: "fa fa-calculator" },
{ label: "Úloha 7", href: "#", class: "fa fa-map-o", items:
[
{ label: "Prevedenie 1", href: "uloha7_1.html", class: "fa fa-globe" },
{ label: "Prevedenie 2", href: "uloha7_2.html", class: "fa fa-map" }
]},
{ label: "Úloha 9", href: "uloha9.html", class: "fa fa-building" },
{ label: "Hry", href: "#", class: "fa fa-gamepad", items:
[
{ label: "Tomáš Gono", href: "hra_tomas.html", class: "fa fa-gamepad"},
{ label: "Michal Paluš", href: "hra_michal.html", class: "fa fa-gamepad"},
{ label: "Lukáš Stránovský", href: "hra_luky.html", class: "fa fa-gamepad"},
{ label: "Patrik Eliáš", href: "hra_pato.html", class: "fa fa-gamepad"},
{ label: "Adrián Rybanský", href: "hra_ado.html", class: "fa fa-gamepad"}
]
},
{ label: "Kontakt", href: "kontakt.html", class: "fa fa-phone" }
];
var m = document.getElementById('side-menu');
for(var i = 0; i < menu.length; i++) {
var li = document.createElement('li');
var actualPath = (window.location.pathname).substring((window.location.pathname).lastIndexOf("/")+1);
if (menu[i].href == actualPath) {
li.className += "actual";
}
var str = '<a href="'+menu[i].href+'"><i class="'+menu[i].class+'"></i> '+menu[i].label;
if (menu[i].items) {
str += '<span class="fa arrow"></span></a>';
str += '<ul class="nav nav-second-level">';
for(var j = 0; j < menu[i].items.length; j++) {
if (menu[i].items[j].href == actualPath) {
str += '<li class="actual">';
} else {
str += '<li>';
}
str += '<a href="'+menu[i].items[j].href+'"><i class="'+menu[i].items[j].class+'"></i> '+menu[i].items[j].label;
if (menu[i].items[j].items) {
str += '<span class="fa arrow"></span></a>';
str += '<ul class="nav nav-third-level">';
for(var k = 0; k < menu[i].items[j].items.length; k++) {
str += '<li><a href="'+menu[i].items[j].items[k].href+'"><i class="'+menu[i].items[j].items[k].class+'"></i> '+menu[i].items[j].items[k].label+'</a><li>';
}
str += "</ul>";
} else {
str += "</a></li>";
}
}
str += "</ul>";
} else {
str += "</a></li>";
}
li.innerHTML = str;
m.appendChild(li);
}