MediaWiki

Foreground.js: Difference between revisions

From Grouse House Wiki

No edit summary
(Blanked the page)
Tag: Blanking
Line 1: Line 1:


/* Adding link to discussion button */
$(function() {
    $('h1#firstHeading').each(function () {
        var $header = $(this).children('span').html();
        $pagetitle = $header.split(' ').join('_');
        $url = $(location).attr('href');
        $spliturl = $url.split(':').join(' ');
        var main = $spliturl.indexOf("Main");
        var mediawiki = $spliturl.indexOf("MediaWiki");
        var special = $spliturl.indexOf("Special");
        var edit = $spliturl.indexOf("edit");
        if(main !== -1){
          $(this).children('div').children('a').css("display", "none");
        } else if(mediawiki !== -1){
          $(this).children('div').children('a').css("display", "none");
        } else if(special !== -1){
          $(this).children('div').children('a').css("display", "none");
        } else if(edit !== -1){
          $(this).children('div').children('a').css("display", "none");
        } else{
        $talklink = "https://grousehouse.wiki/Talk:" + $pagetitle;
        $link = $(this).children('div').children('a');
        $link.attr("href", $talklink);
        }
    });
});
/* Section toggles */
function toggleSectionsOn() {
    var sections = document.getElementsByClassName("c-header"),
        len = sections !== null ? sections.length : 0,
        i = 0;
    for(i; i < len; i++) {
        var content = sections[i].nextElementSibling;
        content.style.display = "block";
        sections[i].classList.remove("hidden");
        sections[i].classList.add("active")
    }
}
function toggleSectionsOff() {
    var sections = document.getElementsByClassName("c-header"),
        len = sections !== null ? sections.length : 0,
        i = 0;
    for(i; i < len; i++) {
        var content = sections[i].nextElementSibling;
        content.style.display = "none";
        sections[i].classList.remove("active");
        sections[i].classList.add("hidden")
    }
}
/* Spoiler toggles */
function toggleSpoilersOn() {
    var sections = document.getElementsByClassName("spoilerButton"),
        len = sections !== null ? sections.length : 0,
        i = 0;
    for(i; i < len; i++) {
        var content = sections[i].nextElementSibling;
        content.style.display = "block";
        sections[i].classList.remove("hidden");
        sections[i].classList.add("active")
    }
}
function toggleSpoilersOff() {
    var sections = document.getElementsByClassName("spoilerButton"),
        len = sections !== null ? sections.length : 0,
        i = 0;
    for(i; i < len; i++) {
        var content = sections[i].nextElementSibling;
        content.style.display = "none";
        sections[i].classList.remove("active");
        sections[i].classList.add("hidden")
    }
}

Revision as of 22:15, 24 February 2024