dwm-app/static/js/updateMonsterSkills.js

21 lines
868 B
JavaScript
Raw Normal View History

2024-02-21 15:43:08 +00:00
function updateMonsterSkills() {
2024-02-21 15:59:43 +00:00
// Get the selected monster from the dropdown
var selectedMonster = document.getElementById("monsterDropdown").value;
2024-02-21 15:43:08 +00:00
2024-02-21 15:59:43 +00:00
// Make an API request to get the stats for the selected monster
fetch(`/api/monster/stats?monster=${selectedMonster}`)
2024-02-21 15:43:08 +00:00
.then(response => response.json())
.then(data => {
2024-02-21 15:59:43 +00:00
// Split the skills string into an array and join with line breaks
var skillsArray = data.Skills.split(",");
var formattedSkills = skillsArray.join(",<br>");
// Update the HTML content with the monster skills
var skillsContainer = document.getElementById("monsterSkillsContainer");
skillsContainer.innerHTML = `<h2>Skills:<br> ${formattedSkills}</h2>`;
2024-02-21 15:43:08 +00:00
})
.catch(error => {
2024-02-21 15:59:43 +00:00
console.error("Error fetching monster skills:", error);
2024-02-21 15:43:08 +00:00
});
2024-02-21 15:59:43 +00:00
}