1/** 2 * Canonical site sidebar navigation â single source of truth for menu items. 3 * Loaded by sidebarMenu.js before the sidebar is built. 4 */ 5(function (global) { 6 'use strict'; 7 8 /** @type {Array<{ href: string, img: string, label: string }>} */ 9 var SIDEBAR_NAV = [ 10 { href: '/dashboard.html', img: '/icons/puppybutton.png', label: 'Home' }, 11 { href: '/music.html', img: '/icons/musicbutton.png', label: 'Music' }, 12 { href: '/friends.html', img: '/icons/friendsbutton.png', label: 'Friends' }, 13 { href: '/silly.html', img: 'https://adriansblinkiecollection.neocities.org/buttons/4.jpg', label: 'Silly Things' }, 14 { href: '/cookbook.html', img: '/icons/cookbookbutton.png', label: 'Cookbook' }, 15 { href: '/daw.html', img: '/icons/dawbutton.png', label: 'DAW' }, 16 { href: '/shrines.html', img: 'https://adriansblinkiecollection.neocities.org/buttons/a44.gif', label: 'Shrines' }, 17 { href: '/arcade.html', img: '/icons/arcadebutton.webp', label: 'Arcade' }, 18 { href: '/casino.html', img: '/icons/iheartgambling.png', label: 'Casino' }, 19 { href: '/?app=studyhall', img: '/icons/studyhallbutton.png', label: 'Study Hall' }, 20 { href: '/blog.html', img: '/icons/blogbutton.png', label: 'Blog' }, 21 { href: '/chatroom.html', img: '/icons/chatbutton.png', label: 'Chat' } 22 ]; 23 24 var SITE_NAV_MARKER = /puppybutton\.png|icons\/puppybutton/i; 25 26 function getBasePath() { 27 var path = (global.location && global.location.pathname) || ''; 28 return path.indexOf('/blog/') !== -1 ? '../' : ''; 29 } 30 31 function resolveHref(basePath, href) { 32 if (!href) return basePath; 33 if (/^(https?:)?\/\//i.test(href) || href.indexOf('//') === 0) return href; 34 if (href.charAt(0) === '/') return href; 35 return basePath + href; 36 } 37 38 function resolveImg(basePath, src) { 39 if (!src) return src; 40 if (/^https?:\/\//i.test(src)) return src; 41 if (src.charAt(0) === '/') return src; 42 return basePath + src; 43 } 44 45 function buildNavListElement(basePath) { 46 var ul = document.createElement('ul'); 47 for (var i = 0; i < SIDEBAR_NAV.length; i++) { 48 var item = SIDEBAR_NAV[i]; 49 var li = document.createElement('li'); 50 var link = document.createElement('a'); 51 link.href = resolveHref(basePath, item.href); 52 53 var img = document.createElement('img'); 54 img.src = resolveImg(basePath, item.img); 55 img.alt = item.label; 56 img.title = item.label; 57 img.className = 'sidebar-nav-btn-img'; 58 img.decoding = 'async'; 59 link.appendChild(img); 60 link.appendChild(document.createTextNode(' ' + item.label)); 61 62 li.appendChild(link); 63 ul.appendChild(li); 64 } 65 return ul; 66 } 67 68 function populateSidebarNav(sidebar, basePath) { 69 if (!sidebar) return; 70 basePath = basePath != null ? basePath : getBasePath(); 71 72 var ul = sidebar.querySelector('ul'); 73 if (!ul) { 74 ul = document.createElement('ul'); 75 sidebar.appendChild(ul); 76 } 77 78 var fresh = buildNavListElement(basePath); 79 ul.innerHTML = ''; 80 while (fresh.firstChild) { 81 ul.appendChild(fresh.firstChild); 82 } 83 } 84 85 function createSettingsButton() { 86 var settingsBtn = document.createElement('a'); 87 settingsBtn.href = 'javascript:void(0)'; 88 settingsBtn.className = 'settingsbtn'; 89 settingsBtn.innerHTML = '<i class="fa-solid fa-gear fa-width-auto" aria-hidden="true"></i>'; 90 settingsBtn.title = 'Settings'; 91 settingsBtn.addEventListener('click', function (e) { 92 e.preventDefault(); 93 if (global.SettingsMenu && typeof global.SettingsMenu.openSettings === 'function') { 94 global.SettingsMenu.openSettings(); 95 } else if (global.ChatroomSettings && typeof global.ChatroomSettings.showSettings === 'function') { 96 global.ChatroomSettings.showSettings(); 97 } 98 }); 99 return settingsBtn; 100 } 101 102 function createSidebarElement(basePath) {
103 basePath = basePath != null ? basePath : getBasePath(); 104 var sidebar = document.createElement('div'); 105 sidebar.id = 'sidebar-menu'; 106 sidebar.setAttribute('data-sidebar-injected', '1'); 107 sidebar.appendChild(createSettingsButton()); 108 sidebar.appendChild(buildNavListElement(basePath)); 109 return sidebar; 110 } 111 112 function isSidebarSourceNav(nav) { 113 if (!nav || !nav.querySelector) return false; 114 if (nav.id && /footer|lightbox|quiz|blog-back/i.test(nav.id)) return false; 115 if (nav.classList && ( 116 nav.classList.contains('cookbook-lightbox-nav') || 117 nav.classList.contains('cookbook-quiz-nav') 118 )) return false; 119 var html = nav.innerHTML || ''; 120 return SITE_NAV_MARKER.test(html); 121 } 122 123 function removeLegacySidebarSourceNavs() { 124 if (typeof document === 'undefined') return; 125 var navs = document.querySelectorAll('nav'); 126 for (var i = 0; i < navs.length; i++) { 127 if (isSidebarSourceNav(navs[i])) { 128 navs[i].remove(); 129 } 130 } 131 } 132 133 global.SidebarNavConfig = { 134 items: SIDEBAR_NAV, 135 getBasePath: getBasePath, 136 resolveHref: resolveHref, 137 resolveImg: resolveImg, 138 buildNavListElement: buildNavListElement, 139 populateSidebarNav: populateSidebarNav, 140 createSidebarElement: createSidebarElement, 141 createSettingsButton: createSettingsButton, 142 isSidebarSourceNav: isSidebarSourceNav, 143 removeLegacySidebarSourceNavs: removeLegacySidebarSourceNavs 144 }; 145})(typeof window !== 'undefined' ? window : this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.