MediaWiki:Common.js
From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ mw.loader.load("https://dev.fandom.com/wiki/MediaWiki:MarkBlocked.js?action=raw&ctype=text/javascript"); /* Below is stolen from ED at User:Cobblestone's request */ /* Collapsible toggle */ $(document).ready(function() { $(".collapsibletoggletext").click(function() { $(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext"); }); }); /* Cycle forwards or backwards through elements one at a time via click */ $(function(){ $(".cyclesequence").find(".cyclesequencelinknext").click(function(){ if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").length === 0) { $(this).closest(".cyclesequence").find(".cyclesequenceitem:first").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); } else { $(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); } }); $(".cyclesequence").find(".cyclesequencelinkprev").click(function(){ if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").length === 0) { $(this).closest(".cyclesequence").find(".cyclesequenceitem:last").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); } else { $(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); } }); }); /* Click link to show one or more items and hide other items */ $(function() { $(".morphlink").click(function() { var correspondingContent = $(this).data("correspondingcontent"); if ($(this).parents(".morphcontainer").length) { $(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext"); if ($("#" + correspondingContent).length) // morphing object uses IDs $("#" + correspondingContent).removeClass("hiddentext"); else // morphing object uses classes $("." + correspondingContent).removeClass("hiddentext"); } else { if ($("#" + correspondingContent).length) { // morphing object uses IDs $("#" + correspondingContent).removeClass("hiddentext"); $("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); } else { // morphing object uses classes $("." + correspondingContent).removeClass("hiddentext"); $("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); } } }); }); //SHOWING JANNY INTERFACE FOR JANNIES //shamelessly ripping this from wikipedia's guide - Manual:Interface/Sidebar function ModifySidebar( action, section, name, link ) { try { switch ( section ) { case 'languages': var target = 'p-lang'; break; case 'toolbox': var target = 'p-tb'; break; case 'navigation': var target = 'p-navigation'; break; default: var target = 'p-' + section; break; } if ( action == 'add' ) { var node = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0]; var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' ); aNode.appendChild( document.createTextNode( name ) ); aNode.setAttribute( 'href', link ); liNode.appendChild( aNode ); liNode.className = 'plainlinks'; node.appendChild( liNode ); } if ( action == 'remove' ) { var list = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0]; var listelements = list.getElementsByTagName( 'li' ); for ( var i = 0; i < listelements.length; i++ ) { if ( listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name || listelements[i].getElementsByTagName( 'a' )[0].href == link ) { list.removeChild( listelements[i] ); } } } } catch( e ) { // let's just ignore what's happened return; } } // adjustments function CustomizeModificationsOfSidebar() { // Since everybody is going to read this, the goal is to add Janny Interface for jannies ModifySidebar( 'add', 'Navigation', 'Janny interface', 'Soyjak_Wiki:Janny_interface' ); } //'navigation' doesn't work due to capitalization but 'toolbox' does if ( mw.config.get( 'wgUserGroups', [] ).indexOf( 'Helper' ) !== -1 ) { //check user groups for the names jQuery( CustomizeModificationsOfSidebar ); } //this is specifically for admins who aren't helpers //currently this applies only for coalson if ( mw.config.get( 'wgUserGroups', [] ).indexOf( 'administrator' ) !== -1 ) { //check user groups for the names jQuery( CustomizeModificationsOfSidebar ); }