User:Prodego/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:Prodego/monobook.css. |
function addlimenu(tabs, name, id)
{
var na = document.createElement('a');
na.href = '#';
var mn = document.createElement('ul');
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.className = 'tabmenu';
li.appendChild(na);
li.appendChild(mn);
tabs.appendChild(li);
return li;
}
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
// appends msg to the currently-editted page, sets the summary to summ,
// and marks or unmarks the Watch this page checkbox according to watch.
function edit_summary_watch(msg, summ, watch, line)
{
var f = document.editform, t = f.wpTextbox1;
if ((t.value.length > 0) && (line == 1))
t.value += '\n\n';
if (line == -1)
t.value = msg + t.value;
else
t.value += msg;
if (summ.charAt(0) == '+')
f.wpSummary.value += summ.substr(1);
else
f.wpSummary.value = summ;
f.wpWatchthis.checked = 0;
}
function add_talk_header()
{
var from_page = "";
var from_index = location.search.indexOf("&fakefrom=");
if(from_index != -1)
var from_page = unescape(location.search.substring(from_index + 10));
edit_summary_watch("Regarding your edits to [[\:" + from_page + "]]: ", "\/\* " + from_page + "\*\/ ", true, 1);
}
function testwarning(level, summ, sig)
{
var user_warnings = new Array (
"test2a", "test1", "test2", "test3", "test4", "test5-n|31 hours|~\~\~\~", "vblock|31 hours|~\~\~\~", "vpblock", "usertalk-sprotect", "test1a" );
var msg = "{{" + (level == 8 ? "" : "subst:") + user_warnings [level] + "}}" + (sig==1 ? "\n\n\~\~\~\~\n" : "\n");
if (level == 3)
msg = "[[" + "Image:Stop_hand.png|left|30px]]" + msg;
edit_summary_watch (msg, summ, true, ((level != 8) ? 1 : -1));
}
// adds various tabs to call the above
function add_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
// Only add for pages with "Editing User talk:" somewhere in the title
if (document.title.indexOf("Editing User talk:") != -1)
{
addlimenu(tabs, 'Warnings', 'usert');
var usert = document.getElementById('usert').getElementsByTagName('ul')[0];
addlilink(usert,'javascript:add_talk_header()',"header");
addlilink(usert,'javascript:testwarning(1,"+{{" + "test1}}",1)',"test1");
addlilink(usert,'javascript:testwarning(9,"+{{" + "test1a}}",1)',"test1a");
addlilink(usert,'javascript:testwarning(2,"+{{" + "test2}}",1)',"test2");
addlilink(usert,'javascript:testwarning(0,"+{{" + "test2a}}",1)',"test2a");
addlilink(usert,'javascript:testwarning(3,"+{{" + "test3}}",1)',"test3");
addlilink(usert,'javascript:testwarning(4,"+{{" + "test4}}",1)',"test4");
}
}
if (window.addEventListener)
window.addEventListener("load", add_tabs, false);
else if (window.attachEvent)
window.attachEvent("onload", add_tabs);
function strip_namespace(target)
{
var colon = target.indexOf(':');
if (colon != -1)
{
var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
var ns = target.substring(0, colon);
if (ns == '' || ns == 'Talk')
return target.substring(colon + 1);
else
for (var i = 0; i < spaces.length; ++i)
{
if (ns == spaces[i]
|| ns == spaces[i] + '_talk')
return target.substring(colon + 1);
}
}
return target;
}