MediaWiki

MediaWiki:BibTest.js

From Illustrations in German Translations of Mark Twain's Works

Revision as of 21:36, 11 May 2026 by HMHTEST (talk | contribs) (Created page with "document.querySelectorAll(".expand-btn").forEach(button => { button.addEventListener("click", () => { const related = button.nextElementSibling; related.classList.toggle("hidden"); button.textContent = related.classList.contains("hidden") ? "Show Related Sources" : "Hide Related Sources"; }); }); document.querySelectorAll(".filter-btn").forEach(button => { button.addEventListener(...")
(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.
document.querySelectorAll(".expand-btn").forEach(button => {

    button.addEventListener("click", () => {

        const related =
            button.nextElementSibling;

        related.classList.toggle("hidden");

        button.textContent =
            related.classList.contains("hidden")
            ? "Show Related Sources"
            : "Hide Related Sources";

    });

});

document.querySelectorAll(".filter-btn").forEach(button => {

    button.addEventListener("click", () => {

        document.querySelectorAll(".filter-btn")
            .forEach(btn => btn.classList.remove("active"));

        button.classList.add("active");

        const filter =
            button.dataset.filter;

        document.querySelectorAll(".bib-entry")
            .forEach(entry => {

                const tags =
                    entry.dataset.tags;

                if (
                    filter === "all" ||
                    tags.includes(filter)
                ) {
                    entry.style.display = "block";
                } else {
                    entry.style.display = "none";
                }

            });

    });

});