User:Davidgothberg/monobook.js

/************************************************************   Note! Old JavaScript code is stored on the talk page.

/* A JavaScript file loaded from my local web server for testing. */ mw.loader.load( 'http://localhost:8080/wikipediatest.js' );

/* Works! */ /* importStylesheet( 'User:Bob/externals.css' ); mw.loader.load( 'http://localhost:8080/wikipediatest.css', 'text/css' );

/*******************************************************  Note! The DavidClock has been moved to   User:Davidgothberg/clock.js. See code and usage explanation there. window.davidClock = 300;   //Static + ticking clock, every 5 minutes. importScript( "User:Davidgothberg/clock.js" );

/* New messages history */ importScript( "User:Davidgothberg/newmessageshistory.js" );

// Add [purge][edit] links at top right corner of page. // Originally by User:Pile0nades, // modified by User:Gerbrant and User:Davidgothberg $( function {

/* if(window.location.href.indexOf("/wiki/Special:") != -1) return; if(document.getElementById("wikiPreview")) return; if(document.getElementById("histlegend?")) return; if(document.getElementById("difference?")) return; if(document.getElementById("watchdetails")) return; if(document.getElementById("mainpage")) return; if ( mw.config.get('wgCanonicalNamespace') == "Special" || mw.config.get('wgPageName') == "Main_Page"   || mw.config.get('wgAction') == "submit" || mw.config.get('wgAction') == "history" ) { return; }

if ( window.location.href.indexOf("&action=edit") == -1 ) { //var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); var divContainer = document.createElement("div");

divContainer.innerHTML = ' [purge] [edit] ';

document.getElementById("content").insertBefore( divContainer,     document.getElementsByTagName("h1")[0] ); } else if ( window.location.href.indexOf("&action=edit&section=0") != -1 ) { var wpSummary = document.getElementById("wpSummary"); if(wpSummary) { wpSummary.value = "/* Section 0 */ "; } }

} );

// Turn on spellchecking in the edit summary field, for Firefox. // Remove this when MediaWiki uses HTML 5 and adds // the "spellcheck=true" attribute in the rendered pages. /* $( function { var wpSummary = document.getElementById( "wpSummary" );  if ( wpSummary && typeof wpSummary.spellcheck != undefined )    wpSummary.spellcheck = true; } );

/* Adding the "My sandbox" or "Sandbox" link. */ /* $( function {

if( mw.config.get('wgUserName') ) { mw.util.addPortletLink( 'p-personal', mw.config.get('wgArticlePath').replace("$1", "Special:Mypage/sandbox"), 'My sandbox', 'pt-sandbox', 'Your personal sandbox', null, document.getElementById('pt-preferences')); } else { mw.util.addPortletLink( 'p-personal', mw.config.get('wgArticlePath').replace("$1", "Wikipedia:Sandbox"), 'Sandbox', 'pt-sandbox', 'A sandbox where you can experiment' ); } } );

// Add some links in the navigation and toolbox menus // on the left side of the page. $( function {

// Add an "Extended search" link to the "navigation" menu". mw.util.addPortletLink( 'p-navigation', mw.config.get('wgArticlePath').replace("$1", "Special:Search"), 'Extended search', 'pt-search', 'More search options' );

// Add "Secure server view" or "Normal server view" link. if( mw.config.get('wgServer') == "http://en.wikipedia.org" ) { mw.util.addPortletLink( "p-tb",      "https://secure.wikimedia.org/wikipedia/en/wiki/" + mw.config.get('wgPageName'),       "Secure server view", "pt-securepage", "Secure server view" ); } else if( mw.config.get('wgServer') == "https://secure.wikimedia.org" ) { mw.util.addPortletLink( "p-tb",      "http://en.wikipedia.org/wiki/" + mw.config.get('wgPageName'),       "Normal server view", "pt-securepage", "Normal server view" ); }

// List subpages of the current page. mw.util.addPortletLink( "p-tb", mw.config.get('wgScript') + "?title=Special:PrefixIndex/" + mw.config.get('wgPageName') + "/",    "Subpages", "pt-subpages", "Subpages" );

// List template transclusion count of the current template page. if ( mw.config.get('wgNamespaceNumber') == 10 || mw.config.get('wgNamespaceNumber') == 11 ) { mw.util.addPortletLink( "p-tb",      "http://toolserver.org/~jarry/templatecount/index.php?lang=en&name="       + mw.config.get('wgTitle') + "#bottom",       "Template transclusions", "pt-transclusion-count", "Transclusion count" ); }

} );

/* Extra buttons for the Edit Toolbar. */ /* mwCustomEditButtons.push( { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5f/Btn_toolbar_tt.png",  "speedTip": "",  "tagOpen": "",  "tagClose": "",  "sampleText": "" } );

mwCustomEditButtons.push( { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/23/Button_code.png",  "speedTip": " ",  "tagOpen": " ",  "sampleText": "" } );

// User:Lupin/popups.js //importScript('User:Lupin/popups.js');  // Old method. //importStylesheet('MediaWiki:Gadget-navpop.css'); //Really old method. //importScript('User:TheDJ/slimpopups.js');        //Really old method. /* I now load it using "my preferences - Gadgets   - Navigation popups" instead. */

// When true prevents loading of preview data for the popup. simplePopups=true;

// When false makes it so the "actions" menu instead goes under the page link instead of as a separate menu. popupActionsMenu=false;

// PopupStructure can be 'original', 'fancy', 'fancy2', 'menus', 'shortmenus', 'lite', 'nostalgia' // popupStructure='original';

/* Makes the "compare selected versions" button on history pages into a link (allows diffs in new windows, tabs, etc.) User:Superm401/Compare link.js */ importScript("User:Superm401/Compare link.js");

/* Colour matching brackets in a copy of the edit box. User:ais523/bracketmatch.js  */ importScript("User:ais523/bracketmatch.js");

/* Shows both "preview" and "changes" with Ajax, much faster than standard preview/changes buttons. User:Js/ajaxPreview  */ importScript("User:Js/ajaxPreview.js"); ajaxPreviewButton = 'P';   // "Preview" button text, when above. ajaxDiffButton = 'D';      // "Changes" button text, when above. ajaxPreviewPos = 'bottom'; // Buttons on the bottom, replacing standard. /* Code to execute after each preview update. */ ajaxPreviewExec = function(previewArea) { if (window.setupTooltips) setupTooltips(previewArea);  // Restart the Navigation popups. }

/*******************************************************  Note! The DavidClock has been moved to   User:Davidgothberg/clock.js. See code and usage explanation there.