-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcharacter_detail.js
More file actions
46 lines (40 loc) · 1.52 KB
/
Copy pathcharacter_detail.js
File metadata and controls
46 lines (40 loc) · 1.52 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
/**
* character_detail.js
* Renders a single character detail page.
* Depends on item_detail.js being loaded first.
*/
function renderCharacter(data) {
document.title = (data.name || "Character") + " – GameDB";
document.getElementById("character-name").textContent = data.name || "Unknown Character";
// Mug shot
const mugEl = document.getElementById("character-mug");
const mugPlaceholder = document.getElementById("character-mug-placeholder");
const mugUrl = data.mug_shot?.url
? igdbImageUrl(data.mug_shot.url, "t_cover_big_2x")
: null;
if (mugUrl) {
mugEl.src = mugUrl;
mugEl.alt = data.name || "";
mugEl.style.display = "";
} else {
mugPlaceholder.style.display = null;
mugPlaceholder.style.removeProperty("display");
}
// Badges / meta
const badgesEl = document.getElementById("character-badges");
if (data.character_gender?.name) {
badgesEl.appendChild(makeBadge(data.character_gender.name, "bg-info text-dark"));
}
if (data.character_species?.name) {
badgesEl.appendChild(makeBadge(data.character_species.name, "bg-secondary"));
}
// Games
if (data.games && data.games.length > 0) {
const section = document.getElementById("character-games-section");
section.classList.remove("d-none");
renderGameList(document.getElementById("character-games"), data.games);
}
}
document.addEventListener("DOMContentLoaded", () => {
loadItemDetail("characters", renderCharacter);
});