We do our best to give you all information you need. Use the Search menu to search for the page you are looking for. The most used pages are on the side menu or in the Popular Pages page.

Do you miss important stuff or do you have suggestions? Let us know via Discord or in-game. Thank you for using our Wiki!

Difference between revisions of "MediaWiki:Common.js"

From GrinderScape Wiki
Jump to: navigation, search
Line 1: Line 1:
 
// ***************************** Structure *****************************
 
// ***************************** Structure *****************************
+
 
 
// Remove unnecessary elements
 
// Remove unnecessary elements
  
$( "div#p-tb" ).remove();
+
$("div#p-tb").remove();
  
 
// Wrap the content
 
// Wrap the content
  
$( "div#content, div#mw-navigation" ).wrapAll( "<div id='wrap'></div>" );
+
$("div#content, div#mw-navigation").wrapAll("<div id='main-wrapper' class='container'></div>");
  
 
// Insert the header
 
// Insert the header
  
$( "<div style='padding:10px 0;text-align:center;background-color:#ECE6D8;color:#000;'>Wiki design is currently under construction. Wiki content is still available to browse.</div><header><div class='entire-header'><div class='header-top'><div class='container dFlx'><!--ul class='play-link'> <li><a itemprop='url' href='https://www.facebook.com/Grinderscape.org'><i class='fab fa-facebook-square'></i></a></li><li><a itemprop='url' href='https://www.youtube.com/user/dokenfilm/feed'><i class='fab fa-youtube'></i></a></li><li><a itemprop='url' href='https://discord.gg/b46xx5u'><i class='fab fa-discord'></i></a></li></ul--> <div class='logo'><a itemprop='url' href='https://www.grinderscape.org/home'><img src='https://www.grinderscape.org/images/grinderscape-logo.png' alt='GrinderScape'></a></div><div class='mobile-logo'><a itemprop='url' href='https://www.grinderscape.org/home'><img src='https://www.grinderscape.org/images/grinderscape-logo-mobile.png' alt='GrinderScape'></a></div></div></div><div class='header-bottm'><div class='container'><div class='mobile-menu'><span></span> <span></span> <span></span></div><ul class='main-nav'><li><a itemprop='url' href='https://www.grinderscape.org'>HOME</a></li><li><a itemprop='url' href='http://forum.grinderscape.org/'>FORUM</a></li><li><a itemprop='url' href='https://www.grinderscape.org/store'>STORE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/download'>DOWNLOAD</a></li><li><a href='javascript:void(0);' data-toggle='modal' data-target='#myModal-vote'>VOTE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/highscores'>HIGHSCORES</a></li><li class='acitve'><a itemprop='url' href='http://wiki.grinderscape.org/'>WIKI</a></li><li><a itemprop='url' href='https://www.grinderscape.org/contact'>CONTACT</a></li></ul></div></div></div></header>" ).insertBefore( "div#wrap" );
+
$("<div style='padding:10px 0;text-align:center;background-color:#ECE6D8;color:#000;'>Wiki design is currently under construction. Wiki content is still available to browse.</div><header><div class='entire-header'><div class='header-top'><div class='container dFlx'><!--ul class='play-link'> <li><a itemprop='url' href='https://www.facebook.com/Grinderscape.org'><i class='fab fa-facebook-square'></i></a></li><li><a itemprop='url' href='https://www.youtube.com/user/dokenfilm/feed'><i class='fab fa-youtube'></i></a></li><li><a itemprop='url' href='https://discord.gg/b46xx5u'><i class='fab fa-discord'></i></a></li></ul--> <div class='logo'><a itemprop='url' href='https://www.grinderscape.org/home'><img src='https://www.grinderscape.org/images/grinderscape-logo.png' alt='GrinderScape'></a></div></div></div><div class='header-bottm'><div class='container'><div class='mobile-menu'><span></span> <span></span> <span></span></div><ul class='main-nav'><li><a itemprop='url' href='https://www.grinderscape.org'>HOME</a></li><li><a itemprop='url' href='http://forum.grinderscape.org/'>FORUM</a></li><li><a itemprop='url' href='https://www.grinderscape.org/store'>STORE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/download'>DOWNLOAD</a></li><li><a href='javascript:void(0);' data-toggle='modal' data-target='#myModal-vote'>VOTE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/highscores'>HIGHSCORES</a></li><li class='acitve'><a itemprop='url' href='http://wiki.grinderscape.org/'>WIKI</a></li><li><a itemprop='url' href='https://www.grinderscape.org/contact'>CONTACT</a></li></ul></div></div></div></header>").insertBefore("div#main-wrapper");
  
 
// Insert the footer
 
