User:Sonicwave/xp-calculator.js

$(function {	if (mw.config.get( 'wgPageName' ) !== 'User:Sonicwave32/XP_calculator') return;	$("#no-xp-calc").remove;	calcHTML = ' '	+ ' '	+ '  Hostile '	+ '  '	+ '  Passive '	+ '  Health: '	+ '   '	+ '  Damage: '	+ '   '	+ '  Armor: '	+ '   '	+ '   '	+ ' ';	$("#xp-calc").html(calcHTML);	$("#xp-calc-hostile").click(function { $("#xp-calc-armor").attr('disabled', false); $("#xp-calc-damage").attr('disabled', false); });	$("#xp-calc-passive").click(function { $("#xp-calc-armor").attr('disabled', true); $("#xp-calc-damage").attr('disabled', true); });	$("#xp-calc").on("submit", function { var health = parseFloat($("#xp-calc-health").val); var armor = parseFloat($("#xp-calc-armor").val); var damage = parseFloat($("#xp-calc-damage").val); if (isNaN(health)) { health = 0; $("#xp-calc-health").val(0); }		if (isNaN(armor)) { armor = 0; $("#xp-calc-armor").val(0); }		if (isNaN(damage)) { damage = 0; $("#xp-calc-damage").val(0); }		var xp; if ($('input[name="xp-calc-type"]:checked').val == "passive") { xp = Math.floor(Math.floor(health) / 25); }		else { xp = Math.floor(5 + (health + armor * 1.75 + damage * 2) / 10); }		$("#xp-calc-result").remove; // remove old result $("#xp-calc").after('XP: ' + xp + ' '); return false; // prevent page reloading }); });