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
 
(209 intermediate revisions by 6 users not shown)
Line 1: Line 1:
/********** Any JavaScript here will be loaded for all users on every page load **********/
+
// ***************************** Structure *****************************
  
// Allow Jquery
+
/* Load fontawesome and bootstrap css dependencies */
 +
mw.loader.load('https://use.fontawesome.com/releases/v5.8.1/css/all.css', 'text/css');
 +
mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', 'text/css');
  
jquery = document.createElement( "script" );
 
jquery.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
 
  
document.getElementsByTagName( "head" )[0].appendChild( jquery );
+
// Remove unnecessary elements
  
 +
$("div#p-tb").remove();
 +
$("img").removeAttr("height");
  
 +
// Wrap the content
  
 +
$("div#content, div#mw-navigation").wrapAll("<div id='main-wrapper'><div class='container'></div></div>");
  
 +
// Insert the header
  
 +
$("<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><ul class='login'> <li id='n-Log-in'><a href='/Special:UserLogin' data-toggle='modal' data-target='#myModal-user'>Wiki Login</a></li></ul> </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");
  
  
 +
// 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 id='content-sidebar-wrap'></div>");
 +
$("div#mw-panel").insertAfter("div#content");
 +
$("div#content").wrap("<div id='content-wrap'></div>");
  
/********** Structure **********/
+
$("<div id='navigation'></div>").prependTo("div#content");
 +
$("div#left-navigation").appendTo("div#navigation");
 +
$("div#right-navigation").appendTo("div#navigation");
  
// Remove unnecessary elements
+
$("<div id='pageInfo'></div>").insertBefore("div#content");
 +
$("div#content").wrap("<div id='content-navigation-wrap'></div>");
 +
$("ul#footer-info").insertAfter("div#content");
  
$( "div#p-tb" ).remove();
+
// Insert the footer
if ( $( "li#pt-userpage" ).length ) {} else {
+
$( "div#p-Wiki" ).remove();
+
}
+
  
// Wrap the content
+
$("<footer> <div class='footer-top dFlx'> <div class='cw-30'> <h5>ABOUT</h5> <p>GrinderScape has been a dedicated server since 2008, with helpful staff and dedicated members. If you need help in how to start, you can see the Wiki. If you wish to get involved with the community as a whole, join our Forums, for the latest threads and game suggestions.</p></div><div class='cw-70 dFlx'> <div class='cw-33'> <h5>GENERAL</h5> <ul> <li><a itemprop='url' href='https://www.grinderscape.org/download'>Play Now</a></li><li><a itemprop='url' href='https://www.grinderscape.org/contact' target='_blank'>Contact Us</a></li><li><a itemprop='url' href='https://www.grinderscape.org/tos' target='_blank'>Terms of Services</a></li><li><a itemprop='url' href='https://www.grinderscape.org/user/manage' target='_blank'>Account Management</a></li><li><a itemprop='url' href='https://www.grinderscape.org/faq' target='_blank'>Frequently Asked Questions</a></li></ul> </div><div class='cw-33'> <h5>GUIDES</h5> <ul> <li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/topic/132-in-game-drops-guide-mystery-boxes/' target='_blank'>NPC Drops Guide</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Skill_guides/Slayer' target='_blank'>Slayer Guide</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/topic/132-in-game-drops-guide-mystery-boxes/' target='_blank'>Drops Guide</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Monster_hunting_guides' target='_blank'>Monster Hunting Guides</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/General_guides/Commands' target='_blank'>In-Game Commands </a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Skill_guides' target='_blank'>Skilling Guides</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/General_guides' target='_blank'>General Guides</a></li></ul> </div><div class='cw-33'> <h5>FORUM THREADS</h5> <ul> <li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/2-news-announcements/' target='_blank'>News &amp; Announcements</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/39-report-in-game-bugs/' target='_blank'>Report In-Game Bugs</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/11-submit-appeal/' target='_blank'>Submit In-Game Appeal</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/59-recover-a-lost-account/' target='_blank'>Recover a Lost Account</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/10-submit-player-report/' target='_blank'>Submit Player Report</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/5-rules/' target='_blank'>In-Game Rules</a></li></ul> </div></div></div><div class='footer-btm dFlx'> <div class='footer-logo'> <a itemprop='url' href='https://www.grinderscape.org'><img src='https://www.grinderscape.org/images/footer-logo-trans.png' alt='GrinderScape'></a> </div><p>GrinderScape is not affiliated with Jagex or Runescape in any way.</p></div></footer>").insertAfter(".main-content-cstm");
  
$( "div#content, div#mw-navigation" ).wrapAll( "<div id='wrap'></div>" );
+
// Mobile Navigation Click Function
 +
$(".mobile-menu").click(function () {
 +
    $(this).toggleClass('open');
 +
    $(".main-nav").toggleClass("side-open");
 +
});
  