// Insert the footer
  
$( "<div id='customFooter'><div style='margin-bottom: 30px; line-height: 0;'><a href='https://www.facebook.com/Grinderscape.org' style='background: url(https://i.imgur.com/DeOQfOs.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3a589e; border: 1px solid #17274D;'></a><a href='https://twitter.com/grinderscape' style='background: url(https://i.imgur.com/GZzo3yV.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3A89C4; border: 1px solid #0E3959;'></a><a href='https://www.youtube.com/user/dokenfilm' style='background: url(https://i.imgur.com/wF3Xf61.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #C8312B; border: 1px solid #78130F;'></a></div><p style='margin-bottom: 0;'>Theme developed by Jplayer.<br>GrinderScape is not affiliated with Jagex or RuneScape in any way.</p></div>" ).insertBefore( "ul#footer-places" );
+
$("<div id='customFooter'><div style='margin-bottom: 30px; line-height: 0;'><a href='https://www.facebook.com/Grinderscape.org' style='background: url(https://i.imgur.com/DeOQfOs.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3a589e; border: 1px solid #17274D;'></a><a href='https://twitter.com/grinderscape' style='background: url(https://i.imgur.com/GZzo3yV.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3A89C4; border: 1px solid #0E3959;'></a><a href='https://www.youtube.com/user/dokenfilm' style='background: url(https://i.imgur.com/wF3Xf61.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #C8312B; border: 1px solid #78130F;'></a></div><p style='margin-bottom: 0;'>Theme developed by Jplayer.<br>GrinderScape is not affiliated with Jagex or RuneScape in any way.</p></div>").insertBefore("ul#footer-places");
  
 
// Organize the elements
 
// Organize the elements
  
$( "div#mw-navigation" ).insertBefore( "div#content" );
+
$("div#mw-navigation").insertBefore("div#content");
$( "div#content" ).wrap( "<div id='content-sidebar-wrap'></div>" );
+
$("div#content").wrap("<div id='content-sidebar-wrap'></div>");
$( "div#mw-panel" ).insertAfter( "div#content" );
+
$("div#mw-panel").insertAfter("div#content");
$( "div#content" ).wrap( "<div id='content-wrap'></div>" );
+
$("div#content").wrap("<div id='content-wrap'></div>");
  
$( "<div id='navigation'></div>" ).prependTo( "div#content" );
+
$("<div id='navigation'></div>").prependTo("div#content");
$( "div#left-navigation" ).appendTo( "div#navigation" );
+
$("div#left-navigation").appendTo("div#navigation");
$( "div#right-navigation" ).appendTo( "div#navigation" );
+
$("div#right-navigation").appendTo("div#navigation");
  
$( "<div id='pageInfo'></div>" ).insertBefore( "div#content" );
+
$("<div id='pageInfo'></div>").insertBefore("div#content");
  
$( "div#content" ).wrap( "<div id='content-navigation-wrap'></div>" );
+
$("div#content").wrap("<div id='content-navigation-wrap'></div>");
$( "div#siteNotice" ).insertAfter( "div#mw-navigation" );
+
$("div#siteNotice").insertAfter("div#mw-navigation");
$( "ul#footer-info" ).insertAfter( "div#content" );
+
$("ul#footer-info").insertAfter("div#content");
  
 
// Set up the page footer info
 
// Set up the page footer info
  
if ( $( "li#footer-info-credits" ).length > 0 ) {
+
if ($("li#footer-info-credits").length > 0) {
$( "li#footer-info-credits" ).html( $( "li#footer-info-credits" ).html().replace( /\[/g, "<span style='position: absolute; right: 0;'>" ).replace( /\]/g, "</span>" ).replace( /\{/g, "<p id='contentFooter' style='position: relative;'>" ).replace( /\}/g, "</p>" ) );
+
    $("li#footer-info-credits").html($("li#footer-info-credits").html().replace(/\[/g, "<span style='position: absolute; right: 0;'>").replace(/\]/g, "</span>").replace(/\{/g, "<p id='contentFooter' style='position: relative;'>").replace(/\}/g, "</p>"));
$( "p#contentFooter" ).insertBefore( "li#footer-info-credits" );
+
    $("p#contentFooter").insertBefore("li#footer-info-credits");
$( "li#footer-info-credits" ).remove();
+
    $("li#footer-info-credits").remove();
 
}
 
}
  
 
// Set up the page title and breadcrumb
 
