You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
First-Website/resources/js/insertNavbar.js

67 lines
2.1 KiB

var c = document.createElement.bind(document);
var d = document.getElementById.bind(document);
var g = document.querySelector.bind(document);
// Insert nav tag
var navigation = c("nav")
navigation.className = "navigation"
5 years ago
var navbarList = c("ul")
navbarList.className = "navbarList"
navigation.appendChild(navbarList)
5 years ago
document.body.appendChild(navigation)
// Create Navbar
Navbar.forEach(i=>{
var navList = c("li")
navList.className = "navList"
var navButton = c("button");
navButton.className = "navbarbutton"
5 years ago
navButton.innerHTML = "<i class='" + i.icon + " fa-lg'></i>" + i.name
if (i.link) {
var navLink = c("a");
navLink.href = i.link
navLink.appendChild(navButton);
navButton = navLink
}
if (i.desc) {
navButton.title = i.desc
}
navList.appendChild(navButton)
var dropdownList = c("ul")
dropdownList.className = "dropdownList"
dropdownList.style = "display:none;"
if (typeof i.dropdown == "object") {
i.dropdown.forEach(d=>{
var dropdownListItem = c("li");
// Dropdown button
var dropdownButton = c("button");
5 years ago
dropdownButton.innerHTML = "<i class='" + d.icon + " fa-lg'></i>" + d.name
dropdownButton.className = "dropdownButton"
if (d.desc) {
dropdownButton.title = d.desc
}
if (d.link) {
var link = c("a");
link.href = d.link
link.appendChild(dropdownButton);
dropdownButton = link
}
dropdownListItem.appendChild(dropdownButton);
dropdownList.appendChild(dropdownListItem);
})
}
$(navList).append(dropdownList)
navbarList.appendChild(navList);
})
// Appearance changer
var appearanceSwitch = c("label")
appearanceSwitch.className = "appearance"
appearanceSwitch.title = "Dark/Light mode"
var appearanceInput = c("input")
appearanceInput.type = "checkbox"
var appearanceSpan = c("span")
appearanceSpan.className = "appearanceSlider"
$(appearanceSwitch).append(appearanceInput, appearanceSpan)
navigation.appendChild(appearanceSwitch)