MediaWiki:Common.js

From Realm Of Thrones
Revision as of 02:32, 25 March 2025 by SitX (talk | contribs)
Jump to navigation Jump to search

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.addEventListener("DOMContentLoaded", function () {
    var toc = document.getElementById("toc");
    if (!toc) return; // Exit if no ToC exists

    // Create Floating ToC Box
    var floatingToc = document.createElement("div");
    floatingToc.id = "floating-toc";

    // Move the existing ToC into the new floating box
    floatingToc.appendChild(toc);
    document.body.appendChild(floatingToc);

    // Add Click Event to Collapse/Expand
    floatingToc.addEventListener("click", function () {
        floatingToc.classList.toggle("collapsed");
    });
});