Jump to content

User:Davidgothberg/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Davidgothberg (talk | contribs) at 02:21, 11 February 2010 (Add "Secure server view" link to the toolbox.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/************************************************************
    Note! Old JavaScript code is stored on the talk page. 
*************************************************************/

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


/* Works! */
/*
importStylesheet( 'User:Bob/externals.css' );
importStylesheetURI( 'http://localhost:8080/wikipediatest.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" );



// [[User:Gerbrant/edit/top.js]]

// This will add an [edit] link at the top of all pages except preview pages and the main page.
// Originally by [[User:Pile0nades]], modified by [[User:Gerbrant]].
// [[User:Davidgothberg]] added a [purge] link.

// Add an [edit] link to pages
hookEvent("load", 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(window.location.href.indexOf("&action=edit") == -1)
	{
		var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
		var divContainer = document.createElement("div");


		divContainer.innerHTML = '<div class="editsection" style="float:right; margin-top:0px;">\
[<a href="/w/index.php?title=' + pageTitle + '&action=purge" \
title="' + pageTitle + '">purge</a>]<br/>[<a href="/w/index.php?title=' + pageTitle + '&action=edit&section=0" \
title="' + pageTitle + '">edit</a>]</div>';


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



// 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.
/*
addOnloadHook( function() {
  var wpSummary = document.getElementById( "wpSummary" );
  if ( wpSummary && typeof wpSummary.spellcheck != undefined )
    wpSummary.spellcheck = true;
} );
*/


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

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



/* Add "Extended search" to the "navigation" menu. */
addOnloadHook( function() {

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

} );



/* Extra buttons for the Edit Toolbar. */
/*
mwCustomEditButtons.push( {
  "imageFile": "/media/wikipedia/commons/5/5f/Btn_toolbar_tt.png",
  "speedTip": "<tt></tt>",
  "tagOpen": "<tt>",
  "tagClose": "</tt>",
  "sampleText": ""
} );
*/

mwCustomEditButtons.push( {
  "imageFile": "/media/wikipedia/commons/2/23/Button_code.png",
  "speedTip": "<code><nowiki></nowiki></code>",
  "tagOpen": "<code><nowiki>",
  "tagClose": "</nowiki></code>",
  "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.
}



// Add some links in the toolbox menu on the left side of the page.
addOnloadHook( function() {

  // Add "Group notice" and "Page notice" links.

  addPortletLink( "p-tb", wgScript + "?title=Template:Editnotices/Group/" 
    + encodeURIComponent(wgPageName) 
    + "&action=edit", "Group notice", "pt-groupnotice", "Group notice" );
  addPortletLink( "p-tb", wgScript + "?title=Template:Editnotices/Page/" 
    + encodeURIComponent(wgPageName) 
    + "&action=edit", "Page notice", "pt-pagenotice", "Page notice" );
  if( wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User talk" ) {
    addPortletLink( "p-tb", wgScript + "?title=" + encodeURIComponent(wgPageName) 
      + "/Editnotice"
      + "&action=edit", "User notice", "pt-usernotice", "User notice" );
  }

  // Add "Secure server view" or "Normal server view" link.

  if( wgServer == "http://en.wikipedia.org" ) {
    addPortletLink( "p-tb", 
      "https://secure.wikimedia.org/wikipedia/en/wiki/" + encodeURIComponent(wgPageName), 
      "Secure server view", "pt-securepage", "Secure server view" );
  }
  else if( wgServer == "https://secure.wikimedia.org" ) {
    addPortletLink( "p-tb", 
      "http://en.wikipedia.org/wiki/" + encodeURIComponent(wgPageName), 
      "Normal server view", "pt-securepage", "Normal server view" );
  }

} );



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