MediaWiki

Foreground.js: Difference between revisions

From Grouse House Wiki

No edit summary
No edit summary
Line 120: Line 120:
     $('h1#firstHeading').each(function () {
     $('h1#firstHeading').each(function () {
         var $header = $(this).children('span').html();
         var $header = $(this).children('span').html();
         var main = $header.indexOf("Main");
         /*var main = $header.indexOf("Main");
         if(main !== -1){
         if(main !== -1){
             $(this).children('div').children('a').css("display", "none");
             $(this).children('div').children('a').css("display", "none");
         } else{
         } else{
         return;  
         return;  
         }
         }*/


         var upload = $header.indexOf("Upload");
         var upload = $header.indexOf("Upload");
Line 160: Line 160:
     $('h1#firstHeading').each(function () {
     $('h1#firstHeading').each(function () {
         $url = $(location).attr('href')
         $url = $(location).attr('href')
         var mediawiki = $url.indexOf("Mediawiki");
         var main = $url.indexOf("Main");
         if(mediawiki !== -1){
         if(main !== -1){
             $(this).children('div').children('a').css("display", "none");
             $(this).children('div').children('a').css("display", "none");
         } else{
         } else{

Revision as of 23:41, 15 February 2024

/* Collapsible Headers */

var coll = document.getElementsByClassName("c-header");
var i;

for (i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    var content = this.nextElementSibling;
    if (content.style.display === "block") {
      content.style.display = "none";
      if (this.classList.contains("active")) {
         this.classList.remove("active");
         this.classList.add("hidden");
      } else {
         this.classList.add("hidden");
      }
    } else {
      content.style.display = "block";
      if (this.classList.contains("hidden")) {
         this.classList.remove("hidden");
         this.classList.add("active");
      } else {
         this.classList.add("active");
      }
    }
  });
}

/* Remove extra headers from edit button fix */

$(function() {
    $('h2.c-header.active span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h2.c-header.hidden span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h2.h-static span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.c-header.active span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.c-header.hidden span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.h-static span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');

        var $secondheader = "#" + $headernameu + "_2";

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

/* Adding link to discussion button */

$(function() {
    $('h1#firstHeading').each(function () {
        var $header = $(this).children('span').html();
        $pagetitle = $header.split(' ').join('_');

        $talklink = "https://grousehouse.wiki/Talk:" + $pagetitle;
        $link = $(this).children('div').children('a');

        $link.attr("href", $talklink);
    });
 });

/* Removing discussion link from certain pages */

$(function() {
    $('h1#firstHeading').each(function () {
        var $header = $(this).children('span').html();
        /*var main = $header.indexOf("Main");
        if(main !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }*/

        var upload = $header.indexOf("Upload");
        if(upload !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }

        var logout = $header.indexOf("Log");
        if(logout !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }

        var mediawiki = $header.indexOf("Mediawiki");
        if(mediawiki !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }

        var editing = $header.indexOf("Editing");
        if(editing !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }
    });
 });

$(function() {
    $('h1#firstHeading').each(function () {
        $url = $(location).attr('href')
        var main = $url.indexOf("Main");
        if(main !== -1){
             $(this).children('div').children('a').css("display", "none");
        } else{
        return; 
        }
    });
 });