User:Lar/DYK/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 can be added at User:Lar/DYK/monobook.css. |
// <nowiki>
//automate insertion of the following functions:
// Article talk page: {{dyktalk|10 June|2006}}
// (do not subst so that it's compatible with a later change to small)
// Article creator's talk page: {{subst:UpdatedDYK|Article name}}
// Nominator's talk page: {{subst:UpdatedDYKNom|Article name}}
// DEPENDS on addlilink() and addlimenu() being defined already.
// TO USE JUST THESE FUNCS on new tabs, call add_DYK_tabs() from your main menu hook area
function pipe_date()
{
var months = new Array('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December');
var date = new Date();
var yearStr = date.getUTCFullYear();
var dayMoStr = months[date.getUTCMonth()] +" "+ date.getUTCDate();
var t = dayMoStr+"|"+yearStr;
return t;
}
function dyk_talk()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{dyktalk|"+pipe_date()+"|small=no}}~~~~";
f.wpSummary.value = "This article was selected for [[WP:DYK|]]!"
}
function dyk_talkNo()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{dyktalk|"+pipe_date()+"|small=no}}";
f.wpSummary.value = "This article was selected for [[WP:DYK|]]!"
}
function updated_dyk()
{
var page = prompt("User created which article?")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:UpdatedDYK|"+pipe_date()+"|" + page + "}} \nThanks for your contributions! ~~~~";
f.wpSummary.value = "An article which you started, or significantly expanded, ''[[" + page + "]]'', was selected for [[WP:DYK|]]!"
}
function updated_dyk_nom()
{
var page = prompt("User nominated which article?")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:UpdatedDYKNom|"+pipe_date()+"|" + page + "}} \nThanks for your contributions! ~~~~";
f.wpSummary.value = "Your [[WP:DYK|]] nomination for [[" + page + "]] was successful"
}
/// Special DYK version of add_more_tabs and add Unsigned2 (don't call these if you don't want new tabs, add funcs to some existing one)
// add a {{subst:unsigned2|00:49, 27 May 2006|Joe Random User}}
// at the end of the current edit contents.
// will have problems at the change in years since it depends on date.getUTCFullYear()
function addUnsigned2_DYK()
{
// sample string to paste in is "18:32, 18 June 2006 FredUser" or "00:49, 27 May 2006 Timothy Usher "
var date = new Date();
var idString = prompt("ID string?");
var f = document.editform, t = f.wpTextbox1;
// a regexp for the date part of the string would be a better way to do this...
//... but slicing on year should almost always work
var pipeLoc= idString.indexOf(date.getUTCFullYear()); // assume 4 digit year, breaks after 9999
var idStringPiped= idString.substr(0,pipeLoc+4)+'|'+idString.substr(pipeLoc+5,idString.length);
t.value += "{{subst:unsigned2|" + idStringPiped + "}}";
f.wpSummary.value = "add {{tl|Unsigned2}} using string:" + idString;
}
// adds various tabs and menu tabs
function add_DYK_tabs()
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var username=document.getElementById("pt-userpage").textContent;
// Only add for pages with "Editing User talk:" somewhere in the title
if (document.title.indexOf("Editing User talk:") != -1)
{
addlimenu(tabs, 'user talk DYK', 'talkDYK');
var talkDYK = document.getElementById('talkDYK').getElementsByTagName('ul')[0];
addlilink(talkDYK,'javascript:updated_dyk()','DYK-Auth');
addlilink(talkDYK,'javascript:updated_dyk_nom()','DYK-Nom');
addlilink(talkDYK,'javascript:addUnsigned2_DYK()','Unsigned2');
}
// Only add for pages with "Editing Talk:" somewhere in the title
if (document.title.indexOf("Editing Talk:") != -1) {
addlimenu(tabs, 'article Talk DYK', 'talkDYK');
var talkDYK = document.getElementById('talkDYK').getElementsByTagName('ul')[0];
addlilink(talkDYK,'javascript:dyk_talk()','DYK talk');
addlilink(talkDYK,'javascript:dyk_talkNo()','DYK talk no sig');
addlilink(talkDYK,'javascript:addUnsigned2_DYK()','Unsigned2');
}
}
// end of file </nowiki>