User:Voice of All/Approvals.js

//

function add_bottabs()

{

if (document.title.indexOf('Editing Wikipedia:Bots/Requests for approval/') ==0)

{

var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];

addlimenu(tabs, 'bot approval', 'respfunc');

var respfunc = document.getElementById('respfunc').getElementsByTagName('ul')[0];

addlilink(respfunc, 'javascript:rfa_trial(1)',"trial (t)", '');

addlilink(respfunc, 'javascript:rfa_trial(2)',"trial (e)", '');

addlilink(respfunc, 'javascript:rfa_pass(1)',"app. (f)", '');

addlilink(respfunc, 'javascript:rfa_pass(0)',"app. (nf)", '');

addlilink(respfunc, 'javascript:rfa_pass(2)',"app. task", '');

addlilink(respfunc, 'javascript:rfa_fail()',"deny", '');

addlilink(respfunc, 'javascript:rfa_arch()',"done", '');

}

else if (document.title.indexOf('Editing Wikipedia:Bots/Requests for approval') ==0)

{

if (location.href.search(/&jstext=/) !=-1)

{

var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];

addlimenu(tabs, 'bot approval', 'respfunc');

var respfunc = document.getElementById('respfunc').getElementsByTagName('ul')[0];

addlilink(respfunc, 'javascript:add_text()',"Add", '');

alert('Add "" to the correct place and press the "add" tab');

}

}

}

function add_text()

{

var target = unescape(location.href.split('&jstext=')[1].split('&')[0]);

var f = document.editform, t = f.wpTextbox1;

if (t.value.search(//) ==-1) return;

t.value = t.value.replace(//g,target);

f.wpSummary.value += "JS: adding " + target;

}

//

var approvals_url = 'Wikipedia:Bots/Requests_for_approval';

var approved_list_url = 'Wikipedia:Bots/Approved_bot_requests';

var rejected_list_url = 'Wikipedia:Bots/Requests_for_approval/rejected';

function rfa_trial(type)

{

var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];

var f = document.editform, t = f.wpTextbox1;

if (t.value.length > 0)

t.value += '\n';

if (type==1)

t.value +=":20px Bot trial run approved for the duration of one week. " + "~" + "~" + "~" + "~";

else

t.value +=":20px Bot trial run approved for 50 edits. " + "~" + "~" + "~" + "~";

target = "*{{botlinks|" + name + "}} Approved for trials as of ~~~~~";

f.wpSummary.value += "Response: trial run approved";

window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approvals_url + '&action=edit§ion=3&jstext=' + escape(target),'RFBA:add',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

}

function rfa_fail()

{

var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];

var f = document.editform, t = f.wpTextbox1;

if (t.value.length > 0)

t.value += '\n';

t.value +=":20px Bot not approved, discussion archived. " + "~" + "~" + "~" + "~";

if (t.value.search(/:''The above discussion is preserved as an archive/) !=-1)

{t.value = '' + '\n' + t.value + '\n' + ''; alert('Please tag manually.');}

else

{t.value = '{{subst:debate top}}' + '\n' + t.value + '\n' + '{{subst:debate bottom}}';}

f.wpSummary.value += "Archiving, bot not approved";

window.open(mw.config.get('wgServer') + '/w/index.php?title=' + rejected_list_url + '&action=edit','RFBA:archf',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

}

function rfa_pass(flag)

{

var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];

var f = document.editform, t = f.wpTextbox1;

target ='';

if (t.value.length > 0)

t.value += '\n';

if (flag==1)

{

t.value +=":20px Approved; the bot shall run with a flag. " + "~" + "~" + "~" + "~";

f.wpSummary.value += "Response: bot approved (flagged)";

target = "{{botlinks|" + name + "}} Approved on ~~~~~ (flag needed)";

}

else if (flag==0)

{

t.value +=":20px Approved; the bot shall run without a flag. " + "~" + "~" + "~" + "~";

f.wpSummary.value += "Response: bot approved (not flagged)";

target = "{{botlinks|" + name + "}} Approved on ~~~~~ (not flagged)";

}

else if (flag==2)

{

t.value +=":20px Task approved. " + "~" + "~" + "~" + "~";

f.wpSummary.value += "Response: task approved";

target = "{{botlinks|" + name + "}} Task approved on ~~~~~";

}

//approved reqs

window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approved_list_url + '&action=edit§ion=4&jstext=' + escape(target),'RFBA:add',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

//bots in a trial, bot should be removed from here if listed

window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approvals_url + '&action=edit§ion=3','RFBA:rm',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

}

function rfa_arch()

{

var f = document.editform, t = f.wpTextbox1;

if (t.value.search(/:''The above discussion is preserved as an archive/) !=-1)

{t.value = '' + '\n' + t.value + '\n' + ''; alert('Please tag manually.');}

else

{t.value = '{{subst:debate top}}' + '\n' + t.value + '\n' + '{{subst:debate bottom}}';}

window.open(approvals_url,'RFBA:remove',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

document.editform.wpMinoredit.checked = true;

f.wpSummary.value += "Archiving request";

var URL ='http://en.wikipedia.org/w/index.php?title=Wikipedia:Bots/Requests_for_approval/Approved&action=edit';

window.open(URL,'RFBA:archp',

'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');

}

$(approvals_main)

function approvals_main()

{

add_bottabs();

}

//