Techious
http://www.techious.com/forums/

The Haste Calculator
http://www.techious.com/forums/viewtopic.php?f=82&t=5962
Page 1 of 1

Author:  azcn2503 [ Thu Jun 17, 2010 9:33 am ]
Post subject:  The Haste Calculator

2 versions...

Code:
<!DOCTYPE html PUBLIC "-/W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Haste Calculator</title>
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
      <script type="text/javascript"><!--
         function grab(o){
            return document.all?document.all[o]:document.getElementById?document.getElementById(o):"";
         }
         function recalc(){
            var w1d=grab("weapon1_delay").value; var w2d=grab("weapon2_delay").value; var h=grab("haste").value;
            grab("weapon2_delay").disabled=grab("weapon2_inuse").checked?"":"disabled";
            if(!isNaN(w1d)&&!isNaN(w2d)&&!isNaN(h)){
               var w1dh=w1d-(w1d*((h*.01)/2));
               var w2dh=w2d-(w2d*((h*.01)/2));
               if(grab("weapon2_inuse").checked){
                  w1dh*=1.3; w2dh*=1.3;
               }
               else{
                  w2dh=0;
               }
               var hpm=(60/w1dh)+(w2dh==0?0:(60/w2dh));
               // GRAPHING BELOW
               if(w1dh==w2dh){ lwd=w1d>w1dh?w1d:w1dh; }
               else{
                  if(w1d>w1dh||w2d>w2dh){ lwd=w1d>w2d?w1d:w2d; }
                  else{ lwd=w1dh>w2dh?w1dh:w2dh; }
               }
               if(!grab("weapon2_inuse").checked){ lwd=w1d>w1dh?w1d:w1dh; }
               g_w1d=Math.round((100/lwd)*w1d);
               g_w1dh=Math.round((100/lwd)*w1dh);
               g_w2d=Math.round((100/lwd)*w2d);
               g_w2dh=Math.round((100/lwd)*w2dh);
               if(!grab("weapon2_inuse").checked){ g_w2d=g_w2dh=0; }
               grab("g_w1d").style.width=g_w1d+"%";
               grab("g_w1dh").style.width=g_w1dh+"%";
               grab("g_w2d").style.width=g_w2d+"%";
               grab("g_w2dh").style.width=g_w2dh+"%";
               // GRAPHING ABOVE
               grab("weapon1_delay_actual").innerHTML=Math.round(w1dh*10)/10+" sec";
               grab("weapon2_delay_actual").innerHTML=Math.round(w2dh*10)/10+" sec";
               grab("hitspermin").innerHTML=Math.round(hpm*10)/10+"/min";
            }
         }
      //--></script>
      <style type="text/css"><!--
         *{
            font-family:tahoma;
            font-size:12pt;
         }
         input{
            border:0;
            background-color:#ccc;
         }
         .result{
            font-size:12pt;
            font-weight:bold;
            color:#0c0;
         }
         table td{ padding:5px; }
         .bar1{ background-color:#c00; }
         .bar2{ background-color:#00c; }
         .bar1,.bar2{ height:15px; }
         .barbox{ background-color:#ccc; }
      //--></style>
   </head>
   <body onload="recalc();">
      <div align="center">
         <table style="width:600px;">
            <tr>
               <td>&nbsp;</td>
               <td>Weapon 1 Delay:</td>
               <td><input type="text" id="weapon1_delay" value="4" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td><input type="checkbox" id="weapon2_inuse" checked="checked" onclick="recalc();" /></td>
               <td>Weapon 2 Delay:</td>
               <td><input type="text" id="weapon2_delay" value="4" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Haste:</td>
               <td><input type="text" id="haste" value="35" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Actual Weapon 1 Delay:</td>
               <td><span id="weapon1_delay_actual" class="result">?</span></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Actual Weapon 2 Delay:</td>
               <td><span id="weapon2_delay_actual" class="result">?</span></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Hits/min:</td>
               <td><span id="hitspermin" class="result">?</span></td>
            </tr>
         </table>
         
         <table style="width:600px;">
            <tr>
               <td>Weapon 1 Delay:</td>
               <td style="width:60%" class="barbox"><div id="g_w1d" class="bar1"></div></td>
            </tr>
            <tr>
               <td>Actual Weapon 1 Delay:</td>
               <td class="barbox"><div id="g_w1dh" class="bar2"></div></td>
            </tr>
            <tr>
               <td>Weapon 2 Delay:</td>
               <td class="barbox"><div id="g_w2d" class="bar1"></div></td>
            </tr>
            <tr>
               <td>Actual Weapon 2 Delay:</td>
               <td class="barbox"><div id="g_w2dh" class="bar2"></div></td>
            </tr>
      </div>
   </body>
</html>


Or attached.

Author:  kyhas [ Thu Jun 17, 2010 10:19 am ]
Post subject:  Re: The Haste Calculator

nice calculator

Author:  azcn2503 [ Fri Jun 18, 2010 10:00 am ]
Post subject:  Re: The Haste Calculator

I would just like to say that I did something absolutely rediculous and I changed a few lines of code...

Code:
               /*if(w1dh==w2dh){ lwd=w1d>w1dh?w1d:w1dh; }
               else{
                  if(w1d>w1dh||w2d>w2dh){ lwd=w1d>w2d?w1d:w2d; }
                  else{ lwd=w1dh>w2dh?w1dh:w2dh; }
               }*/


Changed to...

Code:
lwd=w1dh==w2dh?w1d>w1dh?w1d:w1dh:w1d>w1dh||w2d>w2dh?w1d>w2d?w1d:w2d:w1dh>w2dh?w1dh:w2dh;


LOL

So yeah here's version 2:

Spoiler for Haste Calculator:
Code:
<!DOCTYPE html PUBLIC "-/W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Haste Calculator</title>
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
      <script type="text/javascript"><!--
         function grab(o){ return document.all?document.all[o]:document.getElementById?document.getElementById(o):""; }
         function recalc(){
            var w1d=grab("weapon1_delay").value; var w2d=grab("weapon2_delay").value; var h=grab("haste").value;
            var w2iu=grab("weapon2_inuse").checked;
            grab("weapon2_delay").disabled=grab("weapon2_inuse").checked?"":"disabled";
            if(!isNaN(w1d)&&!isNaN(w2d)&&!isNaN(h)){
               var w1dh=w1d-(w1d*((h*.01)/2));
               var w2dh=w2d-(w2d*((h*.01)/2));
               w1dh*=w2iu?1.3:1;
               w2dh*=w2iu?1.3:!w2iu?0:1;
               var hpm=(60/w1dh)+(w2dh==0?0:(60/w2dh));
               var lwd=w1dh==w2dh?w1d>w1dh?w1d:w1dh:w1d>w1dh||w2d>w2dh?w1d>w2d?w1d:w2d:w1dh>w2dh?w1dh:w2dh;
               lwd=!w2iu?w1d>w1dh?w1d:w1dh:lwd;
               g_w1d=Math.round((100/lwd)*w1d);
               g_w1dh=Math.round((100/lwd)*w1dh);
               g_w2d=w2iu?Math.round((100/lwd)*w2d):0;
               g_w2dh=w2iu?Math.round((100/lwd)*w2dh):0;
               grab("g_w1d").style.width=g_w1d+"%";
               grab("g_w1dh").style.width=g_w1dh+"%";
               grab("g_w2d").style.width=g_w2d+"%";
               grab("g_w2dh").style.width=g_w2dh+"%";
               grab("weapon1_delay_actual").innerHTML=Math.round(w1dh*10)/10+" sec";
               grab("weapon2_delay_actual").innerHTML=Math.round(w2dh*10)/10+" sec";
               grab("hitspermin").innerHTML=Math.round(hpm*10)/10+"/min";
            }
         }
      //--></script>
      <style type="text/css"><!--
         table tr{ padding:0; margin:0; }
         table td{ padding:0; margin:0; }
         .bar1{ background-color:#c00; }
         .bar2{ background-color:#00c; }
         .bar1,.bar2{ height:20px; }
         .barbox{ background-color:#ccc; }
      //--></style>
   </head>
   <body onload="recalc();">
      <div align="center">
         <table style="width:600px;">
            <tr>
               <td style="width:5%;">&nbsp;</td>
               <td style="width:35%;">Weapon 1 Delay:</td>
               <td style="width:60%;"><input type="text" id="weapon1_delay" value="4" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td><input type="checkbox" id="weapon2_inuse" checked="checked" onclick="recalc();" /></td>
               <td>Weapon 2 Delay:</td>
               <td><input type="text" id="weapon2_delay" value="4" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Haste %:</td>
               <td><input type="text" id="haste" value="35" onkeydown="recalc();" onkeyup="recalc();" /></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Actual Weapon 1 Delay:</td>
               <td><span id="weapon1_delay_actual" class="result">?</span></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Actual Weapon 2 Delay:</td>
               <td><span id="weapon2_delay_actual" class="result">?</span></td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td>Hits/min:</td>
               <td><span id="hitspermin" class="result">?</span></td>
            </tr>
         </table>
         

         <table style="width:600px;">
            <tr>
               <td style="width:40%;">Weapon 1 Delay:</td>
               <td style="width:60%" class="barbox"><div id="g_w1d" class="bar1"></div></td>
            </tr>
            <tr>
               <td>Actual Weapon 1 Delay:</td>
               <td class="barbox"><div id="g_w1dh" class="bar2"></div></td>
            </tr>
            <tr>
               <td>Weapon 2 Delay:</td>
               <td class="barbox"><div id="g_w2d" class="bar1"></div></td>
            </tr>
            <tr>
               <td>Actual Weapon 2 Delay:</td>
               <td class="barbox"><div id="g_w2dh" class="bar2"></div></td>
            </tr>
         </table>
      </div>
   </body>
</html>

Author:  azcn2503 [ Fri Jun 18, 2010 4:13 pm ]
Post subject:  Re: The Haste Calculator

I have just been informed that the delay on dual-wield may be 1/3 (1.333... etc), so if that is true then just change *=w2iu?1.3 to *=w2iu?4/3 job done.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/