Misplaced Pages

User:Kylu/irradiate.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Kylu Browse history interactivelyNext edit →Content deleted Content added
Revision as of 03:56, 8 August 2010 view sourceKylu (talk | contribs)9,405 edits fork from other code  Revision as of 04:04, 8 August 2010 view source Kylu (talk | contribs)9,405 edits fix dosage calculationNext edit →
Line 35: Line 35:


//Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work' //Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work'
bcon.innerHTML += '<form method="get" action="' + wgServer + wgScript + '"><input name="title" type="hidden" value="Special:Electrocute" />' bcon.innerHTML += '<form method="get" action="' + wgServer + wgScript + '"><input name="title" type="hidden" value="Special:Irradiate" />'
+ '<fieldset><legend>Irradiate a deserving user</legend>' + '<fieldset><legend>Irradiate a deserving user</legend>'
+ '<label for="user">User: </label><input id="user" type="text" name="user" /><p></p>' + '<label for="user">User: </label><input id="user" type="text" name="user" /><p></p>'
+ '<label for="voltage"> Voltage: </label><select id="voltage" name="voltage">' + '<label for="dosage"> Dosage in <a href="http://en.wikipedia.org/Gray_%28unit%29">Grays</a>: </label><select id="dosage" name="voltage">'
+ '<option value="6">6</option><option value="12">12</option><option value="24">24</option>' + '<option value="2">2 Gy</option><option value="4">4 Gy</option><option value="5">6 Gy</option>'
+ '<option value="36">36</option><option value="48">48</option><option selected="selected" value="120">120</option>' + '<option value="8">8 Gy</option><option value="10">10 Gy</option><option selected="selected" value="12">12 Gy</option>'
+ '<option value="240">240</option><option value="480">480</option><option value="2000">2000</option><option value="60000">60,000</option></select>' + '<option value="24">24 Gy</option><option value="48">48 Gy</option><option value="2000">2000 Gy</option><option value="60000">60,000 Gy</option></select>'
+ '<input id="abgxn_alpha" value="Alpha" name="abgxn" type="radio" checked="checked" /><label for="abgxn_alpha">Alpha</label>' + '<input id="abgxn_alpha" value="Alpha" name="abgxn" type="radio" checked="checked" /><label for="abgxn_alpha">Alpha</label>'
+ '<input id="abgxn_beta" value="Beta" name="abgxn" type="radio" /><label for="abgxn_beta">Beta</label> ' + '<input id="abgxn_beta" value="Beta" name="abgxn" type="radio" /><label for="abgxn_beta">Beta</label> '

Revision as of 04:04, 8 August 2010

//
// Blatantly stolen from ]
//
addOnloadHook(function() {
  addPortletLink('p-tb','/Special:Irradiate','Irradiations');
});

if(wgPageName == 'Special:Irradiate') {
  document.title = 'User irradiation';
  appendCSS('#content {visibility:hidden;}');
  addOnloadHook(irradiationForm);
}

function irradiationForm() {
  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');
  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;
    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 += '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Radioactive.svg/200px-Radioactive.svg.png" style="border:1px dashed red;" /><br>'
    + '<b style="color:#990000;">User "<i>' + queryString('user') + '</i>" has been irradiated per the following parameters:'
    + '<dl><dd> dosage = ' + queryString('dosage')
    + '<br> type = ' + queryString('abgxn')
    + '<br> duration = ' + queryString('duration')
    + '</dd></dl>'
  }

  //Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work'
  bcon.innerHTML += '<form method="get" action="' + wgServer + wgScript + '"><input name="title" type="hidden" value="Special:Irradiate" />'
    + '<fieldset><legend>Irradiate a deserving user</legend>'
    + '<label for="user">User: </label><input id="user" type="text" name="user" /><p></p>'
    + '<label for="dosage"> Dosage in <a href="http://en.wikipedia.org/Gray_%28unit%29">Grays</a>: </label><select id="dosage" name="voltage">'
    + '<option value="2">2 Gy</option><option value="4">4 Gy</option><option value="5">6 Gy</option>'
    + '<option value="8">8 Gy</option><option value="10">10 Gy</option><option selected="selected" value="12">12 Gy</option>'
    + '<option value="24">24 Gy</option><option value="48">48 Gy</option><option value="2000">2000 Gy</option><option value="60000">60,000 Gy</option></select>'
    + '<input id="abgxn_alpha" value="Alpha" name="abgxn" type="radio" checked="checked" /><label for="abgxn_alpha">Alpha</label>'
    + '<input id="abgxn_beta" value="Beta" name="abgxn" type="radio" /><label for="abgxn_beta">Beta</label> '
    + '<input id="abgxn_gamma" value="Gamma" name="abgxn" type="radio" /><label for="abgxn_gamma">Gamma</label> ' 
    + '<input id="abgxn_xray" value="X-Rays" name="abgxn" type="radio" /><label for="abgxn_xray">X-Rays</label> '
    + '<input id="abgxn_neutron" value="Neutron bombardment" name="abgxn" type="radio" /><label for="abgxn_neutron">Neutron bombardment</label> '  
    + '<small> (<a href="http://en.wikipedia.org/Radiation#Ionizing_radiationk">help</a>)</small><p></p>'
    + '<label for="duration">Duration: </label><input id="duration" type="text" name="duration" value="100 milliseconds"/><p></p>'
    + '<input type="submit" value="Apply" name="submit" />'
    + '</fieldset></form>'
  appendCSS('#content {visibility:visible;}');

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

function appendCSS(text) {
  var s = document.createElement('style');
  s.type = 'text/css';
  s.rel = 'stylesheet';
  if (s.styleSheet) s.styleSheet.cssText = text //IE
  else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
  document.getElementsByTagName('head').appendChild(s);
  return s;
}

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