User:Kiokurashi/common.js: Difference between revisions

From IdleOn MMO Wiki
imported>Kiokurashi
No edit summary
mNo edit summary
 
(72 intermediate revisions by 2 users not shown)
Line 1: Line 1:
function coindisplay(coins) {
// $(document).ready(function(){
    var n = coins;
// var element = document.createElement("p"); // "p" is the type of element that will be created
    var ret = '';
// element.style = "color:blue"; // to modify attributes to the element that will be created, just type element.(attribute you want to modify) = "whatever value"
    const imgs = ["4/43/Copper", "4/4e/Silver", "1/1f/Gold", "2/2c/Platinum", "5/53/Dementia",
// element.contentText = "Text Here"; // this sets the innerHTML of the element that will be created to "Paragraph text"
    "d/d5/Void_Coin.png/22px-Void", "1/11/Lustre_Coin.png/22px-Lustre",  
// document.getElementById('firstHeading').appendChild(element); // this adds the element to the page content
    "8/83/Starfire_Coin.png/22px-Starfire", "8/8b/Dreadlo_Coin.png/22px-Dreadlo",
// });
    "e/e6/Godshard_Coin.png/22px-Godshard"];
$(document).ready(function(){
    var i = 18;
var personalExtra = document.getElementById('personal-extra');
var pExtraUList = personalExtra.querySelector('ul');
var darkmodeElement = document.createElement('li');
var darkmodeLink = document.createElement('a');
var darkmodeIcon = document.createElement('img');
darkmodeLink.setAttribute('href', '#');
darkmodeLink.setAttribute('id', 'pt-darkmode-icon');
darkmodeLink.setAttribute('class', 'ext-darkmode-link');
darkmodeIcon.setAttribute('src','https://idleon.wiki/wiki/images/8/8d/Minuteglass.png');
darkmodeLink.appendChild(darkmodeIcon);
darkmodeElement.appendChild(darkmodeLink);
pExtraUList.appendChild(darkmodeElement);
});
/*
var a = document.createElement("a");
var ulist = document.getElementById("list1");
var newItem = document.createElement("li");


    do {
a.textContent = "...ooo";
        var len = n.length;
a.setAttribute('href', "http://www.msn.com");
        if (len > i) {
newItem.appendChild(a);
            var num = parseInt(n.substring(0, len - i));
ulist.appendChild(newItem);
            if (num > 0) {
                ret += "<img src=https://static.miraheze.org/idleonwiki/" + imgs[(i/2)] +
                "_Coin.png>" + num + " ";
            }
            n = n.substring(len - i);
        }
        i -= 2;
    }
    while(i > 0);


    return ret;
var el = document.createElement('img')
}
el.setAttribute('src','images/s2.jpg')
 
*/
$(document).ready(function(){
console.log("UPDATED22");
    $.each($('.skillDiv'), function(){
    var container = $(this);
    var x1 = parseFloat($(this).data('x1'));
    var x2 = parseFloat($(this).data('x2'));
    var max = parseFloat($(this).data('max'));
    var func1 = $(this).data('func1');
    var y1 = parseFloat($(this).data('y1'));
    var y2 = parseFloat($(this).data('y2'));
    var func2 = $(this).data('func2');
    $('.result1', container).text(0);
    $('.result2', container).text(0);
    $('.valInput', this).html('(<input id="inField" type="number" min="0" max="'+max+'" placeholder=" Level "/>) ');
    $("#inField", this).change(function(){
    var inVal = parseInt($(this).val());
    $('.result1', container).text(lavaFunc(func1,inVal,x1,x2));
    $('.result2', container).text(lavaFunc(func2,inVal,y1,y2));
    });
    });
    $.each($('.guildBonusDiv'), function(){
    var container = $(this);
    var x1 = parseFloat($(this).data('x1'));
    var x2 = parseFloat($(this).data('x2'));
    var max = parseFloat($(this).data('max'));
    var func1 = $(this).data('func');
    var baseC = parseFloat($(this).data('basec'));
    var incC = parseFloat($(this).data('incc'));
    $('.result1', container).text(0);
    $('.result2', container).text(0);
    $('.cost', container).text(baseC);
    $('.valInput', this).html('(<input id="inField" type="number" min="0" max="'+max+'" placeholder=" Level "/>) ');
    $("#inField", this).change(function(){
    var inVal = parseInt($(this).val());
    $('.result1', container).text(lavaFunc(func1,inVal,x1,x2));
    $('.result2', container).text(10+inVal);
    $('.cost', container).text(baseC + inVal*incC);
    $('.tcost', container).text(getCostTotal(baseC,inVal,incC));
    });
    });
    $.each($('.boxDiv'), function(){
        var container = $(this);
        var func1 = $(this).data('func1');
        var x1 = $(this).data('x1');
        var x2 = $(this).data('x2');
        var func2 = $(this).data('func2');
        var y1 = $(this).data('y1');
        var y2 = $(this).data('y2');
        var func3 = $(this).data('func3');
        var z1 = $(this).data('z1');
        var z2 = $(this).data('z2');
        $('.result1', container).text(0);
        $('.result2', container).text(0);
        $('.result3', 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());
            $('.result1', container).text(Math.max(0,lavaFunc(func1,inVal,x1,x2)));
            $('.result2', container).text(Math.max(0,lavaFunc(func2,inVal-25,y1,y2)));
            $('.result3', container).text(Math.max(0,lavaFunc(func3,inVal-100,z1,z2)));
        });
});
    $.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'));
    $('.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 == 0){
    $('.resultM', container).text(Math.floor(materialCost).toLocaleString());
    } else {
    $('.resultM', container).text(i4 - (inVal % i4) + " Upgrades left before you need to increase max level.");
    }
    });
    });
