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
Line 48: | Line 48: | ||
$( "div#left-navigation" ).appendTo( "div#navigation" ); | $( "div#left-navigation" ).appendTo( "div#navigation" ); | ||
− | $( "<div id='pageInfo'></div>" ).insertBefore( "content-sidebar-wrap" ); | + | $( "<div id='pageInfo'></div>" ).insertBefore( "div#content-sidebar-wrap" ); |
$( "div#navigation, div#content" ).wrapAll( "<div id='content-navigation-wrap'></div>" ); | $( "div#navigation, div#content" ).wrapAll( "<div id='content-navigation-wrap'></div>" ); |
Revision as of 19:49, 3 April 2016
/********** Any JavaScript here will be loaded for all users on every page load **********/ // Allow Jquery 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 ); /********** Structure **********/ // Remove unnecessary elements $( "div#p-tb" ).remove(); if ( $( "li#pt-userpage" ).length ) {} else { $( "div#p-Wiki" ).remove(); } // Wrap the content $( "div#content, div#mw-navigation" ).wrapAll( "<div id='wrap'></div>" ); // Insert the header $( "<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" ); // Insert the footer $( "<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" ); // Organize the elements $( "div#mw-navigation" ).insertBefore( "div#content" ); $( "div#content" ).wrap( "<div id='content-sidebar-wrap'></div>" ); $( "div#mw-panel" ).insertBefore( "div#content" ); $( "div#content" ).wrap( "<div id='content-wrap'></div>" ); $( "<div id='navigation'></div>" ).insertBefore( "div#content" ); $( "div#right-navigation" ).appendTo( "div#navigation" ); $( "div#left-navigation" ).appendTo( "div#navigation" ); $( "<div id='pageInfo'></div>" ).insertBefore( "div#content-sidebar-wrap" ); $( "div#navigation, div#content" ).wrapAll( "<div id='content-navigation-wrap'></div>" ); $( "div#siteNotice" ).insertAfter( "div#mw-navigation" ); $( "ul#footer-info" ).insertAfter( "div#content" ); //$( "div#p-search" ).prependTo( "div#mw-panel" ); //$( "<div id='searchTitle'>Search</div>" ).insertBefore( "form#searchform" ); // 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 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() ); $.each( $( "span.subpages > a" ), function() { if ( $( this ).is( ":last-child" ) ) { // } else { $( "<span> / </span>" ).insertAfter( this ); } }); /* if ( $( "span.subpages" ).length > 0 ) { $( "span.subpages" ).html( $( "span.subpages" ).children() ); var title = $( "h1#firstHeading" ).html().split('/'); $( "<span>" + title[ title.length - 1 ] + "</span>" ).appendTo( "span.subpages" ); $( "<span> / </span>" ).insertAfter( "span.subpages > a" ); } 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 $( "<div id='announcement'></div>" ).prependTo( "div#localNotice" ); $( "div#localNotice > p" ).first().addClass( "current" ); $( "div#announcement" ).html( $( "div#localNotice > p.current" ).html() ); setInterval( function() { if ( $( "div#localNotice > p.current" ).is( ":last-child" ) ) { $( "div#localNotice > p.current" ).removeClass( "current" ); $( "div#localNotice > p" ).first().addClass( "current" ); } else { $( "div#localNotice > p.current" ).removeClass( "current" ).next().addClass( "current" ); } $( "div#announcement" ).fadeTo( 500, 0, function() { $( "div#announcement" ).html( $( "div#localNotice > p.current" ).html() ).fadeTo( 500, 1 ); }); }, 4000); // 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" ); // Set up the edit box $( "input#wpWatchthis" ).prop( "checked", false ); $( "<div class='customButton' id='CB-Bold'>Bold</div>" ).appendTo( "div#toolbar" ); $( "#CB-Bold" ).click( function() { wrapText( "wpTextbox1", "<b>", "</b>" ); }); $( "<div class='customButton' id='CB-Italic'>Italic</div>" ).appendTo( "div#toolbar" ); $( "#CB-Italic" ).click( function() { wrapText( "wpTextbox1", "<i>", "</i>" ); }); $( "<div class='customButton' id='CB-Heading1'>Heading 1</div>" ).appendTo( "div#toolbar" ); $( "#CB-Heading1" ).click( function() { wrapText( "wpTextbox1", "<h1>", "</h1>" ); }); $( "<div class='customButton' id='CB-Heading2'>Heading 2</div>" ).appendTo( "div#toolbar" ); $( "#CB-Heading2" ).click( function() { wrapText( "wpTextbox1", "<h2>", "</h2>" ); }); 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 ) ); } /********** 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() { $( this ).wrap( "<a></a>" ); var href = $( this ).find( "a" ).attr( "href" ); var title = $( this ).find( "a" ).attr( "title" ); $( this ).parent().attr( "href", href ).attr( "title", title ); }); $.each( $( "div#index img" ), function() { $( this ).attr( "draggable", "false" ); }); // Remove the loader setTimeout( function() { $( "div#mw-head-base" ).fadeOut( 500 ); $( "div#mw-page-base" ).fadeOut( 500 ); }, 600 );