fixed some bugs

This commit is contained in:
IM23a-spirgif
2024-09-21 18:55:30 +02:00
parent 9f12490fc7
commit 8a35ac8edd
3 changed files with 13 additions and 12 deletions
+4 -1
View File
@@ -401,7 +401,6 @@ function updateModifiedWeaponStats(damage, rpm, reloadTime) {
`; `;
} }
// Function to filter weapons in the dropdown based on search input
function filterWeapons() { function filterWeapons() {
const input = document.getElementById('weapon-search').value.toLowerCase(); const input = document.getElementById('weapon-search').value.toLowerCase();
const weaponSelect = document.getElementById('weapon-select'); const weaponSelect = document.getElementById('weapon-select');
@@ -426,6 +425,8 @@ function filterWeapons() {
// Automatically select the first visible matching option // Automatically select the first visible matching option
if (firstVisibleOption) { if (firstVisibleOption) {
weaponSelect.value = firstVisibleOption.value; weaponSelect.value = firstVisibleOption.value;
// Manually trigger the 'change' event after auto-selecting the first option
weaponSelect.dispatchEvent(new Event('change'));
} }
} }
@@ -454,6 +455,8 @@ function filterOperatives() {
// Automatically select the first visible matching option // Automatically select the first visible matching option
if (firstVisibleOption) { if (firstVisibleOption) {
operativeSelect.value = firstVisibleOption.value; operativeSelect.value = firstVisibleOption.value;
// Manually trigger the 'change' event after auto-selecting the first option
operativeSelect.dispatchEvent(new Event('change'));
} }
} }
+9 -10
View File
@@ -4,12 +4,12 @@ document.addEventListener('DOMContentLoaded', () => {
.then(data => { .then(data => {
const updatedGuns = data.map(gun => { const updatedGuns = data.map(gun => {
const original_damage = gun['damage']; const original_damage = gun['damage'];
const rps = gun['rpm'] / 60;
const dps = original_damage * rps;
const reload_time_min = gun['reload_time'] / 60;
const dpm = (gun['mag_size'] * original_damage) / (reload_time_min + (gun['mag_size'] / gun['rpm']));
const avg_dps = dpm / 60;
const total_damage = original_damage * gun['damage_multiplier']; const total_damage = original_damage * gun['damage_multiplier'];
const rps = gun['rpm'] / 60;
const dps = total_damage * rps;
const reload_time_min = gun['reload_time'] / 60;
const dpm = (gun['mag_size'] * total_damage) / (reload_time_min + (gun['mag_size'] / gun['rpm']));
const avg_dps = dpm / 60;
// Add the calculated stats to the gun object // Add the calculated stats to the gun object
return { return {
@@ -37,10 +37,9 @@ function populateTable(data) {
row.insertCell(3).innerText = gun.rpm; row.insertCell(3).innerText = gun.rpm;
row.insertCell(4).innerText = gun.mag_size; row.insertCell(4).innerText = gun.mag_size;
row.insertCell(5).innerText = gun.reload_time; row.insertCell(5).innerText = gun.reload_time;
row.insertCell(6).innerText = gun.guntype; row.insertCell(6).innerText = gun.rps.toFixed(2);
row.insertCell(7).innerText = gun.rps.toFixed(2); row.insertCell(7).innerText = gun.dps.toFixed(2);
row.insertCell(8).innerText = gun.dps.toFixed(2); row.insertCell(8).innerText = gun.dpm.toFixed(2);
row.insertCell(9).innerText = gun.dpm.toFixed(2); row.insertCell(9).innerText = gun.avg_dps.toFixed(2);
row.insertCell(10).innerText = gun.avg_dps.toFixed(2);
}); });
} }
-1
View File
@@ -61,7 +61,6 @@
<th>Rounds per minute</th> <th>Rounds per minute</th>
<th>Magazine Size</th> <th>Magazine Size</th>
<th>Reload time</th> <th>Reload time</th>
<th>Gun type</th>
<th>RPS</th> <th>RPS</th>
<th>DPS</th> <th>DPS</th>
<th>DPM</th> <th>DPM</th>