all repos — rastro @ main

BitTorrent tracker!

app/static/js/app.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
(function () {
  "use strict";

  console.log("hey stranger, nothing here. kisses, pablo");

  function copyText(text) {
    if (navigator.clipboard && navigator.clipboard.writeText) {
      return navigator.clipboard.writeText(text);
    }
    var ta = document.createElement("textarea");
    ta.value = text;
    document.body.appendChild(ta);
    ta.select();
    try {
      document.execCommand("copy");
    } finally {
      document.body.removeChild(ta);
    }
    return Promise.resolve();
  }

  document.addEventListener("click", function (ev) {
    var btn = ev.target.closest("[data-copy], [data-copy-target]");
    if (!btn) return;
    var text = btn.getAttribute("data-copy");
    if (!text) {
      var sel = btn.getAttribute("data-copy-target");
      var el = sel ? document.querySelector(sel) : null;
      text = el ? el.textContent : "";
    }
    copyText(text || "").then(function () {
      var prev = btn.textContent;
      btn.textContent = document.documentElement.getAttribute("data-copied") || "copied";
      setTimeout(function () {
        btn.textContent = prev;
      }, 1200);
    });
  });
})();