mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-05-17 12:34:32 +02:00
WIP: Docs
This commit is contained in:
parent
1e7ae885b4
commit
ae7bfb2c97
28 changed files with 822 additions and 1 deletions
docs/static/js
31
docs/static/js/extra.js
vendored
Normal file
31
docs/static/js/extra.js
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Link tabs, as per https://facelessuser.github.io/pymdown-extensions/extensions/tabbed/#linked-tabs
|
||||
|
||||
const savedTab = localStorage.getItem('savedTab')
|
||||
const tabs = document.querySelectorAll(".tabbed-set > input")
|
||||
for (const tab of tabs) {
|
||||
tab.addEventListener("click", () => {
|
||||
const current = document.querySelector(`label[for=${tab.id}]`)
|
||||
const pos = current.getBoundingClientRect().top
|
||||
const labelContent = current.innerHTML
|
||||
const labels = document.querySelectorAll('.tabbed-set > label, .tabbed-alternate > .tabbed-labels > label')
|
||||
for (const label of labels) {
|
||||
if (label.innerHTML === labelContent) {
|
||||
document.querySelector(`input[id=${label.getAttribute('for')}]`).checked = true
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve scroll position
|
||||
const delta = (current.getBoundingClientRect().top) - pos
|
||||
window.scrollBy(0, delta)
|
||||
|
||||
// Save
|
||||
localStorage.setItem('savedTab', labelContent)
|
||||
})
|
||||
|
||||
// Select saved tab
|
||||
const current = document.querySelector(`label[for=${tab.id}]`)
|
||||
const labelContent = current.innerHTML
|
||||
if (savedTab === labelContent) {
|
||||
tab.checked = true
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue