MediaWiki:Common.js: Difference between revisions

From Realm Of Thrones
Jump to navigation Jump to search
SitX (talk | contribs)
No edit summary
SitX (talk | contribs)
No edit summary
Line 1: Line 1:
document.addEventListener("DOMContentLoaded", function () {
document.addEventListener("DOMContentLoaded", function () {
     var toc = document.getElementById("toc");  
     var toc = document.getElementById("toc");
     var guidesSection = document.getElementById("p-Guides");  
     if (!toc) return; // Exit if no ToC exists


     if (toc && guidesSection) {
     // Create Floating ToC Box
         guidesSection.parentNode.insertBefore(toc, guidesSection);
    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");
     });
});
});

Revision as of 02:32, 25 March 2025

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");
    });
});