User:Davidgothberg/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Davidgothberg/monobook.css. |
/************************************************************
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§ion=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§ion=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.
}
/*******************************************************
Note! The DavidClock has been moved to
[[User:Davidgothberg/clock.js]]. See code and usage
explanation there.
********************************************************/
// SVG images: adds links to rendered PNG images in different resolutions
function SVGThumbs() {
var file = document.getElementById("file"); // might fail if MediaWiki can't render the SVG
if (file && wgIsArticle && wgTitle.substring(wgTitle.lastIndexOf(".")).toLowerCase() == ".svg") {
var thumbu = file.getElementsByTagName('IMG')[0].src;
var thumbs = file.getElementsByTagName('IMG')[0].width;
if(!thumbu || !thumbs) return;
function svgAltSize( w, title) {
var path = thumbu.replace( "/"+thumbs+"px-", "/"+ w +"px-" );
var a = document.createElement("A");
a.setAttribute("href", path);
a.appendChild(document.createTextNode(title));
return a;
}
var p = document.createElement("p");
p.className = "SVGThumbs";
p.appendChild(document.createTextNode("This image rendered as PNG in other sizes"+": "));
var l = new Array( 200, 500, 1000, 2000 )
for( var i = 0; i < l.length; i++ ) {
p.appendChild(svgAltSize( l[i], l[i] + "px"));
if( i < l.length-1 ) p.appendChild(document.createTextNode(", "));
}
p.appendChild(document.createTextNode("."));
var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0];
if( info ) info.appendChild(p);
}
};
addOnloadHook( SVGThumbs )