$.each($('.prayerDiv'), function(){
    var container = $(this);
    var bonus = parseInt($(this).data('bonus'));
    var curse = parseInt($(this).data('curse'));
    var multiplier = parseInt($(this).data('mult'));
    var id = parseInt($(this).data('id'));
    $('.result1', container).text(bonus);
    $('.result2', container).text(curse);
    $('.result3', container).text(0);
    $('.valInput', this).html('<input id="inField" type="number" min="1" placeholder=" Level " style="max-width: 100px;"/>');
    $("#inField", this).change(function(){
    var inVal = parseInt($(this).val());
    $('.result1', container).text(bonus + (bonus *(inVal - 1))/10);
    $('.result2', container).text(curse + (curse *(inVal - 1))/10);
    $('.result3', container).text(
    Math.round(multiplier * (1 + (4 + (id/25)) * inVal)).toLocaleString()
    );
    });
    });
    $.each($('.gfoodDiv'), function(){
    var container = $(this);
    var amount = parseFloat($(this).data('amount'));
    $('.result', container).text(0);
    $('.valInput', this).html('<input id="inField" type="number" min="0" placeholder=" Quantity " style="max-width: 100px;"/>');
    $("#inField", this).change(function(){
    var inVal = parseInt($(this).val());
    $('.result', container).text(goldFoodBonus(amount,inVal));
    });
    });
    $.each($('.statueDiv'), function(){
    var container = $(this);
    var perLv = parseFloat($(this).data('amount'));
    $('.result1', container).text(0);
    $('.result2', 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());
    $('.result1', container).text(round(inVal*perLv));
    $('.result2', container).text(Math.round(Math.pow(inVal,1.17)*Math.pow(1.35,inVal/10)+1) + " Required statues to level this bonus.");
    });
    });
    $.each($('.cauldDiv'), function(){
    var cauldCostReduxLvl = 0
    var bubbleCostBubbleLvl = 0
    var bubbleCostVialLvl = 0
    var bubbleBargainLvl = 0
    var bubbleMultClassLvl = 0
    var shopBargainBought = 0
    $('.cauldCostReduxLvlInput', this).html('<input id="inCauldCostReduxLvl" type="number" min="0" placeholder=" Level "/>');
    $('.bubbleCostBubbleInput', this).html('<input id="inBubbleCostBubbleLvl" type="number" min="0" placeholder=" Level "/>');
    $('.bubbleCostVialInput', this).html('<input id="inBubbleCostVialLvl" type="number" min="0" placeholder=" Level "/>');
    $('.bubbleMultClassInput', this).html('<input id="inBubbleMultClassLvl" type="number" min="0" placeholder=" Level "/>');
    $('.bubbleBargainInput', this).html('<input id="inBubbleBargainLvl" type="number" min="0" placeholder=" Level "/>');
    $('.shopBargainInput', this).html('<input id="inShopBargainBought" type="number" min="0" placeholder=" Level "/>');
    $("#inCauldCostReduxLvl", this).change(function(){
    cauldCostReduxLvl = parseInt($(this).val());
    });
    $("#inBubbleCostBubbleLvl", this).change(function(){
    bubbleCostBubbleLvl = parseInt($(this).val());
    });
    $("#inBubbleCostVialLvl", this).change(function(){
    bubbleCostVialLvl = parseInt($(this).val());
    });
    $("#inBubbleBargainLvl", this).change(function(){
    bubbleBargainLvl = parseInt($(this).val());
    });
    $("#inBubbleMultClassLvl", this).change(function(){
    bubbleMultClassLvl = parseInt($(this).val());
    });
    $("#inShopBargainBought", this).change(function(){
    shopBargainBought = parseInt($(this).val());
    });
    $.each($('.bubbleDiv'), function(){
    var container = $(this);
    var baseCost = $(this).data('basecost').split(',')
    var isLiquid = $(this).data('isliquid').split(',')
    var x1 = parseFloat($(this).data('x1'));
    var x2 = parseFloat($(this).data('x2'));
    var func = $(this).data('func');
    $('.valInput', this).html('<input id="inField" type="number" min="0" placeholder=" Level "/>');
    for(i=0;i<baseCost.length;i++){
var div = '.material' +(i+1);
$(div, container).text(0);
}
$(".bonusOut", container).text(0);
    $("#inField", this).change(function(){
    var inVal = parseInt($(this).val());
for(i=0;i<baseCost.length;i++){
var div = '.material' +(i+1);
var cost = calcBubbleMatCost(
inVal,
parseInt(baseCost[i]),
isLiquid[i],
cauldCostReduxLvl,
bubbleCostBubbleLvl,
bubbleCostVialLvl,
bubbleBargainLvl,
bubbleMultClassLvl,
shopBargainBought
);
$(div, container).html('<div class="tooltip"> ' + nFormatter(cost,2) + '<span>' + cost + '</span></div>')
}
$(".bonusOut", container).text(round(lavaFunc(func,inVal,x1,x2)))
    });
    });
    });
});

