Files
Toolbox/public/common/nav.js
T

27 lines
1.0 KiB
JavaScript

(async function(){
try {
const wrap = document.querySelector('#topbar')
if (!wrap) return
const res = await fetch('/common/nav.html')
const html = await res.text()
wrap.innerHTML = html
const path = location.pathname.toLowerCase()
let key = ''
if (path.includes('/tools/weibo/')) key = 'weibo'
else if (path.includes('/tools/markets/')) key = 'markets'
else if (path.includes('/tools/wall/')) key = 'wall'
else if (path.includes('/tools/funds/')) key = 'funds'
else if (path.includes('/tools/ccb_private_funds/')) key = 'ccb_private_funds'
else if (path.includes('/tools/cloud/')) key = 'cloud'
else if (path.includes('/tools/weekly/')) key = 'weekly'
else if (path.includes('/tools/ai-lib/')) key = 'ai-lib'
else if (path.includes('/tools/expense/')) key = 'expense'
if (key) {
wrap.querySelectorAll('a.tab').forEach(a => {
if (a.dataset.key === key) a.classList.add('active')
else a.classList.remove('active')
})
}
} catch {}
})()