kutt/static/scripts/main.js

21 lines
705 B
JavaScript
Raw Normal View History

2024-08-11 18:41:03 +03:30
// add text/html accept header to receive html instead of json for the requests
document.body.addEventListener('htmx:configRequest', function(evt) {
evt.detail.headers["Accept"] = "text/html,*/*";
console.log(evt.detail.headers);
});
// copy the link to clipboard
function handleCopyLink(element) {
navigator.clipboard.writeText(element.dataset.url);
}
// copy the link and toggle copy button style
function handleShortURLCopyLink(element) {
handleCopyLink(element);
const parent = document.querySelector("#shorturl");
if (!parent || parent.classList.contains("copied")) return;
parent.classList.add("copied");
setTimeout(function() {
parent.classList.remove("copied");
}, 1000);
}