Latest revision as of 19:25, 11 June 2023

// $(document).ready(function(){
// 	var element = document.createElement("p"); // "p" is the type of element that will be created
// 	element.style = "color:blue"; // to modify attributes to the element that will be created, just type element.(attribute you want to modify) = "whatever value"
// 	element.contentText = "Text Here"; // this sets the innerHTML of the element that will be created to "Paragraph text"
// 	document.getElementById('firstHeading').appendChild(element); // this adds the element to the page content
// });
$(document).ready(function(){
	var personalExtra = document.getElementById('personal-extra');
	var pExtraUList = personalExtra.querySelector('ul');
	var darkmodeElement = document.createElement('li');
	var darkmodeLink = document.createElement('a');
	var darkmodeIcon = document.createElement('img');
	darkmodeLink.setAttribute('href', '#');
	darkmodeLink.setAttribute('id', 'pt-darkmode-icon');
	darkmodeLink.setAttribute('class', 'ext-darkmode-link');
	darkmodeIcon.setAttribute('src','https://idleon.wiki/wiki/images/8/8d/Minuteglass.png');
	
	darkmodeLink.appendChild(darkmodeIcon);
	darkmodeElement.appendChild(darkmodeLink);
	pExtraUList.appendChild(darkmodeElement);
});
/*
var a = document.createElement("a");
var ulist = document.getElementById("list1");
var newItem = document.createElement("li");

a.textContent = "...ooo";
a.setAttribute('href', "http://www.msn.com");
newItem.appendChild(a);
ulist.appendChild(newItem);

var el = document.createElement('img')
el.setAttribute('src','images/s2.jpg')
*/