MediaWiki:Electrocute.js

/** * Special:Electrocute * @author Splarka * Originally from http://en.wikipedia.org/wiki/User:Splarka/electrocute.js */ addOnloadHook(function {	addPortletLink('p-tb', '/wiki/Special:Electrocute', 'Electrocutions'); });

if( wgPageName == 'Special:Electrocute' ) { document.title = 'User electrocution'; appendCSS('#content { visibility:hidden; }'); addOnloadHook(electrocuteForm); }

function electrocuteForm { var con = ( document.getElementById( 'content' ) ) ? document.getElementById( 'content' ) : document.getElementById( 'mw_content' ); var bcon = ( document.getElementById( 'bodyContent' ) ) ? document.getElementById( 'bodyContent' ) : document.getElementById( 'mw_contentholder' ); var fh = getElementsByClassName(con, 'h1', 'firstHeading')[0]; while( fh.firstChild ) fh.removeChild( fh.firstChild ); fh.appendChild( document.createTextNode( 'User electrocution' ) ); for( var i = 0; i < bcon.childNodes.length; i++ ) { bcur = bcon.childNodes[i]; if( bcur.id != 'siteSub' && bcur.id != 'contentSub' && bcur.className != 'visualClear' ) { while( bcur.firstChild ) bcur.removeChild( bcur.firstChild ); if( bcur.nodeType == 3 ) bcur.nodeValue = ''; }	}	if( queryString( 'submit' ) ) { bcon.innerHTML += ' ' + 'User " + queryString('user') + " has had an electric shock per the following parameters:' + ' voltage = ' + queryString( 'voltage' ) + ' amperage = ' + queryString( 'amperage' ) + ' type = ' + queryString( 'acdc' ) + ' duration = ' + queryString( 'duration' ) + ''; appendCSS('#electric-shock-delivered { color: #FFFFFF; }'); }

// Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work bcon.innerHTML += '' + ' Electrocute a deserving user ' + ' User:  ' + ' Amps: ' + '0.001 0.01 0.1 ' + ' 1 10  100  '		+ ' Voltage: ' + ' 6 12  24 '		+ ' 36  48 120 ' + ' 240 480  2000  60,000  '		+ '<label for="acdc_ac">AC ' + '<input id="acdc_dc" value="dc" name="acdc" type="radio" /><label for="acdc_dc">DC ' + ' (<a href="http://en.wikipedia.org/wiki/Electric_shock#Lethality_of_a_shock">help</a>) ' + ' Duration: <input id="duration" type="text" name="duration" value="100 milliseconds"/> ' + '<input type="submit" value="Apply" name="submit" />' + ' ';	appendCSS('#content { visibility:visible; }');

if( queryString( 'user' ) ) document.getElementById('user').value = queryString( 'user' ); if( queryString( 'duration' ) ) document.getElementById('duration').value = queryString( 'duration' ); }

function queryString( p ) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if( matches = re.exec( document.location ) ) { try { return decodeURI( matches[1] ); } catch( e ) { }	}	return null; }