MediaWiki

Group-Grouse.js: Difference between revisions

From Grouse House Wiki

No edit summary
No edit summary
 
(175 intermediate revisions by the same user not shown)
Line 1: Line 1:
$(function() {
$(function() {
     $('h2.c-header.active span.mw-headline').each(function () {
     $('h2.c-header.active span.mw-headline').each(function () {
Line 5: Line 4:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.toString().replace("'", "\\'").replace("?", "\\?").replace("!", "\\!").replace(/,/g, "\\,").replace("/", "\\/");


         var $secondheader = "#" + $headernameu + "_2";
         var $secondheader = "#" + $headernameu + "_2";
Line 12: Line 12:
         $header.after('[Edit]');
         $header.after('[Edit]');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');
        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
       
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;


         $("a[href*='" + $secondheader + "']").hide();
         $("a[href*='" + $secondheader + "']").hide();
Line 27: Line 22:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");


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


         var $editsection = $( $secondheader ).next().children('a').attr("href");
         var $editsection = $( $secondheader ).next().children('a').attr("href");
 
       
         $header.after('[Edit]');
         $header.after('[Edit]');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');


        var $pagename = $('h1#firstHeading').html();
         $("a[href='" + $secondheader + "']").hide();
        $pagenameu = $pagename.split(' ').join('_');
       
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;
 
         $("a[href*='" + $secondheader + "']").hide();
     });
     });
  });
  });
Line 49: Line 40:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");


         var $secondheader = "#" + $headernameu + "_2";
         var $secondheader = "#" + $headernameu + "_2";
Line 71: Line 63:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");


         var $secondheader = "#" + $headernameu + "_2";
         var $secondheader = "#" + $headernameu + "_2";
Line 78: Line 71:
         $header.after('[Edit]');
         $header.after('[Edit]');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');
         $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');
        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
       
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;


         $("a[href*='" + $secondheader + "']").hide();
         $("a[href*='" + $secondheader + "']").hide();
Line 93: Line 81:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");


         var $secondheader = "#" + $headernameu + "_2";
         var $secondheader = "#" + $headernameu + "_2";
Line 115: Line 104:
         var $headername = $header.html();
         var $headername = $header.html();
         $headernameu = $headername.split(' ').join('_');
         $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");


         var $secondheader = "#" + $headernameu + "_2";
         var $secondheader = "#" + $headernameu + "_2";
Line 131: Line 121:
     });
     });
  });
  });
/* Mobile TOC */
$(document).ready(function () {
            setTimeout(() => {
                // Get ToC div
               
                toc = document.getElementById("mobiletoc"); //Add a header
                tocHeader = document.createElement("h2");
                tocHeader.innerText = "Table of contents";
                toc.appendChild(tocHeader); // Get the h3 tags — ToC entries
                // Create a list for the ToC entries
                tocList = document.createElement("ul");
                $('h3').each(function () {
                    tocListItem = document.createElement("li");
                    // a link for the h3
                    tocEntry = document.createElement("a");
                    tocEntry.setAttribute("href", "#" + $(this).attr('id'));
                    tocEntry.innerText = $(this).text();
                    tocListItem.appendChild(tocEntry);
                    tocList.appendChild(tocListItem);
                });
                toc.appendChild(tocList);
            });
        });

Latest revision as of 19:24, 14 April 2024

$(function() {
    $('h2.c-header.active span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.toString().replace("'", "\\'").replace("?", "\\?").replace("!", "\\!").replace(/,/g, "\\,").replace("/", "\\/");

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        $("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('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");
        
        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

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

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

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

        $("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('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        $("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('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

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

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

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

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

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