Jump to content

MediaWiki:Common.js

From International Treaty Law Wiki
Revision as of 22:10, 17 January 2026 by DrInternationalLaw (talk | contribs) (Created page with "Any JavaScript here will be loaded for all users on every page load.: PDF- und Share-Buttons oben rechts neben dem Seitentitel: $(function () { // Nur auf Artikelseiten (Namespace 0) if (mw.config.get('wgNamespaceNumber') !== 0) return; // PDF-Button mit Icon var pdfButton = ` <a class="pdf-download-button" href="javascript:window.print()" style="margin-left:10px;"> 📄 PDF </a> `; // Share-Button mit Icon...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
/* PDF- und Share-Buttons oben rechts neben dem Seitentitel */
$(function () {

    // Nur auf Artikelseiten (Namespace 0)
    if (mw.config.get('wgNamespaceNumber') !== 0) return;

    // PDF-Button mit Icon
    var pdfButton = `
        <a class="pdf-download-button" href="javascript:window.print()" style="margin-left:10px;">
            📄 PDF
        </a>
    `;

    // Share-Button mit Icon
    var shareButton = `
        <a class="pdf-download-button" href="javascript:navigator.share ? navigator.share({title: document.title, url: location.href}) : alert('Teilen wird von diesem Browser nicht unterstützt.')" style="margin-left:10px; background:#28a745;">
            🔗 Teilen
        </a>
    `;

    // Buttons an die Überschrift anhängen
    $('.mw-first-heading').append(pdfButton + shareButton);
});