-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
202 lines (196 loc) · 5.71 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
</head>
<body>
<form id="frm">
<table>
<tr>
<td>Damage</td>
<td>
<input inputmode="numeric" name="Damage" onchange="calc()" oninput="calc()" id="dmg" size="4em">
</td>
<td>
x <input inputmode="numeric" onchange="calc()" oninput="calc()" id="x" size="2em">
</td>
</tr>
<tr>
<td>
Reload
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="reload" size="4em">
</td>
</tr>
<tr>
<td>
Fire Rate
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="rate" size="4em">
</td>
</tr>
<tr>
<td>
Magazine Size
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="mag" size="4em">
</td>
</tr>
<tr>
<td>
Elemental DPS
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="edps" size="4em">
</td>
</tr>
<tr>
<td>
Elemental Chance
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="epct" size="4em">
</td>
</tr>
<tr><td>-</td></tr>
<tr>
<td>
Crit Damage Bonus
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="critbonus" size="4em">
</tr>
<tr>
<td>
Rounds per Shot
</td>
<td>
<input inputmode="numeric" onchange="calc()" oninput="calc()" id="rps" size="4em">
</tr>
<tr><td>-</td></tr>
<tr>
<td>
Effective DPS
</td>
<td>
<strong id="dps" size="4em"></strong>
</td>
</tr>
<tr>
<td>
Damage/Shot
</td>
<td>
<strong id="dpsshot"></strong>
</td>
</tr>
<tr>
<td>
Critical Damage/Shot
</td>
<td>
<strong id="dpscrit"></strong>
</td>
</tr>
</table>
<!-- <button onclick="reset()";>Reset</button> reset screws things up for some reason.-->
<input type="submit" style="opacity:0;"></input>
</form>
<script>
frm=document.getElementById("frm")
inputs = ['dmg', 'reload', 'rate', 'mag', 'edps', 'epct', 'dps'];
// if(frm.attachEvent)
// frm.attachEvent("submit", nextInput, false);
// else
// frm.addEventListener("submit", nextInput, false);
window.addEventListener("submit", nextInput, true);
HTMLFormElement.prototype.submit = nextInput
function nextInput(e)
{
console.log("value: " + document.activeElement.value)
if(e.preventDefault) e.preventDefault();
e.preventDefault()
e.stopImmediatePropagation();
idx = inputs.indexOf(document.activeElement.id)
//this produces an error "Cannot read property 'focus' of null" on last input field
if(idx > -1 && idx<(inputs.length)){
document.getElementById(inputs[idx+1]).focus();
}
return true
}
function isNumeric(n)
{
return !isNaN(parseFloat(n)) && isFinite(n);
}
function getvalfromid(id)
{
e = document.getElementById(id)
if(isNumeric(e.value))
{
e.style.backgroundColor = ""
return parseFloat(e.value)
}
else if(e.value != "")
e.style.backgroundColor = "indianred"
// else if(e.value == "" && e != document.activeElement)
// e.value = e.name
return null
}
function reset()
{
alert("asdf")
console.log("resetting")
for (id of inputs)
document.getElementById(id).value = "";
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function calc()
{
x = getvalfromid('x')
rps = getvalfromid('rps')
mag = getvalfromid('mag')
dmg = getvalfromid('dmg')
if (x)
dmg *= x
if (rps)
mag /= rps
critbonus = getvalfromid('critbonus')/100
reload = getvalfromid('reload')
rate = getvalfromid('rate')
edps = getvalfromid('edps')
epct = getvalfromid('epct')
dps = 0
// Calculating crit:
// Additive bonuses
// Player skills: Skills such as Moze's Scorching RPM's or Amara's Transcend. FL4K has several critical damage skills which are added together in the formula. However, FL4K's Fade Away action skill follows different rules and is not included in this formula.
// Class mod bonus: Class mods sometimes have a critical hit bonus, in most cases restricted to one weapon manufacturer.
// Guardian Rank: The critical damage Guardian rank (accessible after the first playthrough).
// Anointed bonus: Some anointed gear comes with a critical hit bonus that applies under certain circumstances.
// Multiplicative bonuses
// Sniper rifle bonus: Sniper rifles from all manufacturers receive a +20% bonus.
// Weapon critical bonus: Many weapons come with a critical damage bonus which is listed on the item card.
// Manufacturer bonus: Jakobs weapons have a +10%, Hyperion weapons a +5% bonus. Other manufacturers have no bonus.
// CritDMG = NormalDMG × 2 × (100% + Add1 + Add2 + ...) × (100% + Mult1) × (100% + Mult2) × ...
if(dmg && reload && rate && mag)
dps = (dmg*mag)/(mag/rate + reload)
if(epct && edps)
dps += edps*(epct/100)
// Crit calculation
if(dmg)
crit = dmg * 2 * (1 + critbonus)
console.log("dps is ", dps)
if(dps)
document.getElementById('dps').innerHTML = numberWithCommas(Math.round(dps))
if(dmg)
{
document.getElementById('dpsshot').innerHTML = numberWithCommas(Math.round(dmg))
document.getElementById('dpscrit').innerHTML = numberWithCommas(Math.round(crit))
}
}
</script>
</body>
</html>