-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (49 loc) · 3.14 KB
/
Copy pathscript.js
File metadata and controls
63 lines (49 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
document.addEventListener("DOMContentLoaded", function() {
fetch("roster_data.json")
.then(response => response.json())
.then(data => {
const rosterContainer = document.getElementById("roster-container");
rosterContainer.innerHTML = ""; // Clear loading message
data.factions.forEach(faction => {
const factionSection = document.createElement("section");
factionSection.classList.add("faction-section");
const factionHeader = document.createElement("h2");
factionHeader.classList.add("faction-header");
factionHeader.textContent = faction.name;
factionSection.appendChild(factionHeader);
const characterGrid = document.createElement("div");
characterGrid.classList.add("character-grid");
faction.characters.forEach(character => {
const characterCard = document.createElement("div");
characterCard.classList.add("character-card");
const priorityClass = character.priority === "N/A" ? "NA" : character.priority;
const statusClass = character.status.toLowerCase();
// Check if icon exists and is not N/A
const iconHtml = character.icon && character.icon !== "N/A" ? `<img src="${character.icon}" alt="${character.name} icon" class="character-icon">` : '';
// Check if advice exists and is not N/A
const teamCompHtml = character.team_comp_advice && character.team_comp_advice !== "N/A" ? `<p class="team-comp-advice"><b>Team Comp:</b> ${character.team_comp_advice}</p>` : '';
const positioningHtml = character.positioning_advice && character.positioning_advice !== "N/A" ? `<p class="positioning-advice"><b>Positioning:</b> ${character.positioning_advice}</p>` : '';
characterCard.innerHTML = `
${iconHtml}
<h3>${character.name}</h3>
<p class="character-id">${character.id}</p>
<p class="status ${statusClass}">${character.status}</p>
<p class="rank-stars">Rank: ${character.rank}</p>
<p class="level-cap">Level: ${character.level}</p>
<p class="abilities">Abilities: ${character.abilities}</p>
<p class="priority ${priorityClass}">Priority: ${character.priority}</p>
<p class="description">${character.description}</p>
${teamCompHtml}
${positioningHtml}
`;
characterGrid.appendChild(characterCard);
});
factionSection.appendChild(characterGrid);
rosterContainer.appendChild(factionSection);
});
})
.catch(error => {
console.error("Error loading roster data:", error);
document.getElementById("roster-container").innerHTML = "<p>Failed to load roster data. Please try again later.</p>";
});
});