// Set up the page title and breadcrumb
  
var title = $( "h1#firstHeading" ).html().split('/');
+
var title = $("h1#firstHeading").html().split('/');
$( "h1#firstHeading" ).html( title[ title.length - 1 ] );
+
$("h1#firstHeading").html(title[title.length - 1]);
$( "h1#firstHeading" ).appendTo( "div#pageInfo" );
+
$("h1#firstHeading").appendTo("div#pageInfo");
  
$( "span.subpages" ).appendTo( "div#pageInfo" );
+
$("span.subpages").appendTo("div#pageInfo");
$( "span.subpages" ).html( $( "span.subpages" ).children() );
+
$("span.subpages").html($("span.subpages").children());
$( "<span>" + title[ title.length - 1 ] + "</span>" ).appendTo( "span.subpages" );
+
$("<span>" + title[title.length - 1] + "</span>").appendTo("span.subpages");
$( "<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>" ).insertAfter( "span.subpages > a" );
+
$("<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>").insertAfter("span.subpages > a");
  
 
// Set up the page title
 
// Set up the page title
  
document.title = title[ title.length - 1 ] + " - GrinderScape Wiki";
+
document.title = title[title.length - 1] + " - GrinderScape Wiki";
  
 
// Set up the announcement
 
// Set up the announcement
  
$( "<div id='noticeTitle'>Notice</div>" ).prependTo( "div#siteNotice" );
+
$("<div id='noticeTitle'>Notice</div>").prependTo("div#siteNotice");
  
 
// Remove href from selected tabs
 
// Remove href from selected tabs
  
$.each( $( "div.vectorTabs li.selected" ), function() {
+
$.each($("div.vectorTabs li.selected"), function () {
$( this ).find( "a" ).removeAttr( "href" );
+
    $(this).find("a").removeAttr("href");
 
});
 
});
  
 
// Remove title from links
 
// Remove title from links
  
$( "a" ).removeAttr( "title" );
+
$("a").removeAttr("title");
  
 
// Set up the search box
 
// Set up the search box
  
