PageSourceSearch

https://www.thf-paderborn.de/wp-content/themes/flib/templates/comp…?ver=85120206ead2745fba9a965df04c2131

js thf-paderborn.de collected 2026-10-02 10:49:31 UTC 1,797 bytes, 57 lines download raw bytes

1/**
2 * Kopiert einen Link in die Zwischenablage und zeigt einen Toast an.
3 *
4 * @param {HTMLElement} el - Das Element, dessen data-copy-Attribut kopiert werden soll. Fällt zurück auf window.location.href.
5 * @returns {void}
6 */
7function copyLinkAndToast(el) {
8  const url = el.getAttribute('data-copy') || window.location.href;
9  let toast = document.querySelector('.share-toast');
10  if (!toast) {
11    toast = document.createElement('span');
12    toast.className = 'share-toast';
13    document.body.appendChild(toast);
14  }
15  // Versucht, den Link zu kopieren
16  let ok = false;
17  if (navigator.clipboard && window.isSecureContext) {
18    navigator.clipboard.writeText(url).then(() => {
19      ok = true;
20      show(ok);
21    }, () => show(false));
22  } else {
23    try {
24      const ta = document.createElement('textarea');
25      ta.value = url;
26      ta.setAttribute('readonly', '');
27      ta.style.position = 'fixed';
28      ta.style.top = '-9999px';
29      document.body.appendChild(ta);
30      ta.select();
31      document.execCommand('copy');
32      document.body.removeChild(ta);
33      ok = true;
34    } catch {
35      ok = false;
36    }
37    show(ok);
38  }
39
40  /**
41   * Zeigt einen Toast mit dem Kopierergebnis an.
42   * @param {boolean} success - Ob das Kopieren erfolgreich war.
43   * @returns {void}
44   */
45  function show(success) {
46    toast.textContent = success ? 'Link kopiert!' : 'Kopieren fehlgeschlagen';
47    toast.style.display = 'block';
48    clearTimeout(toast._t);
49    toast._t = setTimeout(() => { toast.style.display = 'none'; }, 1500);
50  }
51}
52
53// Aufruf: Einfach z.B. im DOMContentLoaded (Initialisiert das Kopieren bei Klick auf ein passendes Element)
54document.addEventListener('click', function(e) {
55  const el = e.target.closest('.copy-link [data-copy]');
56  if (el) copyLinkAndToast(el);
57});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.