/* Vandal Warner, version [0.2.0]
Created and maintained by User:Huji, modified by User:Hoo man
Based on Whackamole, a script written by User:Pilotguy */
var WarnVandalList, WarnVandalSig;
var WarnVandalItems = [];
var WarnVandalCustomItems = [];
WarnVandalItems.push( ['test', 1, 'Test edit', 'Testedit1'] );
WarnVandalItems.push( ['test2', 1, 'Testing', 'Testedit2'] );
WarnVandalItems.push( ['test3', 1, 'Testing', 'Testedit3'] );
WarnVandalItems.push( ['test4', 1, 'Test edit - Last warning', 'Testedit4'] );
WarnVandalItems.push( ['attackpage', 1, 'Only Warning', 'attackpage'] );
WarnVandalItems.push( ['attackimage', 1, 'attackimage', 'attackimage'] );
WarnVandalItems.push( ['please register', 1, 'Vandalism', 'please register'] );
WarnVandalItems.push( ['please describe images', 1, 'Vandalism', 'please describe images'] );
WarnVandalItems.push( ['talkarchive needed', 1, 'Vandalism', 'talkarchive needed'] );
WarnVandalItems.push( ['How to transfer', 1, 'Vandalism', 'How to transfer'] );
WarnVandalItems.push( ['dont remove delete', 1, 'Removing of contents', 'remove1'] );
WarnVandalItems.push( ['dont remove nsd or nld', 1, 'Removing of contents', 'remove2'] );
WarnVandalItems.push( ['dont remove speedy', 1, 'Removing of contents', 'remove3'] );
WarnVandalItems.push( ['dont overwrite', 1, '[[COM:OVERWRITE|OVERWRITE]]', 'dont overwrite'] );
WarnVandalItems.push( ['dont remove warnings', 1, 'Removing of warnings', 'Removing of warnings'] );
WarnVandalItems.push( ['Copyviouploadindefblock', 1, 'indefblock', 'Copyviouploadindefblock'] );
WarnVandalItems.push( ['off topic', 1, 'No off topic', 'off topic'] );
WarnVandalItems.push( ['Commons is not for articles', 1, 'Commons is not for articles', 'Commons is not for articles'] );
WarnVandalItems.push( ['no advertising', 1, 'no advertising', 'no advertising'] );
WarnVandalItems.push( ['no comments', 1, 'no comments', 'no comments'] );
WarnVandalItems.push( ['project scope', 1, 'project scope', 'project scope'] );
WarnVandalItems.push( ['No scaled down dupes', 1, 'No scaled down dupes', 'No scaled down dupes'] );
function WarnVandal (message, param, summary) {
var tbox = document.getElementById('wpTextbox1');
var a = "" + (window.getSelection ? window.getSelection()
: document.getSelection ? document.getSelection()
: document.selection.createRange().text);
if (param != "") {
a = prompt ("Page name?\n(Empty+OK for a generic message.)\n(Cancel now aborts.)", a);
if (a == null) return;
if (a != null && a != "") {
message = message.replace(/\|/,"|"+a);
summary += " in [[" + a + "]]";
} else {
message = param;
}
}
if (WarnVandalSig == undefined) {
WarnVandalSig = " ~~" + "~~\n";
}
document.getElementById('wpTextbox1').value += message + WarnVandalSig;
document.getElementById('wpSummary').value = summary;
document.getElementById('wpMinoredit').checked=false;
document.getElementById('wpWatchthis').checked=false;
document.getElementById('wpTextbox1').focus();
if (document.getElementById('wpTextbox1').scrollTop || true) {
document.getElementById('wpTextbox1').scrollTop =
document.getElementById('wpTextbox1').scrollHeight;
}
}
window.WarnVandal_addlilink=function(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
WarnVandalList.appendChild(li);
if(id) {
if(key && title) ta[id] = [key, title];
else if(key) ta[id] = [key];
else if(title) ta[id] = ['', title];
}
return li;
}
window.WarnVandal_addToolboxLink=function(url, name, id){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
WarnVandal_addlilink(tb, url, name, id);
}
$(document).ready( function () {
if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgCanonicalNamespace') === 'User_talk') {
var link_div = document.createElement('div');
if(mw.config.get('skin') === 'vector') {
link_div.className = 'body';
}else{
link_div.className = 'pBody';
}
WarnVandalList = document.createElement('ul');
link_div.appendChild(WarnVandalList);
var div = document.createElement('div');
div.setAttribute('id', 'p-vandalwarner');
var heading = document.createElement('h5');
heading.appendChild(document.createTextNode('Vandal Warner'));
div.appendChild(heading);
div.appendChild(link_div);
if (WarnVandalCustomItems.length > 0){
for (i=0; i<WarnVandalCustomItems.length; i++) {
itm = WarnVandalCustomItems[i];
WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' +
(itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' +
'"'+itm[2]+'"); void(0);', itm[3], '');
}
} else {
for (i=0; i<WarnVandalItems.length; i++) {
itm = WarnVandalItems[i];
WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' +
(itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' +
'"'+itm[2]+'"); void(0);', itm[3], '');
}
}
if(mw.config.get('skin') === 'vector') {
document.getElementById('mw-panel').insertBefore(div, document.getElementById('p-tb'));
div.className = 'portal';
}else{
div.className = 'portlet';
var side_col = document.getElementById('column-one');
var node = document.getElementById('p-tb');
side_col.insertBefore(div, node);
}
}
});