NavigationBar.js 838 B

123456789101112131415161718192021222324252627282930313233
  1. export class NavigationBar {
  2. constructor() {
  3. this.navbar = document.getElementsByTagName('nav')[0]
  4. this.mainLinks = document.getElementById('navigation-links')
  5. this.supplementalLinks = document.getElementById('supplemental-links')
  6. }
  7. createLink(title, url, isSupplemental) {
  8. const linkA = document.createElement('a')
  9. linkA.href = url
  10. linkA.innerText = title
  11. const navigationLi = document.createElement('li')
  12. navigationLi.appendChild(linkA)
  13. navigationLi.title = title
  14. if (isSupplemental) {
  15. this.supplementalLinks.appendChild(navigationLi)
  16. } else {
  17. this.mainLinks.appendChild(navigationLi)
  18. }
  19. }
  20. refreshSectionPolicyLinks(policy) {
  21. if (policy.showDiagnostics) {
  22. this.createLink('Diagnostics', '/diagnostics', true)
  23. }
  24. if (policy.showLogList) {
  25. this.createLink('Logs', '/logs', true)
  26. }
  27. }
  28. }