From 8a35ac8edd6849aa99c59b40c513d272303d307d Mon Sep 17 00:00:00 2001 From: IM23a-spirgif Date: Sat, 21 Sep 2024 18:55:30 +0200 Subject: [PATCH] fixed some bugs --- static/filterWeapons.js | 5 ++++- static/populateTable.js | 19 +++++++++---------- templates/index.html | 1 - 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/static/filterWeapons.js b/static/filterWeapons.js index 022c10c..b15ef3d 100644 --- a/static/filterWeapons.js +++ b/static/filterWeapons.js @@ -401,7 +401,6 @@ function updateModifiedWeaponStats(damage, rpm, reloadTime) { `; } -// Function to filter weapons in the dropdown based on search input function filterWeapons() { const input = document.getElementById('weapon-search').value.toLowerCase(); const weaponSelect = document.getElementById('weapon-select'); @@ -426,6 +425,8 @@ function filterWeapons() { // Automatically select the first visible matching option if (firstVisibleOption) { 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 if (firstVisibleOption) { operativeSelect.value = firstVisibleOption.value; + // Manually trigger the 'change' event after auto-selecting the first option + operativeSelect.dispatchEvent(new Event('change')); } } diff --git a/static/populateTable.js b/static/populateTable.js index b8c35a6..47a81b5 100644 --- a/static/populateTable.js +++ b/static/populateTable.js @@ -4,12 +4,12 @@ document.addEventListener('DOMContentLoaded', () => { .then(data => { const updatedGuns = data.map(gun => { 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 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 return { @@ -37,10 +37,9 @@ function populateTable(data) { row.insertCell(3).innerText = gun.rpm; row.insertCell(4).innerText = gun.mag_size; row.insertCell(5).innerText = gun.reload_time; - row.insertCell(6).innerText = gun.guntype; - row.insertCell(7).innerText = gun.rps.toFixed(2); - row.insertCell(8).innerText = gun.dps.toFixed(2); - row.insertCell(9).innerText = gun.dpm.toFixed(2); - row.insertCell(10).innerText = gun.avg_dps.toFixed(2); + row.insertCell(6).innerText = gun.rps.toFixed(2); + row.insertCell(7).innerText = gun.dps.toFixed(2); + row.insertCell(8).innerText = gun.dpm.toFixed(2); + row.insertCell(9).innerText = gun.avg_dps.toFixed(2); }); } diff --git a/templates/index.html b/templates/index.html index 806743d..77de8e2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -61,7 +61,6 @@ Rounds per minute Magazine Size Reload time - Gun type RPS DPS DPM