Feat: documentation, UI/UX
This commit is contained in:
27
website/public/docs.js
Normal file
27
website/public/docs.js
Normal file
@@ -0,0 +1,27 @@
|
||||
function dismissNotice() {
|
||||
document.getElementById('docs-notice').classList.add('hidden');
|
||||
}
|
||||
|
||||
function showTopic(s, t) {
|
||||
document.querySelectorAll('.docs-content article').forEach(a => a.classList.remove('visible'));
|
||||
document.querySelectorAll('.docs-sidebar button').forEach(b => b.classList.remove('active'));
|
||||
const article = document.getElementById('topic-s' + s + 't' + t);
|
||||
const btn = document.querySelector('[data-s="' + s + '"][data-t="' + t + '"]');
|
||||
if (article) article.classList.add('visible');
|
||||
if (btn) btn.classList.add('active');
|
||||
history.replaceState(null, '', '#s' + s + 't' + t);
|
||||
document.querySelector('.docs-content').scrollTop = 0;
|
||||
}
|
||||
|
||||
function parseHash() {
|
||||
const m = location.hash.match(/^#s(\d+)t(\d+)$/);
|
||||
return m ? [parseInt(m[1]), parseInt(m[2])] : [0, 0];
|
||||
}
|
||||
|
||||
document.querySelectorAll('.docs-sidebar button').forEach(btn => {
|
||||
btn.addEventListener('click', () => showTopic(+btn.dataset.s, +btn.dataset.t));
|
||||
});
|
||||
|
||||
const [s, t] = parseHash();
|
||||
showTopic(s, t);
|
||||
window.addEventListener('hashchange', () => { const [s, t] = parseHash(); showTopic(s, t); });
|
||||
Reference in New Issue
Block a user