// Insert the header
+
// Set up the page footer info
  
$( "<header><div id='logo'><a href='https://www.grinderscape.org/'><img src='https://www.grinderscape.org/assets/images/logo.png' draggable='false'></a></div><nav><ul><li id='n-Home'><a href='https://www.grinderscape.org/'>Home</a></li><li id='n-Forums'><a href='http://forum.grinderscape.org/'>Forums</a></li><li id='n-Wiki'><a href='https://newwiki.grinderscape.org/Main_Page'>Wiki</a></li><li id='n-Vote'><a href='https://www.grinderscape.org/vote/status'>Vote</a></li><li id='n-Donate'><a href='https://www.grinderscape.org/donate'>Donate</a></li><li id='n-Marketplace'><a href='https://www.grinderscape.org/marketplace/all'>Marketplace</a></li><li id='n-Highscores'><a href='https://www.grinderscape.org/highscores/mode/regular'>Highscores</a></li><li id='n-Webclient'><a href='http://www.grinderscape.org/play'>Webclient</a></li><li id='n-Download'><a href='https://www.grinderscape.org/play/download'>Download</a></li></ul></nav></header>" ).insertBefore( "div#wrap" );
+
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();
 +
}
  
// Insert the footer
+
// Set up the page title and breadcrumb
  
$( "<div id='customFooter'><div style='margin-bottom: 20px;'><a href='https://www.facebook.com/Grinderscape.org' style='margin: 0 5px;'><img src='https://i.imgur.com/JBTwARa.png'></a><a href='https://twitter.com/grinderscape' style='margin: 0 5px;'><img src='https://i.imgur.com/nK46yjP.png'></a><a href='https://www.youtube.com/channel/UCVGi_iQHwRSGY36ff40SkYA' style='margin: 0 5px;'><img src='https://i.imgur.com/bXMaprT.png'></a></div><p>Theme developed by <a href='http://forum.grinderscape.org/members/56905'>Jplayer</a>.</p><p>GrinderScape is not affiliated with Jagex or RuneScape in any way.</p></div>" ).insertBefore( "ul#footer-places" );
+
var title = $("h1#firstHeading").html().split('/');
// Organize the elements
+
$("h1#firstHeading").html(title[title.length - 1]);
 +
$("h1#firstHeading").appendTo("div#pageInfo");
  
$( "div#mw-navigation" ).insertBefore( "div#content" );
+
$("span.subpages").appendTo("div#pageInfo");
$( "div#content" ).wrap( "<div id='content-sidebar-wrap'></div>" );
+
$("span.subpages").html($("span.subpages").children());
$( "div#mw-panel" ).insertBefore( "div#content" );
+
$("<span>" + title[title.length - 1] + "</span>").appendTo("span.subpages");
$( "div#content" ).wrap( "<div id='content-wrap'></div>" );
+
$("<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>").insertAfter("span.subpages > a");
  
$( "<div id='navigation'></div>" ).insertBefore( "div#content" );
+
// Set up the page title
$( "div#right-navigation" ).appendTo( "div#navigation" );
+
$( "div#left-navigation" ).appendTo( "div#navigation" );
+
  
$( "div#contentSub" ).insertBefore( "div#navigation" );
+
document.title = title[title.length - 1] + " - GrinderScape Wiki";
  
$( "div#navigation, div#content" ).wrapAll( "<div id='content-navigation-wrap'></div>" );
+
// Hide mw-panel on HP
$( "div#siteNotice" ).insertAfter( "div#mw-navigation" );
+
if (window.location.href == 'https://wiki.grinderscape.org/Main_page/New' || window.location.href == 'https://wiki.grinderscape.org/Main_page') {
$( "ul#footer-info" ).insertAfter( "div#content" );
+
    $('#mw-panel').remove();
 +
}
  
//$( "div#p-search" ).prependTo( "div#mw-panel" );
+
// Remove href from selected tabs
//$( "<div id='searchTitle'>Search</div>" ).insertBefore( "form#searchform" );
+
  
// Set up the page footer info
+
$.each($("div.vectorTabs li.selected"), function () {
 +
    $(this).find("a").removeAttr("href");
 +
});
  
