User:Trixt/monobook.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
The accompanying .css page for this skin is at User:Trixt/monobook.css. |
- Report page listing warnings and errors.
window.wgNotice=""; // Let's get rid of buggy centralnotices. I don't want them anyway.
var oldEdittools = true; // goddamn.
/*
//var gallery_details_newfiles_run = false;
if (wgUserName == 'Lupo') {
window.importScript = function (page, develop) {
// if (page == 'MediaWiki:Tooltips.js') page = 'User:Lupo/tt.js';
// if (page == 'MediaWiki:LAPI.js') page = 'User:Lupo/lapi.js';
var uri =
wgScript '?title='
encodeURIComponent(page.replace(/ /g,'_')).replace('/','/').replace(':',':')
'&action=raw&ctype=text/javascript';
if (develop) uri = uri '&smaxage=0&maxage=0&dummy=' (new Date).getTime ();
return importScriptURI (uri);
}
}
*/
importScript ('MediaWiki:LAPI.js');
var today = new Date ();
var months = new Array ("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December");
function formatDate (d, with_timezone)
{
if (!with_timezone) {
return months[d.getMonth()] ' ' d.getDate() ', ' d.getFullYear();
} else {
var tzRaw = d.getTimezoneOffset();
var tzHour = Math.floor( Math.abs(tzRaw) / 60);
var tzMin = Math.abs(tzRaw) % 60;
var tzString = ((tzRaw >= 0) ? "-" : " ")
((tzHour < 10) ? "0" : "")
tzHour ((tzMin < 10) ? "0" : "") tzMin;
return formatDate (d, false) ' (' tzString ')';
}
}
if (wgUserName == 'Lupo') {
importScript ('User:Lupo/getRawFileLink.js');
//importScript ('User:Lupo/p.js'); // Gadget-PrettyLog
if (wgCanonicalSpecialPageName == 'Upload'
&& /[&?]uselang=\S*fromflickr/.test (document.location.href)) {
importScript ('User:Lupo/f.js');
}
importScript ('User:Lupo/c2.js'); // HotCat dev. version
addOnloadHook (function () {
if (typeof HotCat != 'undefined') HotCat.blacklist = /stubs?$/;
});
/*
if (webkit_match) {
alert ("Getting Firebug Lite");
importScript ('User:Lupo/fb.js');
}
*/
// Only for me.
var my_tests = getParamValue ('withAnyJS');
if (my_tests) importScript (my_tests);
// var image_deletion_script = '&withAnyJS=User:Lupo/gdh.js';
// importScript ('User:Lupo/gdh.js'); // Fast closing of deletion requests (old version)
}
/*** Enable third-party functionality in external scripts */
importScript ('MediaWiki:Utilities.js');
if (typeof (GalleryDetails) != 'undefined') {
importScript ('MediaWiki:GalleryDetails-Tooltips.js');
// An enhancement of the GalleryDetails extension, which I have enabled as a gadget
if (wgUserName == 'Lupo') {
importScript ('User:Lupo/gd.js'); // Additional links (experimental)
}
}
importScript ('User:Lupo/da.js'); // Deletion request archiver
importScript ('MediaWiki:ThumbnailPurger.js'); // Purge thumbnails (obsolete?)
importScript ('User:Lupo/ImgDelLinks.js'); // Quick deletion links on image pages
var ImageAnnotator_zoom_threshold = 3.0;
if (wgUserName == 'Lupo') {
// TEST: Checkusage replacement
importScript ('User:Lupo/testfile.js');
// importScript ('User:Lupo/ia.js');
}
if (typeof (uTemplate) == 'undefined') { // Gadget-UserMessages is disabled
// Replacement for Gadget-UserMessages.js. Use this only if you have the gadget disabled!
importScript ('User:Lupo/u.js');
var template_autosave = false; // Don't save automatically... MAY BE CHANGED
}
if (wgUserName == 'Lupo') {
importScript ('User:Lupo/autocorrect.js'); // Auto-correction of common errors
importScript ('User:Lupo/uselanghacks.js'); // Support for setting up upload forms
}
/*** Customize third-party functionality: MediaWiki:Extra-tabs.js */
var UploadForm_own_language_first = true;
var UploadForm_page_preview_in_tooltip = true;
if (wgUserName == 'Lupo') { // YOU MAY REMOVE THIS
// Only for me. If you also want these, feel free to remove the if statement
// and it's closing } below.
// Make Quick-delete (the nominate-for-deletion links in the sidebar) close the windows it opens
var quick_delete_close_windows = true;
// I have the gallery details gadget enabled. Make it also close windows it opens.
var gallery_details_close_windows = true;
// Same for ImgDelLinks...
var image_links_close_windows = true;
} // ALSO REMOVE THIS, THEN
// Extra-tabs customizations
tab_check_usage = 'uses';
tab_categorize = 'cat?';
function additionalImageTabs ()
{
if (wgNamespaceNumber != 6) return;
makeTab ( makeRawLink ( 'desc'
, 'http://tools.wikimedia.de/~magnus/whatisthat.php?image='
encodeURIComponent (wgTitle.split (" ").join ("_"))
'&do_it=' encodeURIComponent ('Do it!')
, '_blank')
, 'ca-whatsthis');
}
// Always insert the form of Gadget-rightsfilter, which I have enabled
window.AutoLoadLogsFilter = true;
/*** Thumbnail regenerator (obsolete?) */
function generate_thumbnail () {
var urltitle = encodeURIComponent (wgTitle.split (' ').join ('_'));
var input = prompt ('Sizes (separate by \';\'): ', '120;180');
if (input) input = input.replace (/\s/g, '');
if (!input || input.length == 0) return;
var sizes = input.split (';');
for (i = 0; i < sizes.length; i ) {
if (sizes[i].length > 0) {
if (/\D/.test (sizes[i]))
alert (sizes[i] ' is not a valid thumbnail size. Use only digits. Value ignored.');
else {
var X = sajax_init_object();
var uri = mw.config.get('wgServer') mw.config.get('wgScriptPath') '/thumb.php?w=' sizes[i] '&f=' urltitle;
X.open ('GET', uri, false);
X.send (null); // No POST data
}
}
}
}
/*** Edit section 0 link */
function addLeadSectionTab () {
/* Only add new tab if the page is editable and has section editing links. */
if (getElementsByClassName (document, '*', 'mw-editsection').length > 0) {
var edit_tab = document.getElementById ('ca-edit');
if (edit_tab != null) {
var href_for_lead = edit_tab.firstChild.getAttribute ('href') "§ion=0";
var first_title = getElementsByClassName (document, 'h1', 'firstHeading');
if (first_title.length > 0) {
/* We have a "firstHeading": put "[edit]" to its right */
var edit_span = document.createElement ('span');
edit_span.setAttribute ('class', 'mw-editsection');
edit_span.appendChild (document.createTextNode (' ['));
edit_span.appendChild (makeRawLink ("edit", href_for_lead));
edit_span.appendChild (document.createTextNode (']'));
first_title[0].appendChild (edit_span);
} else {
/* No first title found: create a tab */
var new_tab = document.createElement ('li');
new_tab.id = 'ca-editlead';
var link = makeRawLink ("Edit lead", href_for_lead);
new_tab.appendChild (link);
edit_tab.parentNode.appendChild (new_tab);
}
}
}
}
function getElementsByTagNameStatic (tag, root) {
var elements = root.getElementsByTagName (tag);
var result = [];
if (elements) {
// Now copy it; elements is a live list!
for (var i = 0; i < elements.length; i ) result[result.length] = elements[i];
}
return result;
}
function setLeadSectionEditSummary ()
{
/* The edit summary is set to "Lead section" if we're editing only the lead section of
an article. This is the case iff the URL of the document ends in "§ion=0". */
if ((document.location.href.indexOf ("§ion=0") 10 == document.location.href.length) &&
(document.editform != null) &&
(document.editform.wpSummary != null))
{
document.editform.wpSummary.value = "/* Lead section */ ";
}
}
/*** Personal toolbox */
function myPortlet() {
var leftcolumn = document.getElementById ('column-one');
if (!leftcolumn) return;
/* Put together a new portlet and insert it at the top of the left column. */
/* Note: \xa0 is and \xa9 is © */
var newportlet = document.createElement('div');
var content = document.createElement('div');
newportlet.className = 'portlet';
newportlet.id = 'p-lupo-links';
newportlet.style.direction = 'ltr';
content.className = 'pBody';
content.style.direction = 'ltr';
content.appendChild (document.createTextNode('ML: '));
content.appendChild
(makeRawLink('(en)',
'http://mail.wikipedia.org/pipermail/wikien-l/'
(today.getFullYear ()) '-' months[today.getMonth()] '/thread.html#end'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild
(makeRawLink('(c)',
'http://mail.wikipedia.org/pipermail/commons-l/'
(today.getFullYear ()) '-' months[today.getMonth()] '/thread.html#end'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild
(makeRawLink('(f)',
'http://mail.wikipedia.org/pipermail/foundation-l/'
(today.getFullYear ()) '-' months[today.getMonth()] '/thread.html#end'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild
(makeRawLink('(t)',
'http://mail.wikipedia.org/pipermail/wikitech-l/'
(today.getFullYear ()) '-' months[today.getMonth()] '/thread.html#end'));
content.appendChild (document.createElement('br'));
content.appendChild (document.createTextNode('Logs: '));
content.appendChild (makeWikiLink ('P', 'Special:Log/protect'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('B', 'Special:Log/block'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('D', 'Special:Log/delete'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('I', 'Special:Log/upload'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('M', 'Special:Log/move'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('U', 'Special:Log/newusers'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('N', 'Special:Contributions/newbies'));
content.appendChild (document.createElement('br'));
content.appendChild (makeWikiLink ('DEL', 'COM:DEL'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('L', 'COM:L'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('AN', 'COM:AN'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('VP', 'COM:VP'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('Upload', 'Special:Upload?uselang=experienced'));
content.appendChild (document.createElement('br'));
if (wgUserName == 'Lupo') {
content.appendChild (makeWikiLink ('simple', 'User:Lupo/Simple Photographs'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('hairy', 'User:Lupo/Hairy copyright'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild (makeWikiLink ('bio', 'User:Lupo/resources'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
}
content.appendChild
(makeRawLink ('css', wgScript '?title=User:'
encodeURIComponent (wgUserName)
'/monobook.css&action=edit'));
content.appendChild (document.createTextNode('\xa0|\xa0'));
content.appendChild
(makeRawLink ('js', wgScript '?title=User:'
encodeURIComponent (wgUserName)
'/monobook.js&action=edit'));
if (typeof (ImgDelLinks) != 'undefined') {
var del_lks = ImgDelLinks.create_link ();
if (del_lks) {
content.appendChild (document.createElement('hr'));
content.appendChild (del_lks);
}
}
if (wgNamespaceNumber == 8 && wgUserName == 'Lupo') {
var tmp = wgPageName.split ('/');
if (tmp && tmp.length == 2) {
content.appendChild (document.createElement('hr'));
content.appendChild (
makeActiveLink ('uselang hack', 'UseLangHack.do_uselang_hack (false); void 0;'));
content.appendChild (document.createElement('br'));
content.appendChild (
makeActiveLink ('uselang copy', 'UseLangHack.do_uselang_hack_copy (false); void 0;'));
content.appendChild (document.createElement('br'));
content.appendChild (
makeActiveLink ('uselang hack...', 'UseLangHack.do_uselang_hack (true); void 0;'));
content.appendChild (document.createElement('br'));
content.appendChild (
makeActiveLink ('uselang copy...', 'UseLangHack.do_uselang_hack_copy (true); void 0;'));
}
} else if (wgUserName == 'Lupo') {
var tmp = wgPageName.split ('/');
if (tmp && tmp.length == 2 && tmp[0] == 'Commons:Upload') {
content.appendChild (document.createElement('hr'));
content.appendChild (
makeActiveLink ('uselang hack (full)', 'UseLangHack.do_full_set (false); void 0;'));
content.appendChild (document.createElement('br'));
content.appendChild (
makeActiveLink ('uselang hack...', 'UseLangHack.do_full_set (true); void 0;'));
}
}
var title=document.createElement('h3');
title.style.textTransform = 'none';
title.appendChild (document.createTextNode (formatDate (today, false)));
newportlet.appendChild(title);
newportlet.appendChild(content);
/* Insert the newly created portlet in the left column. */
leftcolumn.insertBefore (newportlet, leftcolumn.firstChild);
}
/*** Other customizations: bottom tabs */
function bottomTabs() {
/* Duplicate the top "tabs" at the end of the content area. */
var tabs = document.getElementById('p-cactions').cloneNode(true);
/* Give all the named items new ids to avoid id clashes with the existing top "tabs". */
tabs.id = 'mytabs';
var listitems = tabs.getElementsByTagName('LI');
for (i=0;i<listitems.length;i ) {
if(listitems[i].id) listitems[i].id = 'mytabs-' listitems[i].id;
}
document.getElementById('column-content').appendChild(tabs);
}
function topTabsToRightPlace() {
/* Remove the top "tabs" from the .portlet side column (why were they ever put there?) and
put them at the top of the content area, where they belong! (This allows me to use simple
relative positioning to get a proper layout. I don't have to mess around with absolute
positioning. This is necessary for my language links at the top to work properly, but it
is cleaner anyway. */
var contents = document.getElementById('column-content');
var tabs = document.getElementById('p-cactions');
tabs.parentNode.removeChild (tabs);
contents.insertBefore(tabs, contents.firstChild);
}
function rmLogo() {
/* Physically remove the logo. My CSS doesn't display it anyway, but I don't know whether
that is sufficient to prevent the browser loading it. */
var logo = document.getElementById('p-logo');
if (logo) logo.parentNode.removeChild (logo);
}
function fixDiffPage () {
var oldtitle = document.getElementById ('mw-diff-otitle1');
var newtitle = document.getElementById ('mw-diff-ntitle1');
if (!oldtitle || !newtitle) return;
oldtitle = oldtitle.getElementsByTagName('a');
newtitle = newtitle.getElementsByTagName('a');
if (!oldtitle || oldtitle.length == 0|| !newtitle || newtitle.length == 0) return;
oldtitle = oldtitle[0];
newtitle = newtitle[0];
if (!oldtitle || !newtitle) return;
var oT = LAPI.WP.pageFromLink (oldtitle);
var nT = LAPI.WP.pageFromLink (newtitle);
if (oT != nT) {
oldtitle.insertBefore (document.createTextNode (oT ': '), oldtitle.firstChild);
newtitle.insertBefore (document.createTextNode (nT ': '), newtitle.firstChild);
}
}
function reformatMyPage() {
rmLogo();
addLeadSectionTab();
setLeadSectionEditSummary();
myPortlet();
additionalImageTabs ();
bottomTabs();
var content = document.getElementById ('bodyContent');
if (/[&?](diff|oldid|newid)=/.test (document.URL)) {
// Diff page: check if we have different files
fixDiffPage ();
}
if (wgCanonicalNamespace == 'Special' &&
(wgCanonicalSpecialPageName == 'Log'
|| wgCanonicalSpecialPageName == 'Whatlinkshere'
|| wgCanonicalSpecialPageName == 'LinkSearch')) {
// Add [del] links to image links on some special pages
var lks = getElementsByTagNameStatic ('a', document.getElementById ('bodyContent'));
DelReqHandler.addDelKeepLinks (lks, false, false, true);
} else if ( document.URL.indexOf ('Commons:Deletion_requests') < 0
&& wgPageName != 'Commons:Deletion_requests'
&& document.URL.search (/[\?&](action=(edit|submit|delete)|oldid=)/) < 0) {
// Add [del] links on galleries (including on categories)
// On a deletion request, we need not do this, as DelReqHandler will do it anyway.
// Also don't do this if "&action=edit|submit|delete" is present.
var galleries = getElementsByClassName (document, 'table', 'gallery');
if (galleries && galleries.length > 0) {
for (var i = 0; i < galleries.length; i ) {
var lks = getElementsByTagNameStatic ('a', galleries[i]);
DelReqHandler.addDelKeepLinks (lks, false, false, true);
}
}
}
if (wgCanonicalNamespace == 'Creator' && document.getElementById ('editform')) {
var t = document.getElementById ('wpTextbox1');
if (!t.value || t.value.length == 0) {
t.value = '\{\{Creator\n|Name = \<\!-- Last name, First name --\>\n|Alternative names = ' wgTitle
'\n|Description = \n|Birthdate = \n|Birthloc = \n|Deathdate = \n|Deathloc = '
'\n|Workperiod = \n|Workloc = \n\}\}'
'\n\<' 'includeonly\>\[\[Category: by ' wgTitle '\]\]\<\/includeonly\>'
'\n\<' 'noinclude\>\n\[\[Category: by ' wgTitle '| \]\]'
'\n\<\!-- birth/death cats or XXth century YY--\>'
'\n\<' '\/noinclude\>';
}
}
// topTabsToRightPlace(); /* First the top "tabs"... */ // Used only at en-WP, not here
}
hookEvent ('load', reformatMyPage);
// Copy from here
(function(){function setShortCuts(){if (!window.HotCat.addShortcuts) return; window.HotCat.addShortcuts({
// Add your shortcuts below
// Shortcut : Replacement, both inside single quotes. If the replacement shall contain a single quote, write it as \'
'ppl':'People',
'tpp':'Template:Painting possible',
'xxx':'hdsjfgjshaghjgdsf',
// Do not modify below
' ':""});} if (window.HotCat && window.HotCat.runWhenReady) window.HotCat.runWhenReady(setShortCuts); else $('body').bind('hotcatSetupCompleted',setShortCuts);})();
// End of copy