MediaWiki:Gadget-blockoptions.js

function QuickBlock (blockOther,blockReason,anonOnly,createAccount,enableAutoblock,emailBan,hideName,watchUser,allowUsertalk) { blockForm = document.getElementById('blockip'); inputs = blockForm.getElementsByTagName('input'); for (i=0; i<inputs.length; i++) { if (inputs[i].name == 'wpBlockOther') { inputs[i].value = blockOther; continue; }		if (inputs[i].name == 'wpBlockReason') { inputs[i].value = blockReason; continue; }		if (inputs[i].name == 'wpAnonOnly') { if (anonOnly==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpCreateAccount') { if (createAccount==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpEnableAutoblock') { if (enableAutoblock==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpEmailBan') { if (emailBan==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpHideName') { if (hideName==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpWatchUser') { if (watchUser==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }		if (inputs[i].name == 'wpAllowUsertalk') { if (allowUsertalk==1) { inputs[i].checked = true; }			else { inputs[i].checked = false; }			continue; }	}	blockForm.submit; }

function userIsInGroup (group) { //are they in a given local group? if (mw.config.get('wgUserGroups')) { if (!group || group.length == 0) group = '*'; if (mw.config.get('wgUserGroups').join (' ').indexOf (group) != -1){ return true; }		else{ return false; }	}	return false; } function userIsInGlobalGroup (group) { //are they in a given global group? if (mw.config.get('wgGlobalGroups')) { if (!group || group.length == 0) group = '*'; if (mw.config.get('wgGlobalGroups').join (' ').indexOf (group) != -1){ return true; }		else{ return false; }	}	return false; }

function addblockoptions {//blockOther,blockReason,anonOnly,createAccount,enableAutoblock,emailBan,hideName,watchUser,allowUsertalk mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("31 hours","recent vandalism",1,1,1,0,0,0,1)',		'vandal: 31h',		'p-block-31h'); mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("1 week","repeated vandalism",1,1,1,0,0,0,1)',		'vandal: 1w',		'p-block-week'); mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("1 month","chronic vandalism",1,1,1,0,0,0,1)',		'vandal: 1m',		'p-block-month'); mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("infinite","vandalism-only account",0,1,1,0,0,0,1)',		'vandal: indef',		'p-block-vandalism'); mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("3 months","cross-wiki issues",0,1,1,0,0,0,0)',		'xwiki: 3mo',		'p-block-xwiki'); mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("1 year","Open proxy or zombie (info)",0,1,0,0,0,0,1)',		'op',		'p-block-proxy'); if(userIsInGroup('checkuser')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("infinite","checkuserblock",0,1,1,1,0,0,0)',		'checkuserblock-user',		'p-block-cu-user'); if(userIsInGroup('checkuser')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("1 year","checkuserblock",0,1,0,0,0,0,1)',		'checkuserblock-IP',		'p-block-cu-ip'); if(userIsInGroup('suppress')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',		'javascript:('+QuickBlock+')("infinite","abusive user name",0,1,1,1,1,0,0)',		'invisible',		'p-block-invisible'); //blockOther,blockReason,anonOnly,createAccount,enableAutoblock,emailBan,hideName,watchUser,allowUsertalk } if ( mw.config.get('wgCanonicalSpecialPageName') == 'Blockip' )$(addblockoptions);