if ( $( "li#footer-info-credits" ).length > 0 ) {
+
// Remove title from links
$( "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 breadcrumb
+
$("a").removeAttr("title");
  
if ( $( "span.subpages" ).length > 0 ) {
+
// Set up the search box
$( "span.subpages" ).html( $( "span.subpages" ).children() );
+
 
var title = $( "h1#firstHeading" ).html().split('/');
+
$("div#p-search").insertBefore(".main-content-cstm");
$( "<span>" + title[ title.length - 1 ] + "</span>" ).appendTo( "span.subpages" );
+
$("div#p-search").wrap("<section class='main-top-cstm'></section>")
$( "<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>" ).insertAfter( "span.subpages > a" );
+
$("input#searchInput").val("Search...").removeAttr("placeholder").attr("onfocus", "if (this.value == 'Search...') {this.value = '';}").attr("onblur", "if (this.value == '') {this.value = 'Search...';}");
} else {
+
$( "div#contentSub" ).prepend( "<span class='subpages'></span>" );
+
var title = $( "h1#firstHeading" ).html().split('/');
+
$( "<span>" + title[ title.length - 1 ] + "</span>" ).appendTo( "span.subpages" );
+
}
+
  
 
// Set up the announcement
 
// Set up the announcement
  
$( "<div id='announcement'></div>" ).prependTo( "div#localNotice" );
+
$("div#siteNotice").insertBefore("div#p-search");
$( "div#localNotice > p" ).first().addClass( "current" );
+
$("<div id='noticeTitle'>Welcome to the GrinderScape Wiki!</div>").prependTo("div#siteNotice");
$( "div#announcement" ).html( $( "div#localNotice > p.current" ).html() );
+
setInterval( function() {
+
  
if ( $( "div#localNotice > p.current" ).is( ":last-child" ) ) {
+
 
$( "div#localNotice > p.current" ).removeClass( "current" );
+
// Show/Hide Plugin
$( "div#localNotice > p" ).first().addClass( "current" );
+
$('.p_hide').hide(); // Hides any element with p_hide class
} else {
+
$('.p_toggle').on('click', function(){
$( "div#localNotice > p.current" ).removeClass( "current" ).next().addClass( "current" );
+
    var $this = $(this);
 +
    var toggleChild = $this.find('.p_toggle_content');
 +
    var toggleIcon = $this.find('.p_toggle_icon')
 +
 
 +
    console.log(toggleIcon);
 +
 
 +
    toggleChild.slideToggle("fast");
 +
    toggleIcon.toggleClass("fa-plus fa-minus");
 +
 
 +
    // if (toggleIcon == '.fa-plus'){
 +
    //    toggleIcon.toggleClass("fa-plus", "fa-minus");
 +
    // } else {
 +
    //    toggleIcon.toggleClass("fa-minus", "fa-plus");
 +
    // }
 +
});
 +
 
 +
 
 +
// 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));
 
}
 
}
$( "div#announcement" ).fadeTo( 500, 0, function() {
+
 
$( "div#announcement" ).html( $( "div#localNotice > p.current" ).html() ).fadeTo( 500, 1 );
+
$("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>");
 
});
 
});
  
}, 4000);
+
$("<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>");
 +
});
  
// Remove href from selected tabs
+
$("<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>");
 +
});
  
$.each( $( "div.vectorTabs li.selected" ), function() {
+
$("<div class='customButton' id='CB-Italic' style='background: url(https://i.imgur.com/zdPfv0X.png);' title='Italic text'></div>").prependTo("div#toolbar");
$( this ).find( "a" ).removeAttr( "href" );
+
$("#CB-Italic").click(function () {
 +
    wrapText("wpTextbox1", "<i>", "</i>");
 
});
 
});
  
// Remove title from links
+
$("<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>");
 +
});
  
$( "a" ).removeAttr( "title" );
+
// Remove auto correct from text boxes
  
//
+
$("textarea#wpTextbox1, input#searchInput, input#database_input").attr("spellcheck", "false");
  
$( "div#p-search" ).prependTo( "div#mw-panel" );
 
$( "<div id='searchTitle'>Search</div>" ).insertBefore( "form#searchform" );
 
  
  
  
 +
// 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, " "));
 +
});
  
  
/********** Specific Pages **********/
 
  
  
// Set up the index
 
  
$( "div#index" ).insertAfter( "div#content-navigation-wrap" );
 
  
$.each( $( "div#index a" ), function() {
 
  
var split = $( this ).html().split('/');
 
$( this ).html( split[ split.length - 1 ] );
 
  
});
 
  
$.each( $( "div.index-item" ), function() {
+
// ***************************** Databases *****************************
  
$( this ).wrap( "<a></a>" );
+
function commaSeparateNumber(val) {
var href = $( this ).find( "a" ).attr( "href" );
+
    while (/(\d+)(\d{3})/.test(val.toString())) {
var title = $( this ).find( "a" ).attr( "title" );
+
        val = val.toString().replace(/(\d+)(\d{3})/, '$1' + '.' + '$2');
$( this ).parent().attr( "href", href ).attr( "title", title );
+
    };
 +
    return val;
 +
};
  
 +
$("button#database_button").click(function () {
 +
    searchDatabase();
 
});
 
});
  
$.each( $( "div#index img" ), function() {
 
  
$( this ).attr( "draggable", "false" );
 
  
});
+
 
 +
 
 +
 
 +
 
 +
 
 +
