added family and location update js
This commit is contained in:
parent
ce1a24217a
commit
cf1af07e6b
@ -22,5 +22,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
updateIframes();
|
updateIframes();
|
||||||
updateMonsterStats();
|
updateMonsterStats();
|
||||||
updateMonsterName();
|
updateMonsterName();
|
||||||
|
updateMonsterFamily();
|
||||||
|
updateMonsterLocation();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
16
static/js/updateMonsterFamily.js
Normal file
16
static/js/updateMonsterFamily.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
function updateMonsterFamily() {
|
||||||
|
// Get the selected monster from the dropdown
|
||||||
|
var selectedMonster = document.getElementById("monsterDropdown").value;
|
||||||
|
|
||||||
|
// Make an API request to get the stats for the selected monster
|
||||||
|
fetch(`/api/monster/stats?monster=${selectedMonster}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
// Update the HTML content with the monster family
|
||||||
|
var familyContainer = document.getElementById("monsterFamilyContainer");
|
||||||
|
familyContainer.innerHTML = `<h2>${data.Family}</h2>`;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error fetching monster family:", error);
|
||||||
|
});
|
||||||
|
}
|
23
static/js/updateMonsterLocation.js
Normal file
23
static/js/updateMonsterLocation.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
function updateMonsterLocation() {
|
||||||
|
// Get the selected monster from the dropdown
|
||||||
|
var selectedMonster = document.getElementById("monsterDropdown").value;
|
||||||
|
|
||||||
|
// Make an API request to get the stats for the selected monster
|
||||||
|
fetch(`/api/monster/stats?monster=${selectedMonster}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
// Check if location is not null before updating HTML content
|
||||||
|
if (data.Location !== null) {
|
||||||
|
// Update the HTML content with the monster location
|
||||||
|
var locationContainer = document.getElementById("monsterLocationContainer");
|
||||||
|
locationContainer.innerHTML = `<h2>${data.Location}</h2>`;
|
||||||
|
} else {
|
||||||
|
// Handle the case when location is null (optional)
|
||||||
|
var locationContainer = document.getElementById("monsterLocationContainer");
|
||||||
|
locationContainer.innerHTML = ""; // Clear the content or provide a default message
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error fetching monster location:", error);
|
||||||
|
});
|
||||||
|
}
|
@ -33,19 +33,19 @@
|
|||||||
<!-- Monster name will be displayed here -->
|
<!-- Monster name will be displayed here -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="monsterFamilyContainer">
|
||||||
|
<!-- Monster Family will be displayed here-->
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="monsterStatsContainer">
|
<div id="monsterStatsContainer">
|
||||||
<!-- Monster stats will be displayed here -->
|
<!-- Monster stats will be displayed here -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="monsterLocationContainer">
|
<div id="monsterLocationContainer">
|
||||||
<!-- Monster Location will be displayed here
|
<!-- Monster Location will be displayed here-->
|
||||||
TODO Add location to stats api -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="monsterFamilyContainer">
|
|
||||||
<!-- Monster Family will be displayed here
|
|
||||||
TODO Add family to stats api -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="grid items-center justify-center grid-cols-1 ml-4">
|
<div class="grid items-center justify-center grid-cols-1 ml-4">
|
||||||
|
Loading…
Reference in New Issue
Block a user