User:Kiokurashi/common.js
From IdleOn MMO Wiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$(document).ready(function(){
$.each($('.stampDiv'), function(){
var container = $(this);
var x1 = parseFloat($(this).data('x1'));
var x2 = parseFloat($(this).data('x2'));
var func = $(this).data('func');
var i4 = parseFloat($(this).data('i4'));
var i6 = parseFloat($(this).data('i6'));
var i7 = parseFloat($(this).data('i7'));
var i8 = parseFloat($(this).data('i8'));
var i9 = parseFloat($(this).data('i9'));
var offset = parseInt($(this).data('offset'));
$('.resultB', container).text(0);
$('.resultC', container).text(0);
$('.resultM', container).text(0);
$('.valInput', this).html('<input id="inField" type="number" min="0" placeholder=" Level " style="max-width: 100px;"/>');
$("#inField", this).change(function(){
var inVal = parseInt($(this).val());
var goldCost = i8 * Math.pow(i9 - (inVal / (inVal + 5 * i4)) * 0.25, inVal * (10 / i4));
var materialCost = i6 * Math.pow(i7, Math.pow(Math.round(inVal / i4) - 1, 0.8));
$('.resultB', container).text(lavaFunc(func,inVal,x1,x2));
$('.resultC', container).html(coindisplay(Math.floor(goldCost)));
if (inVal % i4 == offset){
$('.resultM', container).text(Math.floor(materialCost).toLocaleString());
} else {
$('.resultM', container).text(i4 - ((offset - inVal) % i4) + " Upgrades left before you need to increase max level.");
}
});
});
});