MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ $(function {   var calculator_btn_m = function(o) {            $(o).prev.val(parseInt($(o).prev.val, 10) - 1);            $(o).prev.keyup;        },        calculator_btn_p = function(o) {            $(o).prev.prev.val(parseInt($(o).prev.prev.val, 10) + 1);            $(o).prev.prev.keyup;        };    /*Exp*/    (function { $('#calculator_exp') .append('Level: ') .append(' ') .append($('').click(function { calculator_btn_m(this); })).append(' ') .append($('').click(function { calculator_btn_p(this); }))           .append('

 ')           .append('' + 'Retro Hardcore PvP ')            .append(' ');        $('#calculator_expi1').keyup(function { if ($(this).val === '') { $(this).val(1).select; }           var exp, nextexp, totalxploss, fivebloss, fiveblossp, sevenbloss, sevenblossp, lvl = Math.abs(parseInt($(this).val, 10) || 1), prot = 0.08; $(this).val(lvl); exp = (50 * Math.pow(lvl - 1, 3) - 150 * Math.pow(lvl - 1, 2) + 400 * (lvl - 1)) / 3; nextexp = String(((50 * Math.pow(lvl, 3) - 150 * Math.pow(lvl, 2) + 400 * (lvl)) / 3) - exp); nextexp = nextexp.replace(/\B(?=(\d{3})+(?!\d))/g, ","); if ($('#death_rh').prop('checked')) { prot = 0.0631; }           totalxploss = Math.round((lvl + 50) * (lvl * lvl - 5 * lvl + 8) / 2); fivebloss = totalxploss * (1 - 0.3 - 5 * prot); fiveblossp = Math.round(100 * 100 * fivebloss / exp) / 100; sevenbloss = totalxploss * (1 - 0.3 - 7 * prot); sevenblossp = Math.round(100 * 100 * sevenbloss / exp) / 100; exp = String(exp).replace(/\B(?=(\d{3})+(?!\d))/g, ","); fivebloss = String(Math.round(fivebloss)).replace(/\B(?=(\d{3})+(?!\d))/g, ","); sevenbloss = String(Math.round(sevenbloss)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");

var min_share_lvl = Math.floor((lvl / 3) * 2); var max_share_lvl = Math.ceil((lvl / 2) * 3); max_share_lvl += lvl % 2 === 0 ? 1 : 0;           // The share range is always calculated from the higher level rounding down. // For this reason, the max share level for even levels is underestimated. // For example: a level 151 can share with a level 100 even though 100 * (3/2) = 150. $('#calculator_expr1').html(               'Total level XP: ' + exp + ' ' +                'Next level XP: ' + nextexp + '  ' +                'Death XP Loss (5 blessings): ' + fivebloss + ' (' + fiveblossp + '%) ' +                'Death XP Loss (7 blessings): ' + sevenbloss + ' (' + sevenblossp + '%) ' +                ' promoted characters with 100% to next level  '            ); $('#calculator_expr2').html(               'Minimum level to share experience: ' + min_share_lvl + ' ' +                'Maximum level to share experience: ' + max_share_lvl + ''            ); });       $('#death_rh').change(function { $('#calculator_expi1').keyup; });       $('#calculator_expi1').keyup;    });

/*Stats*/ (function {       var x, tmp = '',            calculator_stats_voc = {                'Druid': [5, 30, 10],                'Knight': [15, 5, 25],                'Paladin': [10, 15, 20],                'Sorcerer': [5, 30, 10],                'Rookstayer': [5, 5, 10]            }, //[hp, mana, cap]

calculator_stats_update = function { var x, lvl; for (x = 2; x <= 4; x++) { if ($('#calculator_statsi' + x).val === '') { $('#calculator_statsi' + x).val(8).select; }                   $('#calculator_statsi' + x).val(Math.abs(parseInt($('#calculator_statsi' + x).val, 10) || 8)); }               lvl = parseInt($('#calculator_statsi2').val, 10); x = calculator_stats_voc[$('#calculator_statsi1').val][0]; $('#calculator_statsr1').text(145 + (5 * Math.min(8, lvl)) + (Math.max(0, lvl - 8) * x)); x = calculator_stats_voc[$('#calculator_statsi1').val][1]; $('#calculator_statsr2').text(50 + (5 * Math.min(8, lvl)) + (Math.max(0, lvl - 8) * x)); x = calculator_stats_voc[$('#calculator_statsi1').val][2]; $('#calculator_statsr3').text(390 + (10 * Math.min(8, lvl)) + (Math.max(0, lvl - 8) * x)); $('#calculator_statsr4').text(109 + (lvl)); };

for (x in calculator_stats_voc) { if (calculator_stats_voc.hasOwnProperty(x)) { tmp += '' + x + ' '; }       }        $('#calculator_stats').html(            ' '        );

$('#calculator_statsi2').keyup(calculator_stats_update) .next.click(function {               calculator_btn_m(this);                calculator_stats_update;            }) .next.click(function {               calculator_btn_p(this);                calculator_stats_update;            }); $('#calculator_statsi1').change(calculator_stats_update); calculator_stats_update; });   /*Loot Bonus*/    (function { $('#calculator_lootbonus') .append(' ') .append(' ') .append('Boss Points: ') .append('') .append(' ') .append('Equipment Loot Bonus: 25% ') .append(' ' +					' ' +           		'  '); bonus_for_points = function(points) { var bonus = 0; if (points < 250) { bonus = Math.floor(25 + points/10); } else if (points < 1250) { bonus = Math.floor(37.5 + points/20); } else { bonus = Math.floor(100 + 0.5 * (Math.sqrt(8 * ((points - 1250) / 5) + 81) - 9)); }       	return bonus; };       points_for_next = function(points) { var points_next = 10, bonus = bonus_for_points(points); if (points < 240) { points_next = 10 * Math.floor(points/ 10) + 10; } else if (points < 1250) { points_next = 20 * Math.floor((points - 250)/ 20) + 20 + 250; } else { points_next = 2.5 * Math.pow(bonus + 1, 2) - 477.5 * (bonus + 1) + 24000; }       	return points_next; };       $('#calculator_lootbonus_points').on('change keyup keypress',function {        	var points = this.value,        	bonus = bonus_for_points(points),        	points_next = points_for_next(points);        	$('#calculator_lootbonus_bonus').html('Current Equipment Loot Bonus: ' + bonus + '%');        	var points_arr = [points_next];        	$('#calculator_lootbonus_next table tbody').empty;        	for (i = bonus + 1; i < bonus + 4; i++) {        		$('#calculator_lootbonus_next table tbody')        			.append('  ' + i + '%  ' + points_next + '  ' + (points_next - points) + '  ');    			points_next = points_for_next(points_arr[points_arr.length - 1]);        		points_arr.push(points_next);        	}        }); });   $('#calculators_loading').hide;    $('#calculators_container').show; });