feat: add copyable links for sharing
This commit is contained in:
parent
62a329aebd
commit
19319b8479
3 changed files with 56 additions and 12 deletions
|
@ -22,6 +22,25 @@ function checkPwd() {
|
|||
const pwd_el = document.getElementById("password");
|
||||
pwd_el.innerHTML = pwd;
|
||||
}
|
||||
|
||||
const copy_els = document.querySelectorAll(".copyable");
|
||||
const cb = window.navigator.clipboard;
|
||||
copy_els.forEach(el => {
|
||||
el.addEventListener("click", evt => {
|
||||
evt.preventDefault();
|
||||
let content = el.dataset.copyContent;
|
||||
if (content.includes("???")) {
|
||||
content = content.replace("???", pwd);
|
||||
}
|
||||
cb.writeText(content).then(() => {
|
||||
const curText = el.innerHTML;
|
||||
el.innerHTML = "copied!";
|
||||
setTimeout(() => {
|
||||
el.innerHTML = curText;
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
checkPwd();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue