main.js 705 B

123456789101112131415161718192021
  1. // add text/html accept header to receive html instead of json for the requests
  2. document.body.addEventListener('htmx:configRequest', function(evt) {
  3. evt.detail.headers["Accept"] = "text/html,*/*";
  4. console.log(evt.detail.headers);
  5. });
  6. // copy the link to clipboard
  7. function handleCopyLink(element) {
  8. navigator.clipboard.writeText(element.dataset.url);
  9. }
  10. // copy the link and toggle copy button style
  11. function handleShortURLCopyLink(element) {
  12. handleCopyLink(element);
  13. const parent = document.querySelector("#shorturl");
  14. if (!parent || parent.classList.contains("copied")) return;
  15. parent.classList.add("copied");
  16. setTimeout(function() {
  17. parent.classList.remove("copied");
  18. }, 1000);
  19. }