User:Jens Ingels/common.js

$( document ).ready(function {

if ( wgPageName == 'Miss_Fortune' ) {

//Prepare Arrays var name = ["Health","Health regeneration","Mana","Mana regeneration","Range","Attack damage","Attack speed","Armor","Magic resistance","Movement speed"];

//Test Load Function $( "#Strut" ).append( " Test " );

//Def Classes $.each(name, function( index, val ) {

loc = $( "#champion_info-lower td span a[title='"+ val + "']").parent.parent.next; valueCode = val.toLowerCase.replace(/ /g,"_"); value = loc.html; $( loc ).addClass( "data-" + valueCode ); defCode = value.replace(/\(.*?\)/, ' $& '); $(".data-" + valueCode).html(defCode);

});

//Add buttons $( "#champion_info-lower td:nth-child(2) table th").append( " Lv default 1 2 3 4 5 6 7 8 9 10 11 12 13 <option value='14'>14 <option value='15'>15 <option value='16'>16 <option value='17'>17 <option value='18'>18 " ); healthDefault = $( ".data-health" ).html; health_regenerationDefault = $( ".data-health_regeneration" ).html; manaDefault = $( ".data-mana" ).html; mana_regenerationDefault = $( ".data-mana_regeneration" ).html; rangeDefault = $( ".data-range" ).html; attack_damageDefault = $( ".data-attack_damage" ).html; attack_speedDefault = $( ".data-attack_speed" ).html; armorDefault = $( ".data-armor" ).html; magic_resistanceDefault = $( ".data-magic_resistance" ).html; movement_speedDefault = $( ".data-movement_speed" ).html;

callBase = function(value) { mainVal = $( ".data-" + value ).contents.filter(function {        return this.nodeType == 3;         }).text; mainVal = parseFloat(mainVal); return mainVal; };

callPlus = function(value) { plusVal = $( ".data-" +value+ " span" ).html; plusVal = plusVal.substring(1, plusVal.length-1) if(plusVal[plusVal.length - 1] === '%') { plusVal = parseFloat(plusVal); plusVal = plusVal/100; }        else {           plusVal = parseFloat(plusVal); }        return plusVal; };

var health = { base : callBase("health"), plus : callPlus("health"), backup : $( ".data-health" ).html },         health_regeneration = { base : callBase("health_regeneration"), plus : callPlus("health_regeneration"), backup : $( ".data-health_regeneration" ).html },         mana = { base : callBase("mana"), plus : callPlus("mana"), backup : $( ".data-mana" ).html },	         mana_regeneration = { base : callBase("mana_regeneration"), plus : callPlus("mana_regeneration"), backup : $( ".data-mana_regeneration" ).html },         range = { base : callBase("range"), plus : callPlus("range"), backup : $( ".data-range" ).html },         attack_damage = { base : callBase("attack_damage"), plus : callPlus("attack_damage"), backup : $( ".data-attack_damage" ).html },         attack_speed = { base : callBase("attack_speed"), plus : callPlus("attack_speed"), backup : $( ".data-attack_speed" ).html };     alert(range.plus + " " + health.backup);

mainVal = $( ".data-health" ).contents.filter(function {        return this.nodeType == 3;      }).text; mainVal = parseFloat(mainVal); plusVal = $( ".data-health span" ).html; plusVal = plusVal.substring(1, plusVal.length-1) if(plusVal[plusVal.length - 1] === '%') { plusVal = parseFloat(plusVal); plusVal = plusVal/100; }     else {        plusVal = parseFloat(plusVal); }

mainValB = $( ".data-magic_resistance" ).contents.filter(function {        return this.nodeType == 3;      }).text; mainValB = parseFloat(mainValB); plusValB = $( ".data-magic_resistance span" ).html; plusValB = plusValB.substring(1, plusValB.length-1) if(plusValB[plusValB.length - 1] === '%') { plusValB = parseFloat(plusValB); plusValB = plusValB/100; }     else {        plusValB = parseFloat(plusValB); }

$( "#lv" ) .change(function {

getLevel = $("#lv").val; getLevel = parseInt(getLevel); if (getLevel == 0) { sendA = healthDefault; sendB = magic_resistance.backup; }        else {        sendA = mainVal + plusVal * (getLevel - 1); sendB = mainValB + plusValB * (getLevel - 1); }        $( ".data-health" ).html(sendA); $( ".data-magic_resistance" ).html(sendB);

});  }

});