From GrinderScape Wiki
Revision as of 04:46, 18 November 2020 by Maranami (Talk | contribs)

Jump to: navigation, search

// ***************************** Structure *****************************

// Remove unnecessary elements

$("div#p-tb").remove();

// Wrap the content

$("div#content, div#mw-navigation").wrapAll("
");

// Insert the header

$("
Wiki design is currently under construction. Wiki content is still available to browse.
<header>
</header>").insertBefore("div#main-wrapper");


// Organize the elements

// if(window.matchMedia("(max-width: 1024px)").matches){ // // The viewport is less than 1024 pixels wide // console.log("This is a mobile device."); // $("div#mw-navigation").appendTo(".main-nav"); // } else{ // // The viewport is at least 1024 pixels wide // console.log("This is a tablet or desktop."); // $("div#mw-navigation").insertBefore(".login"); // }

$("div#content").wrap("<section class='main-content-cstm'></section>"); $("div#mw-navigation").insertBefore(".main-content-cstm");

$("div#content").wrap("
");

$("div#mw-panel").insertAfter("div#content");

$("div#content").wrap("
"); $("").prependTo("div#content");

$("div#left-navigation").appendTo("div#navigation"); $("div#right-navigation").appendTo("div#navigation");

$("

Main page

").insertBefore("div#content"); $("div#content").wrap("
");

$("ul#footer-info").insertAfter("div#content");

// Insert the footer

$("<footer> </footer>").insertAfter(".main-content-cstm");

// Mobile Navigation Click Function $(".mobile-menu").click(function () {

   $(this).toggleClass('open');
   $(".main-nav").toggleClass("side-open");

});

// Set up the page footer info

if ($("li#footer-info-credits").length > 0) {

$("li#footer-info-credits").html($("li#footer-info-credits").html().replace(/\[/g, "").replace(/\]/g, "").replace(/\{/g, "

").replace(/\}/g, "

"));
   $("p#contentFooter").insertBefore("li#footer-info-credits");
   $("li#footer-info-credits").remove();

}

// Set up the page title and breadcrumb

var title = $("h1#firstHeading").html().split('/'); $("h1#firstHeading").html(title[title.length - 1]); $("h1#firstHeading").appendTo("div#pageInfo");

$("span.subpages").appendTo("div#pageInfo"); $("span.subpages").html($("span.subpages").children()); $("" + title[title.length - 1] + "").appendTo("span.subpages"); $("  /  ").insertAfter("span.subpages > a");

// Set up the page title

document.title = title[title.length - 1] + " - GrinderScape Wiki";


// Remove href from selected tabs

$.each($("div.vectorTabs li.selected"), function () {

   $(this).find("a").removeAttr("href");

});

// Remove title from links

$("a").removeAttr("title");

// Set up the search box

$("div#p-search").insertBefore(".main-content-cstm"); $("div#p-search").wrap("<section class='main-top-cstm'></section>") $("input#searchInput").val("Search...").removeAttr("placeholder").attr("onfocus", "if (this.value == 'Search...') {this.value = ;}").attr("onblur", "if (this.value == ) {this.value = 'Search...';}");

// Set up the announcement

var homepage = 'https://wiki.grinderscape.org/Main_page'

if (location.href == homepage){

$("
Welcome to the GrinderScape Wiki!
").prependTo(".welcomeText"); $("
This reference guide can help with all your burning GrinderScape questions, from Alchemy to Zamorak. Have fun and get grinding.
").insertBefore("div#p-search");

} else {

$("
Having Troubles?
").prependTo(".pageText"); $("
Can't find what you're looking for? Use the search feature below for extra assistance!
").insertBefore("div#p-search");

}

// $("div#siteNotice").insertBefore("div#p-search");


// Set up the edit box

function wrapText(elementID, openTag, closeTag) {

   var textArea = $("#" + elementID);
   var len = textArea.val().length;
   var start = textArea[0].selectionStart;
   var end = textArea[0].selectionEnd;
   var selectedText = textArea.val().substring(start, end);
   var replacement = openTag + selectedText + closeTag;
   textArea.val(textArea.val().substring(0, start) + replacement + textArea.val().substring(end, len));

}

$("input#wpWatchthis").prop("checked", false);

$("
").appendTo("div#toolbar");

$("#CB-Nowiki").click(function () {

   wrapText("wpTextbox1", "", "");

});

$("
").prependTo("div#toolbar");

$("#CB-Heading2").click(function () {

wrapText("wpTextbox1", "

", "

");

});

$("
").prependTo("div#toolbar");

$("#CB-Heading1").click(function () {

wrapText("wpTextbox1", "

", "

");

});

$("
").prependTo("div#toolbar");

$("#CB-Italic").click(function () {

   wrapText("wpTextbox1", "", "");

});

$("
").prependTo("div#toolbar");

$("#CB-Bold").click(function () {

   wrapText("wpTextbox1", "", "");

});

// Remove auto correct from text boxes

$("textarea#wpTextbox1, input#searchInput, input#database_input").attr("spellcheck", "false");



// Table Highlight $('.highlight tr').mouseover(function () {

   $(this).addClass('highlight-hover'); //Add Hover Class to toggle css

}) $('.highlight tr').mouseout(function () {

   $(this).removeClass('highlight-hover'); //remove the class when not on hover of .highlight tr

})



// ***************************** Indices *****************************

$.each($("div.timestamp"), function () {

   var str = $(this).html();
   var year = str.substr(0, 4);
   var month = str.substr(4, 2);
   if (month == 01) {
       month = " January "
   } else if (month == 02) {
       month = " February "
   } else if (month == 03) {
       month = " March "
   } else if (month == 04) {
       month = " April "
   } else if (month == 05) {
       month = " May "
   } else if (month == 06) {
       month = " June "
   } else if (month == 07) {
       month = " July "
   } else if (month == 08) {
       month = " August "
   } else if (month == 09) {
       month = " September "
   } else if (month == 10) {
       month = " October "
   } else if (month == 11) {
       month = " November "
   } else if (month == 12) {
       month = " December "
   }
   var day = str.substr(6, 2);
   $(this).html("Last modified on " + day + month + year + ".");
   if (str == "") {
       $(this).html("This page is under construction.");
   }

}); $.each($("div.link > a"), function () {

   var link = $(this).html().split("/");
   $(this).html(link[link.length - 1].replace(/\_/g, " "));

});





// ***************************** Databases *****************************

function commaSeparateNumber(val) {

   while (/(\d+)(\d{3})/.test(val.toString())) {
       val = val.toString().replace(/(\d+)(\d{3})/, '$1' + '.' + '$2');
   };
   return val;

};

$("button#database_button").click(function () {

   searchDatabase();

});





// ***************************** Close *****************************






// Remove the loader

setTimeout(function () {

   $("div#mw-head-base").fadeOut(500);
   $("div#mw-page-base").fadeOut(500);

}, 600);