User:Polarscribe/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:Polarscribe/monobook.css. |
function hidevfd(){
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "none";
document.getElementById('footer').style.display = 'none';
}
function showvfd(){
var divs = document.getElementsByTagName("div");
for(var x = 0; x < divs.length; ++x)
if(divs[x].className.indexOf("vfd") != -1)
divs[x].style.display = "";
document.getElementById('footer').style.display = '';
}
function addlilink(tabs, url, name){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.appendChild(na);
tabs.appendChild(li);
return li;
}
function vfdlinks(){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("Wikipedia:Articles for deletion") == 0){
addlilink(tabs, 'javascript:hidevfd()', 'Hide');
addlilink(tabs, 'javascript:showvfd()', 'Show');
}
}
if (window.addEventListener) window.addEventListener("load",vfdlinks,false);
else if (window.attachEvent) window.attachEvent("onload",vfdlinks);
/**** afd helper ****/
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */
//<nowiki>
//Auto AFD script
//Please include the two following lines
//Modified version of AutoVFD script to work with AFD
//Script Modified by User:Jtkiefer
// This needs to change depending on skin used.
function add_link(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', url);
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.appendChild(na);
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
tabs.appendChild(li);
}
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;
}
function afd()
{
document.editform.wpTextbox1.value = '{{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'afd';
var target = document.editform.action;
target = target.substring(target.indexOf('title=') + 6,
target.lastIndexOf('&action=submit'));
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var date = new Date();
date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate();
var pagename = strip_namespace(target);
window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target,
'Afd ' + unescape(target),
'status,toolbar,location,menubar,directories,resizeable,scrollbars');
window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename,
'AfdLog ' + unescape(target),
'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}
function autoafd()
{
if (document.title.indexOf('Editing ') == 0)
{
var action = '';
var target = '';
if (location.search)
{
var l = location.search.substring(1).split('&');
for (var i = 0; i < l.length; ++i)
{
var eq = l[i].indexOf('=');
var name = l[i].substring(0, eq);
if (name == 'fakeaction')
action = l[i].substring(eq + 1);
else if (name == 'faketarget')
target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
}
}
if (action == 'afdlist')
{
document.editform.wpTextbox1.value += '{{' + 'Wikipedia:Articles for deletion/' + target + '}}\n';
document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]';
}
else if (action == 'afdsub')
{
if (document.editform.wpTextbox1.value.length > 0)
{
target = document.editform.action;
target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' ');
window.alert("There's an old afd at the default location already.\n\n" +
'Please either move it out of the way (and update existing links to it), or file the Afd by hand in another location (such as [[' + target + ' (2)]]).');
}
else
document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' +
'Reason for nomination. ~~' + '~~\n*\n*\n*\n';
}
else
add_link('javascript:afd()', 'Afd');
}
}
if (window.addEventListener)
window.addEventListener('load', autoafd, false);
else if (window.attachEvent)
window.attachEvent('onload', autoafd);
/* <pre><nowiki> */
if (document.title.indexOf("Confirm delete") != -1) {
var csdDeleteForm = {
FillSelect:function(sel, arr){
if(arr && arr.length>0){
if(arr.length>1){
var FirstOpt = new Option("CSD Reasons", "");
// catches stupid IE error
if(FirstOpt.innerHTML != "CSD Reasons"){
FirstOpt.innerHTML = "CSD Reasons";
}
sel.appendChild(FirstOpt);
sel.options[0].style.color = "gray"
}
sel.disabled = false;
for(var i=0;i<arr.length;i++){
var opt = new Option(arr[i].display, arr[i].value);
// catches stupid IE error
if(opt.innerHTML != arr[i].display){
opt.innerHTML = arr[i].display;
}
sel.appendChild(opt);
}
}else{
sel.options[0] = new Option("No Options Available", "");
// catches stupid IE error
if(sel.options[0].innerHTML != "No Options Available"){
sel.options[0].innerHTML = "No Options Available";
}
sel.disabled = true;
return false;
}
return true;
},
ValueArray:[
{"value":"[[WP:CSD#G1|CSD G1]]: Patent Nonsense","display":"G1 - Nonsense"},
{"value":"[[WP:CSD#G2|CSD G2]]: Test Pages","display":"G2 - Test Pages"},
{"value":"[[WP:CSD#G3|CSD G3]]: Pure Vandalism","display":"G3 - Pure Vandalism"},
{"value":"[[WP:CSD#G4|CSD G4]]: Recreation of deleted material","display":"G4 - Recreated Deleted"},
{"value":"[[WP:CSD#G5|CSD G5]]: Contributions by Banned User","display":"G5 - Banned User"},
{"value":"[[WP:CSD#G6|CSD G6]]: Housekeeping","display":"G6 - Housekeeping"},
{"value":"[[WP:CSD#G7|CSD G7]]: Author Requests Deletion","display":"G7 - Author Request"},
{"value":"[[WP:CSD#G8|CSD G8]]: Talkpage of non-Existent Article","display":"G8 - Talk Page"},
{"value":"[[WP:CSD#G9|CSD G9]]: [[WP:OFFICE|Office Actions]]","display":"G9 - Office Actions"},
{"value":"[[WP:CSD#G10|CSD G10]]: Attack Page","display":"G10 - Attack Pages"},
{"value":"[[WP:CSD#G11|CSD G11]]: Blatant Advertising","display":"G11 - Advertising"},
{"value":"[[WP:CSD#G12|CSD G12]]: Blatant Copyright","display":"G12 - Copyright"},
{"value":"[[WP:CSD#A1|CSD A1]]: Very short article providing little or no context","display":"A1 - No Context"},
{"value":"[[WP:CSD#A2|CSD A2]]: Foreign language article that exists on another Wikipedia","display":"A2 - Foreign Language"},
{"value":"[[WP:CSD#A3|CSD A3]]: No content","display":"A3 - No Content"},
{"value":"[[WP:CSD#A5|CSD A5]]: Has been transwikied","display":"A5 - Transwikied"},
{"value":"[[WP:CSD#A7|CSD A7]]: Unremarkable people, groups, companies and web content","display":"A7 - Unremarkable"},
{"value":"[[WP:CSD#R1|CSD R1]]: Redirect to non-existent page","display":"R1 - Bad Target"},
{"value":"[[WP:CSD#R2|CSD R2]]: Redirect to User/User talk namespaces from mainspace","display":"R2 - Crossnamespace"},
{"value":"[[WP:CSD#R3|CSD R3]]: Implausible typo","display":"R3 - Bad Typo"},
{"value":"[[WP:CSD#I1|CSD I1]]: Redundant to another image","display":"I1 - Redundant"},
{"value":"[[WP:CSD#I2|CSD I2]]: Image is corrupted","display":"I2 - Corrupt/Empty"},
{"value":"[[WP:CSD#I3|CSD I3]]: Improper license","display":"I3 - Improper License"},
{"value":"[[WP:CSD#I4|CSD I4]]: No license","display":"I4 - Lack of License"},
{"value":"[[WP:CSD#I5|CSD I5]]: Is unused and not free","display":"I5 - Unused Unfree"},
{"value":"[[WP:CSD#I6|CSD I6]]: No justification given for fair use","display":"I6 - No Fair Use"},
{"value":"[[WP:CSD#I7|CSD I7]]: Bad justification given for fair use","display":"I7 - Invalid Fair Use"},
{"value":"[[WP:CSD#I8|CSD I8]]: Image exists on the Commons","display":"I8 - On Commons"},
{"value":"[[WP:CSD#G1|CSD C1]]: Category is Empty","display":"C1 - Empty"},
{"value":"[[WP:CSD#C2|CSD C2]]: Speedy Renaming","display":"C2 - Speedy Rename"},
{"value":"[[WP:CSD#C3|CSD C3]]: Corresponding template was deleted","display":"C3 - Template"},
{"value":"[[WP:CSD#U1|CSD U1]]: User requested deletion","display":"U1 - User Request"},
{"value":"[[WP:CSD#U2|CSD U2]]: Userpage of non-existent user","display":"U2 - No User"},
{"value":"[[WP:CSD#U3|CSD U3]]: Userpage that is primarily a gallery of fair use images","display":"U3 - Fair Use Gallery"},
{"value":"[[WP:CSD#T1|CSD T1]]: Template that is divisive and inflammatory.","display":"T1 - Divisive"},
{"value":"[[WP:CSD#P1|CSD P1]]: Any topic that would be subject to speedy deletion as an article.","display":"P1 - Speedy Article"},
{"value":"[[WP:CSD#P2|CSD P2]]: Underpopulated","display":"P2 - Underpopulated"}
],
//**************************** attaching function *****************************************
// got thIS super handi function from http://www.scottandrew.com he is pretty dang smart **
//*****************************************************************************************
addEvent:function(obj, evType, fn, useCapture){
//alert(obj);
if (obj.addEventListener){
obj.addEventListener(evType, fn, useCapture);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
alert("Handler could not be attached");
}
}
}
function addSelectAfter(){
var obj = document.getElementById('wpReason');
// create select using included array
var sel = document.createElement("SELECT");
csdDeleteForm .FillSelect(sel, csdDeleteForm .ValueArray);
// name it
sel.name = "csdOptions";
sel.id = "csdOptions";
sel.style.marginLeft = "10px";
csdDeleteForm .addEvent(sel, "change", csdChangeBox, false);
// check for next sibling and insert before it or at the end
if(obj.nextSibling){
obj.parentNode.insertBefore(sel,obj.nextSibling);
}else{
obj.parentNode.appendChild(sel);
}
}
try{
// add one on load
csdDeleteForm.addEvent(window, "load", addSelectAfter, false);
}catch(err){}
}
function csdChangeBox() {
var obj = document.getElementById('wpReason');
obj.value = document.getElementById('csdOptions').value;
}
/* </nowiki><pre> */