JS: Difference between revisions

From ConsoleMods Wiki
Jump to navigation Jump to search
m (Protected "JS" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
m (BACK BUTTON ON TALK PAGE MOVED TO LOCALSETTINGS.PHP)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* AUTO HIDE SIDEBAR ON MOBILE */
<nowiki>
if (screen.width < 450) {
    $('body').addClass("sidebar-collapsed");
}
 
/* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */
/* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */
$(":not(.references li) ol li").click(function (e) {
$(":not(.references li) ol li").click(function (e) {
Line 25: Line 21:
     }
     }
});
});
 
</nowiki>
/* HIDE NAMESPACES */
var namespace_name;
$('title').each(function() {
    var page_title = this.innerHTML;
    if (page_title.includes(":") && !page_title.includes("MediaWiki") && !page_title.includes("\"")) {
        namespace_name = page_title.split(':',2)[0];
        var page_name = this.innerHTML = page_title.split(':',2)[1];
        page_name = page_name.replace(" - ConsoleMods Wiki", "");
 
        $('h1#title').each(function() {
            this.innerHTML = page_name;
        });
 
        $('#firstHeading').each(function() {
            this.innerHTML = page_name;
        });
 
        /* COLOR HEADER TITLE */
        if (!page_title.includes("Mods Wiki") && !page_title.includes("ConsoleMods:")) {
            namespace_name = namespace_name.replace("ConsoleMods", "");
        }
 
    } else {
      this.innerHTML = "ConsoleMods Wiki";
    }
});
 
if (namespace_name != undefined && !namespace_name.includes("Special") && !namespace_name.includes("Category") && !namespace_name.includes("File") && !window.location.href.includes("action=history")) {
    $('a[title*=":"]').each(function() {
        var link_page_name = this.innerHTML.split(':',2)[1];
        if (link_page_name != undefined) {
            this.innerHTML = link_page_name;
        }
    });
}
 
/* BACK BUTTON ON TALK PAGES */
$("#ca-talk a").each(function() {
    if (window.location.href.includes("_talk")) {
        this.href = this.href.replace("_talk","");
        $("#ca-talk a span").each(function() { this.innerHTML = "Back to Page" });
    }
    if (window.location.href.includes("Talk:")) {
        this.href = this.href.replace("Talk:","");
        $("#ca-talk a span").each(function() { this.innerHTML = "Back to Page" });
    }
});

Latest revision as of 03:08, 10 June 2023

/* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */ $(":not(.references li) ol li").click(function (e) { e.stopPropagation(); if(!($(this).hasClass("highlighted"))) { $(this).addClass("highlighted"); $(this).find("li").addClass("highlighted"); } else { $(this).removeClass("highlighted"); $(this).find("li").removeClass("highlighted"); } }); /* TOGGLE SIDEBAR VIA CONSOLEMODS TEXT */ $("#footer-partnersico:first-child").click(function (e) { e.stopPropagation(); if(!($('body').hasClass("sidebar-collapsed"))) { $('body').addClass("sidebar-collapsed"); } else { $('body').removeClass("sidebar-collapsed"); } });