mirror of
https://github.com/OliveTin/OliveTin
synced 2026-08-23 19:16:33 +00:00
Build Snapshot / build-snapshot (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Codestyle checks / codestyle (push) Has been cancelled
DevSkim / DevSkim (push) Has been cancelled
38 lines
1005 B
JavaScript
38 lines
1005 B
JavaScript
export class NavigationBar {
|
|
constructor () {
|
|
this.navbar = document.getElementsByTagName('nav')[0]
|
|
this.mainLinks = document.getElementById('navigation-links')
|
|
this.supplementalLinks = document.getElementById('supplemental-links')
|
|
}
|
|
|
|
createLink (title, url, isSupplemental) {
|
|
const parent = (isSupplemental) ? this.supplementalLinks : this.mainLinks
|
|
|
|
const existsAlready = Array.from(parent.querySelectorAll('li')).some(el => el.title === title)
|
|
|
|
if (existsAlready) {
|
|
return
|
|
}
|
|
|
|
const linkA = document.createElement('a')
|
|
linkA.href = url
|
|
linkA.innerText = title
|
|
|
|
const navigationLi = document.createElement('li')
|
|
navigationLi.appendChild(linkA)
|
|
navigationLi.title = title
|
|
|
|
parent.appendChild(navigationLi)
|
|
}
|
|
|
|
refreshSectionPolicyLinks (policy) {
|
|
if (policy.showDiagnostics) {
|
|
this.createLink('Diagnostics', '/diagnostics', true)
|
|
}
|
|
|
|
if (policy.showLogList) {
|
|
this.createLink('Logs', '/logs', true)
|
|
}
|
|
}
|
|
}
|