// ***************************** Close *****************************
 +
 
  
  
Line 160: Line 266:
 
// Remove the loader
 
// Remove the loader
  
setTimeout( function() {
+
setTimeout(function () {
$( "div#mw-head-base" ).fadeOut( 300 );
+
    $("div#mw-head-base").fadeOut(500);
$( "div#mw-page-base" ).fadeOut( 500 );
+
    $("div#mw-page-base").fadeOut(500);
});
+
}, 600);

Latest revision as of 21:01, 17 September 2021

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

/* Load fontawesome and bootstrap css dependencies */
mw.loader.load('https://use.fontawesome.com/releases/v5.8.1/css/all.css', 'text/css');
mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', 'text/css');


// Remove unnecessary elements

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

// Wrap the content

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

// Insert the header

$("<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><ul class='login'> <li id='n-Log-in'><a href='/Special:UserLogin' data-toggle='modal' data-target='#myModal-user'>Wiki Login</a></li></ul> </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");


// 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 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>");
$("ul#footer-info").insertAfter("div#content");

// Insert the footer

$("<footer> <div class='footer-top dFlx'> <div class='cw-30'> <h5>ABOUT</h5> <p>GrinderScape has been a dedicated server since 2008, with helpful staff and dedicated members. If you need help in how to start, you can see the Wiki. If you wish to get involved with the community as a whole, join our Forums, for the latest threads and game suggestions.</p></div><div class='cw-70 dFlx'> <div class='cw-33'> <h5>GENERAL</h5> <ul> <li><a itemprop='url' href='https://www.grinderscape.org/download'>Play Now</a></li><li><a itemprop='url' href='https://www.grinderscape.org/contact' target='_blank'>Contact Us</a></li><li><a itemprop='url' href='https://www.grinderscape.org/tos' target='_blank'>Terms of Services</a></li><li><a itemprop='url' href='https://www.grinderscape.org/user/manage' target='_blank'>Account Management</a></li><li><a itemprop='url' href='https://www.grinderscape.org/faq' target='_blank'>Frequently Asked Questions</a></li></ul> </div><div class='cw-33'> <h5>GUIDES</h5> <ul> <li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/topic/132-in-game-drops-guide-mystery-boxes/' target='_blank'>NPC Drops Guide</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Skill_guides/Slayer' target='_blank'>Slayer Guide</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/topic/132-in-game-drops-guide-mystery-boxes/' target='_blank'>Drops Guide</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Monster_hunting_guides' target='_blank'>Monster Hunting Guides</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/General_guides/Commands' target='_blank'>In-Game Commands </a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/Skill_guides' target='_blank'>Skilling Guides</a></li><li><a itemprop='url' href='https://wiki.grinderscape.org/Main_page/Guides/General_guides' target='_blank'>General Guides</a></li></ul> </div><div class='cw-33'> <h5>FORUM THREADS</h5> <ul> <li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/2-news-announcements/' target='_blank'>News &amp; Announcements</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/39-report-in-game-bugs/' target='_blank'>Report In-Game Bugs</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/11-submit-appeal/' target='_blank'>Submit In-Game Appeal</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/59-recover-a-lost-account/' target='_blank'>Recover a Lost Account</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/10-submit-player-report/' target='_blank'>Submit Player Report</a></li><li><a itemprop='url' href='https://forum.grinderscape.org/index.php?/forum/5-rules/' target='_blank'>In-Game Rules</a></li></ul> </div></div></div><div class='footer-btm dFlx'> <div class='footer-logo'> <a itemprop='url' href='https://www.grinderscape.org'><img src='https://www.grinderscape.org/images/footer-logo-trans.png' alt='GrinderScape'></a> </div><p>GrinderScape is not affiliated with Jagex or Runescape in any way.</p></div></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, "<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";

// Hide mw-panel on HP
if (window.location.href == 'https://wiki.grinderscape.org/Main_page/New' || window.location.href == 'https://wiki.grinderscape.org/Main_page') {
    $('#mw-panel').remove();
}

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

$("div#siteNotice").insertBefore("div#p-search");
$("<div id='noticeTitle'>Welcome to the GrinderScape Wiki!</div>").prependTo("div#siteNotice");


// Show/Hide Plugin
$('.p_hide').hide(); // Hides any element with p_hide class
$('.p_toggle').on('click', function(){
    var $this = $(this);
    var toggleChild = $this.find('.p_toggle_content');
    var toggleIcon = $this.find('.p_toggle_icon')

    console.log(toggleIcon);

    toggleChild.slideToggle("fast");
    toggleIcon.toggleClass("fa-plus fa-minus");

    // if (toggleIcon == '.fa-plus'){
    //     toggleIcon.toggleClass("fa-plus", "fa-minus");
    // } else {
    //     toggleIcon.toggleClass("fa-minus", "fa-plus");
    // }
});


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