From 0c7c1e6484bda733bd4a72ae783952f94f32d4e9 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Fri, 2 Feb 2024 15:39:43 -0500 Subject: [PATCH] refactoring, cleanup --- app.py | 1 + static/js/indexListener.js | 21 ++----------------- ...ly.js => updateMonsterDropdownByFamily.js} | 2 +- ....js => updateMonsterDropdownBySelected.js} | 5 ++++- ...updateSprite.js => updateMonsterSprite.js} | 0 templates/breeds.html | 3 +++ 6 files changed, 11 insertions(+), 21 deletions(-) rename static/js/{updateMonstersDropdownByFamily.js => updateMonsterDropdownByFamily.js} (89%) rename static/js/{updateMonstersDropdownBySelected.js => updateMonsterDropdownBySelected.js} (70%) rename static/js/{updateSprite.js => updateMonsterSprite.js} (100%) diff --git a/app.py b/app.py index 8c964e4..446b0f1 100644 --- a/app.py +++ b/app.py @@ -120,6 +120,7 @@ def monster_stats(monster_name): ) + # Add this route for fetching breeding combinations @app.route("/breeds") def get_breeding_combinations(): diff --git a/static/js/indexListener.js b/static/js/indexListener.js index 7319f82..948f598 100644 --- a/static/js/indexListener.js +++ b/static/js/indexListener.js @@ -1,15 +1,9 @@ document.addEventListener("DOMContentLoaded", function () { const familyDropdown = document.getElementById("familyDropdown"); const monsterDropdown = document.getElementById("monsterDropdown"); - //const parent = document.getElementById("parent") - - // Implementing Family Icon Grid in place of family dropdown - //const familyGrid = document.getElementById("familyGrid") // Initialize dropdowns - updateMonstersDropdownByFamily(); - // Initialize Family Grid(); - // populateFamilyGrid(); + updateMonsterDropdownByFamily(); // Fetch families data from the server and populate families dropdown fetch("/get_families") @@ -21,22 +15,11 @@ document.addEventListener("DOMContentLoaded", function () { // Listeners for Dropdown Changes familyDropdown.addEventListener("change", function () { - updateMonstersDropdownByFamily(); + updateMonsterDropdownByFamily(); }); monsterDropdown.addEventListener("change", function () { updateIframes(); }); - // Listener for a click on the one of the family icons - //familyGrid.addEventListener("click", function() { - // updateMonsterGrid(); // Need a function for this too... - //}); - - // Listener for a click on a breeding parent - //parent.addEventListener("click", function() { - // updateMonstersDropdownBySelected(); - // updateIFrames(); - //}); - }); diff --git a/static/js/updateMonstersDropdownByFamily.js b/static/js/updateMonsterDropdownByFamily.js similarity index 89% rename from static/js/updateMonstersDropdownByFamily.js rename to static/js/updateMonsterDropdownByFamily.js index e2b1b2b..effe0ec 100644 --- a/static/js/updateMonstersDropdownByFamily.js +++ b/static/js/updateMonsterDropdownByFamily.js @@ -1,4 +1,4 @@ -function updateMonstersDropdownByFamily() { +function updateMonsterDropdownByFamily() { const selectedFamily = familyDropdown.value; // Fetch monsters data from the server based on the selected family diff --git a/static/js/updateMonstersDropdownBySelected.js b/static/js/updateMonsterDropdownBySelected.js similarity index 70% rename from static/js/updateMonstersDropdownBySelected.js rename to static/js/updateMonsterDropdownBySelected.js index 3c1255a..ad70e04 100644 --- a/static/js/updateMonstersDropdownBySelected.js +++ b/static/js/updateMonsterDropdownBySelected.js @@ -2,8 +2,11 @@ // const selectedMonster = parent.value; // // // Fetch monsters data from the server based on the selected monster -// fetch(`/monster/${selectedMonster}`) +// fetch(`/monster_info_json/${selectedMonster}`) // .then(response => response.json()) // .then(data => populateDropdown(monsterDropdown, data)) // .catch(error => console.error("Error fetching monsters:", error)); //} + +// I was using this to try to update the page when a monster +// in the breeding page is clicked \ No newline at end of file diff --git a/static/js/updateSprite.js b/static/js/updateMonsterSprite.js similarity index 100% rename from static/js/updateSprite.js rename to static/js/updateMonsterSprite.js diff --git a/templates/breeds.html b/templates/breeds.html index 3a3bf41..b2b056b 100644 --- a/templates/breeds.html +++ b/templates/breeds.html @@ -42,5 +42,8 @@ {% endif %} + {% for file in js_files %} + + {% endfor %}