$( "div#p-search" ).prependTo( "div#mw-panel" );
+
$("div#p-search").prependTo("div#mw-panel");
$( "<div id='searchTitle'>Search</div>" ).insertBefore( "form#searchform" );
+
$("<div id='searchTitle'>Search</div>").insertBefore("form#searchform");
$( "input#searchInput" ).val( "Search..." ).removeAttr( "placeholder" ).attr( "onfocus", "if (this.value == 'Search...') {this.value = '';}" ).attr( "onblur", "if (this.value == '') {this.value = 'Search...';}" );
+
$("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 edit box
 
// Set up the edit box
  
function wrapText( elementID, openTag, closeTag ) {
+
function wrapText(elementID, openTag, closeTag) {
var textArea = $( "#" + elementID );
+
    var textArea = $("#" + elementID);
var len = textArea.val().length;
+
    var len = textArea.val().length;
var start = textArea[0].selectionStart;
+
    var start = textArea[0].selectionStart;
var end = textArea[0].selectionEnd;
+
    var end = textArea[0].selectionEnd;
var selectedText = textArea.val().substring( start, end );
+
    var selectedText = textArea.val().substring(start, end);
var replacement = openTag + selectedText + closeTag;
+
    var replacement = openTag + selectedText + closeTag;
textArea.val( textArea.val().substring( 0, start ) + replacement + textArea.val().substring( end, len ) );
+
    textArea.val(textArea.val().substring(0, start) + replacement + textArea.val().substring(end, len));
 
}
 
}
  
$( "input#wpWatchthis" ).prop( "checked", false );
+
$("input#wpWatchthis").prop("checked", false);
  
$( "<div class='customButton' id='CB-Nowiki' style='background: url(https://i.imgur.com/Fx2AsCt.png);' title='Ignore wiki formatting'></div>" ).appendTo( "div#toolbar" );
+
$("<div class='customButton' id='CB-Nowiki' style='background: url(https://i.imgur.com/Fx2AsCt.png);' title='Ignore wiki formatting'></div>").appendTo("div#toolbar");
$( "#CB-Nowiki" ).click( function() {
+
$("#CB-Nowiki").click(function () {
wrapText( "wpTextbox1", "<nowiki>", "</nowiki>" );
+
    wrapText("wpTextbox1", "<nowiki>", "</nowiki>");
 
});
 
});
  
$( "<div class='customButton' id='CB-Heading2' style='background: url(https://i.imgur.com/8uajyYO.png);' title='Level 2 heading'></div>" ).prependTo( "div#toolbar" );
+
$("<div class='customButton' id='CB-Heading2' style='background: url(https://i.imgur.com/8uajyYO.png);' title='Level 2 heading'></div>").prependTo("div#toolbar");
$( "#CB-Heading2" ).click( function() {
+
$("#CB-Heading2").click(function () {
wrapText( "wpTextbox1", "<h2>", "</h2>" );
+
    wrapText("wpTextbox1", "<h2>", "</h2>");
 
});
 
});
  
$( "<div class='customButton' id='CB-Heading1' style='background: url(https://i.imgur.com/jKOOZnF.png);' title='Level 1 heading'></div>" ).prependTo( "div#toolbar" );
+
$("<div class='customButton' id='CB-Heading1' style='background: url(https://i.imgur.com/jKOOZnF.png);' title='Level 1 heading'></div>").prependTo("div#toolbar");
$( "#CB-Heading1" ).click( function() {
+
$("#CB-Heading1").click(function () {
wrapText( "wpTextbox1", "<h1>", "</h1>" );
+
    wrapText("wpTextbox1", "<h1>", "</h1>");
 
});
 
});
  
$( "<div class='customButton' id='CB-Italic' style='background: url(https://i.imgur.com/zdPfv0X.png);' title='Italic text'></div>" ).prependTo( "div#toolbar" );
+
$("<div class='customButton' id='CB-Italic' style='background: url(https://i.imgur.com/zdPfv0X.png);' title='Italic text'></div>").prependTo("div#toolbar");
$( "#CB-Italic" ).click( function() {
+
$("#CB-Italic").click(function () {
wrapText( "wpTextbox1", "<i>", "</i>" );
+
    wrapText("wpTextbox1", "<i>", "</i>");
 
});
 
});
  
$( "<div class='customButton' id='CB-Bold' style='background: url(https://i.imgur.com/lyqhAM9.png);' title='Bold text'></div>" ).prependTo( "div#toolbar" );
+
$("<div class='customButton' id='CB-Bold' style='background: url(https://i.imgur.com/lyqhAM9.png);' title='Bold text'></div>").prependTo("div#toolbar");
$( "#CB-Bold" ).click( function() {
+
$("#CB-Bold").click(function () {
wrapText( "wpTextbox1", "<b>", "</b>" );
+
    wrapText("wpTextbox1", "<b>", "</b>");
 
});
 
});
  
 
// Remove auto correct from text boxes
 
// Remove auto correct from text boxes
  
$( "textarea#wpTextbox1, input#searchInput, input#database_input" ).attr( "spellcheck", "false" );
+
$("textarea#wpTextbox1, input#searchInput, input#database_input").attr("spellcheck", "false");
  
  
Line 124: Line 124:
  
 
// Table Highlight
 
// Table Highlight
$('.highlight tr').mouseover(function(){
+
$('.highlight tr').mouseover(function () {
 
     $(this).addClass('highlight-hover'); //Add Hover Class to toggle css
 
     $(this).addClass('highlight-hover'); //Add Hover Class to toggle css
 
})
 
})
$('.highlight tr').mouseout(function(){
+
$('.highlight tr').mouseout(function () {
 
     $(this).removeClass('highlight-hover'); //remove the class when not on hover of .highlight tr
 
     $(this).removeClass('highlight-hover'); //remove the class when not on hover of .highlight tr
 
})
 
})
Line 136: Line 136:
 
// ***************************** Indices *****************************
 
// ***************************** Indices *****************************
  
$.each( $( "div.timestamp" ), function() {
+
$.each($("div.timestamp"), function () {
var str = $( this ).html();
+
    var str = $(this).html();
var year = str.substr( 0, 4 );
+
    var year = str.substr(0, 4);
var month = str.substr( 4, 2 );
+
    var month = str.substr(4, 2);
if ( month == 01 ) { month = " January " }
+
    if (month == 01) {
else if ( month == 02 ) { month = " February " }
+
        month = " January "
else if ( month == 03 ) { month = " March " }
+
    } else if (month == 02) {
else if ( month == 04 ) { month = " April " }
+
        month = " February "
else if ( month == 05 ) { month = " May " }
+
    } else if (month == 03) {
else if ( month == 06 ) { month = " June " }
+
        month = " March "
else if ( month == 07 ) { month = " July " }
+
    } else if (month == 04) {
else if ( month == 08 ) { month = " August " }
+
        month = " April "
else if ( month == 09 ) { month = " September " }
+
    } else if (month == 05) {
else if ( month == 10 ) { month = " October " }
+
        month = " May "
else if ( month == 11 ) { month = " November " }
+
    } else if (month == 06) {
else if ( month == 12 ) { month = " December " }
+
        month = " June "
var day = str.substr( 6, 2 );
+
    } else if (month == 07) {
$( this ).html( "Last modified on " + day + month + year + "." );
+
        month = " July "
if ( str == "" ) {
+
    } else if (month == 08) {
$( this ).html( "This page is under construction." );
+
        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() {
+
$.each($("div.link > a"), function () {
var link = $( this ).html().split( "/" );
+
    var link = $(this).html().split("/");
$( this ).html( link[ link.length - 1 ].replace( /\_/g, " " ) );
+
    $(this).html(link[link.length - 1].replace(/\_/g, " "));
 
});
 
});
  
Line 173: Line 186:
 
// ***************************** Databases *****************************
 
// ***************************** Databases *****************************
  
function commaSeparateNumber( val ){
+
function commaSeparateNumber(val) {
while ( /(\d+)(\d{3})/.test( val.toString() ) ) {
+
    while (/(\d+)(\d{3})/.test(val.toString())) {
val = val.toString().replace( /(\d+)(\d{3})/, '$1' + '.' + '$2' );
+
        val = val.toString().replace(/(\d+)(\d{3})/, '$1' + '.' + '$2');
};
+
    };
return val;
+
    return val;
 
};
 
};
  
$( "button#database_button" ).click( function() {
+
$("button#database_button").click(function () {
searchDatabase();
+
    searchDatabase();
 
});
 
});
  
Line 204: Line 217:
 
// Remove the loader
 
// Remove the loader
  
setTimeout( function() {
+
setTimeout(function () {
$( "div#mw-head-base" ).fadeOut( 500 );
+
    $("div#mw-head-base").fadeOut(500);
$( "div#mw-page-base" ).fadeOut( 500 );
+
    $("div#mw-page-base").fadeOut(500);
}, 600 );
+
}, 600);

Revision as of 07:11, 14 November 2020

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

// Remove unnecessary elements

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

// Wrap the content

$("div#content, div#mw-navigation").wrapAll("<div id='main-wrapper' class='container'></div>");

// Insert the header

$("<div style='padding:10px 0;text-align:center;background-color:#ECE6D8;color:#000;'>Wiki design is currently under construction. Wiki content is still available to browse.</div><header><div class='entire-header'><div class='header-top'><div class='container dFlx'><!--ul class='play-link'> <li><a itemprop='url' href='https://www.facebook.com/Grinderscape.org'><i class='fab fa-facebook-square'></i></a></li><li><a itemprop='url' href='https://www.youtube.com/user/dokenfilm/feed'><i class='fab fa-youtube'></i></a></li><li><a itemprop='url' href='https://discord.gg/b46xx5u'><i class='fab fa-discord'></i></a></li></ul--> <div class='logo'><a itemprop='url' href='https://www.grinderscape.org/home'><img src='https://www.grinderscape.org/images/grinderscape-logo.png' alt='GrinderScape'></a></div></div></div><div class='header-bottm'><div class='container'><div class='mobile-menu'><span></span> <span></span> <span></span></div><ul class='main-nav'><li><a itemprop='url' href='https://www.grinderscape.org'>HOME</a></li><li><a itemprop='url' href='http://forum.grinderscape.org/'>FORUM</a></li><li><a itemprop='url' href='https://www.grinderscape.org/store'>STORE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/download'>DOWNLOAD</a></li><li><a href='javascript:void(0);' data-toggle='modal' data-target='#myModal-vote'>VOTE</a></li><li><a itemprop='url' href='https://www.grinderscape.org/highscores'>HIGHSCORES</a></li><li class='acitve'><a itemprop='url' href='http://wiki.grinderscape.org/'>WIKI</a></li><li><a itemprop='url' href='https://www.grinderscape.org/contact'>CONTACT</a></li></ul></div></div></div></header>").insertBefore("div#main-wrapper");

// Insert the footer

$("<div id='customFooter'><div style='margin-bottom: 30px; line-height: 0;'><a href='https://www.facebook.com/Grinderscape.org' style='background: url(https://i.imgur.com/DeOQfOs.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3a589e; border: 1px solid #17274D;'></a><a href='https://twitter.com/grinderscape' style='background: url(https://i.imgur.com/GZzo3yV.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3A89C4; border: 1px solid #0E3959;'></a><a href='https://www.youtube.com/user/dokenfilm' style='background: url(https://i.imgur.com/wF3Xf61.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #C8312B; border: 1px solid #78130F;'></a></div><p style='margin-bottom: 0;'>Theme developed by Jplayer.<br>GrinderScape is not affiliated with Jagex or RuneScape in any way.</p></div>").insertBefore("ul#footer-places");

// Organize the elements

$("div#mw-navigation").insertBefore("div#content");
$("div#content").wrap("<div id='content-sidebar-wrap'></div>");
$("div#mw-panel").insertAfter("div#content");
$("div#content").wrap("<div id='content-wrap'></div>");

$("<div id='navigation'></div>").prependTo("div#content");
$("div#left-navigation").appendTo("div#navigation");
$("div#right-navigation").appendTo("div#navigation");

$("<div id='pageInfo'></div>").insertBefore("div#content");

$("div#content").wrap("<div id='content-navigation-wrap'></div>");
$("div#siteNotice").insertAfter("div#mw-navigation");
$("ul#footer-info").insertAfter("div#content");

// 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, "<span style='position: absolute; right: 0;'>").replace(/\]/g, "</span>").replace(/\{/g, "<p id='contentFooter' style='position: relative;'>").replace(/\}/g, "</p>"));
    $("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());
$("<span>" + title[title.length - 1] + "</span>").appendTo("span.subpages");
$("<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>").insertAfter("span.subpages > a");

// Set up the page title

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

// Set up the announcement

$("<div id='noticeTitle'>Notice</div>").prependTo("div#siteNotice");

// 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").prependTo("div#mw-panel");
$("<div id='searchTitle'>Search</div>").insertBefore("form#searchform");
$("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 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);

$("<div class='customButton' id='CB-Nowiki' style='background: url(https://i.imgur.com/Fx2AsCt.png);' title='Ignore wiki formatting'></div>").appendTo("div#toolbar");
$("#CB-Nowiki").click(function () {
    wrapText("wpTextbox1", "<nowiki>", "</nowiki>");
});

$("<div class='customButton' id='CB-Heading2' style='background: url(https://i.imgur.com/8uajyYO.png);' title='Level 2 heading'></div>").prependTo("div#toolbar");
$("#CB-Heading2").click(function () {
    wrapText("wpTextbox1", "<h2>", "</h2>");
});

$("<div class='customButton' id='CB-Heading1' style='background: url(https://i.imgur.com/jKOOZnF.png);' title='Level 1 heading'></div>").prependTo("div#toolbar");
$("#CB-Heading1").click(function () {
    wrapText("wpTextbox1", "<h1>", "</h1>");
});

$("<div class='customButton' id='CB-Italic' style='background: url(https://i.imgur.com/zdPfv0X.png);' title='Italic text'></div>").prependTo("div#toolbar");
$("#CB-Italic").click(function () {
    wrapText("wpTextbox1", "<i>", "</i>");
});

$("<div class='customButton' id='CB-Bold' style='background: url(https://i.imgur.com/lyqhAM9.png);' title='Bold text'></div>").prependTo("div#toolbar");
$("#CB-Bold").click(function () {
    wrapText("wpTextbox1", "<b>", "</b>");
});

// 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);