Allow admin password to be revealed
This commit is contained in:
parent
85c63f24a9
commit
34db2e1923
10 changed files with 117 additions and 19 deletions
|
|
@ -1 +1,2 @@
|
|||
import "~/src/lib/copy"
|
||||
import "~/src/lib/copy"
|
||||
import "~/src/lib/reveal"
|
||||
43
internal/dis/component/server/assets/src/lib/reveal/index.ts
Normal file
43
internal/dis/component/server/assets/src/lib/reveal/index.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
document.querySelectorAll('span').forEach((elem: Element) => {
|
||||
if (!elem.hasAttribute('data-reveal')) return
|
||||
|
||||
addReveal(elem as HTMLSpanElement, 10000);
|
||||
})
|
||||
|
||||
export function addReveal(span: HTMLSpanElement, hideDelay: number) {
|
||||
const content = span.getAttribute("data-reveal") ?? '(no content)'
|
||||
|
||||
let isHidden = true
|
||||
|
||||
// handler to hide the element
|
||||
const hide = () => {
|
||||
isHidden = true
|
||||
span.innerText = "(click to reveal)"
|
||||
}
|
||||
hide()
|
||||
|
||||
const reveal = () => {
|
||||
isHidden = false
|
||||
const code = document.createElement('code')
|
||||
code.append(content)
|
||||
code.addEventListener('click', (evt) => {
|
||||
evt.preventDefault()
|
||||
|
||||
if (!navigator.clipboard) return
|
||||
navigator.clipboard.writeText(content)
|
||||
})
|
||||
code.style.userSelect = "all";
|
||||
|
||||
span.innerHTML = ""
|
||||
span.append(code)
|
||||
}
|
||||
|
||||
span.addEventListener("click", (evt) => {
|
||||
evt.preventDefault()
|
||||
|
||||
|
||||
if (!isHidden) return
|
||||
reveal()
|
||||
setTimeout(hide, hideDelay) // hide again after 1 second
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue