Javascript fgv végrehajtódásánál az oldal tetejére ugrik valamiért?
function addPoint(type)
{
if(freepoints > 0)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "functions/addpoint.php?type=" + type, true);
xmlhttp.send();
document.getElementById("freepoints").innerHTML = --freepoints;
if(freepoints == 0)
{
document.getElementById("table").deleteRow(10);
for(var i=0;i<5;i++)
document.getElementById(i).deleteCell(2);
}
if(array["bonus"+type] != 0)
{
strtext = "<font color=\"#12f004\">"+(++array[type]+array["bonus"+type])+"</font>";
bonustext = "Item(s): <font color=\"#12f004\">+"+array["bonus"+type]+"</font><br>";
}
else
{
strtext = ++array[type];
bonustext="";
}
document.getElementById(type).innerHTML = strtext;
if(type === "agi")
{
var crit = Math.round(Math.sqrt(array[type]+array["bonus"+type])*25*<?php echo CRIT_CHANCE_RATE; ?>/(1+<?php echo $level; ?>*0.25)*<?php echo MAX_LEVEL; ?>/100);
document.getElementById("crit").innerHTML = crit+" %";
document.getElementById(type).setAttribute("data-tip","<span class=\"info\">Base: "+array[type]+"<br>"+bonustext+"Determines critical hit chance. <font color=\"#12f004\">("+crit+"%)</font></span>");
}
else if(type === "int")
{
document.getElementById(type).setAttribute("data-tip","<span class=\"info\">Base: "+array[type]+"<br>"+bonustext+"Determines maximum mana and spell power. <font color=\"#12f004\">(Under Developement)</font></span>");
}
else if(type === "spi")
{
var regen = Math.round(Math.sqrt(array[type]+array["bonus"+type])*7*<?php echo HP_REGEN_RATE; ?> /(1+<?php echo $level; ?>*0.25)* <?php echo MAX_LEVEL; ?>/1000*12);
document.getElementById("hpregen").innerHTML = ""+(regen+<?php echo $hprbonus; ?>)+" % / h";
document.getElementById("energyregen").innerHTML = ""+(regen+<?php echo $erbonus; ?>)+" % / h";
document.getElementById(type).setAttribute("data-tip","<span class=\"info\">Base: "+array[type]+"<br>"+bonustext+"Determines health and energy regeneration. <font color=\"#12f004\">("+regen+"% per hour)</font></span>");
}
else if(type === "sta")
{
var maxhealth = (array[type]+array["bonus"+type])*15;
var health = <?php echo $health; ?>;
var percent = Math.round((health/maxhealth)*100);
document.getElementById("hp").innerHTML = "<div title='Health: "+percent+" %' style='position: relative;width: 100%;text-align: center;background-color: #000;border-radius: 4px;z-index: 1;'><div align='center' style='position: absolute;left: 0; top: 0; bottom: 0;background-color: #00BB22;border-radius: 4px;z-index: 2; width:"+percent+"%;'></div><span style='position: relative;z-index: 3;'>"+health+"/"+maxhealth+"</span></div>";
document.getElementById("headerhp").innerHTML = "<div title='Health: "+health+"/"+maxhealth+"' style='position: relative;width: 100%;text-align: center;background-color: #000;border-radius: 4px;z-index: 1;'><div align='center' style='position: absolute;left: 0; top: 0; bottom: 0;background-color: #00BB22; border-radius: 4px;z-index: 2; width:"+percent+"%;'></div><span style='position: relative;z-index: 3;'>"+percent+"%</span></div>";
document.getElementById(type).setAttribute("data-tip","<span class=\"info\">Base: "+array[type]+"<br>"+bonustext+"Determines maximum health. <font color=\"#12f004\">("+maxhealth+")</font></span>");
}
else if(type === "str")
{
var maxdmg = <?php echo $maxdmg;?>;
var mindmg = <?php echo $mindmg;?>;
var bonusmindmg=Math.round(mindmg*(array[type]+array["bonus"+type])/1000);
bonusmindmg+=Math.round((array[type]+array["bonus"+type])/5);
var bonusmaxdmg=Math.round(maxdmg*(array[type]+array["bonus"+type])/1000);
bonusmaxdmg+=Math.round((array[type]+array["bonus"+type])/5);
document.getElementById("dmg").setAttribute("data-tip","<span class=\"info\">Base: "+mindmg+"-"+maxdmg+"<br>Strenght: <font color=\"#12f004\">+"+((array[type]+array["bonus"+type])/5)+"</font> and <font color=\"#12f004\">+"+((array[type]+array["bonus"+type])/10)+"% ("+Math.round(maxdmg*(array[type]+array["bonus"+type])/1000)+")</font> of base damage<br></span>");
if(bonusmindmg == 0 && bonusmaxdmg == 0) document.getElementById("dmg").innerHTML = ""+mindmg+"-"+maxdmg;
else document.getElementById("dmg").innerHTML = "<font color=\"#12f004\">"+(mindmg+bonusmindmg)+"-"+(maxdmg+bonusmaxdmg)+"</font>";
document.getElementById(type).setAttribute("data-tip","<span class=\"info\">Base: "+array[type]+"<br>"+bonustext+"Increases physical damage by <font color=\"#12f004\"> "+((array[type]+array["bonus"+type])/5)+"</font> and <font color=\"#12f004\"> "+((array[type]+array["bonus"+type])/10)+"% ("+Math.round(maxdmg*(array[type]+array["bonus"+type])/1000)+")</font> of base damage.</span>");
}
}
}
Igen.
<a onclick='addPoint(\"agi\")' href='#'></a>
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!