forked from cirion02/bingo-variants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variant-box-generator.js
63 lines (51 loc) · 1.88 KB
/
variant-box-generator.js
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
60
61
62
63
function variantToElement(variant){
let div = document.createElement("div");
div.className = "variantBox";
let name = document.createElement("h3");
name.className = variant.color;
name.innerText = variant.name;
div.appendChild(name);
let credit = document.createElement("div");
credit.className = "credit";
credit.innerText = "Creator: " + variant.credit;
div.appendChild(credit);
let description = document.createElement("div");
description.className = "description";
description.innerText = "Description: " + variant.description;
div.appendChild(description);
if (variant.notes) {
let notes = document.createElement("div");
notes.className = "notes";
notes.innerText = "Additional Notes: " + variant.notes;
div.appendChild(notes);
}
if (variant.external_links) {
for (let linkData of variant.external_links){
if (linkData.link){
let link = document.createElement("div");
link.className = "link";
link.innerHTML = `${linkData.name}: <a href="${linkData.link}">${linkData.link}</a>`;
div.appendChild(link);
}
else if (linkData.file) {
let link = document.createElement("div");
link.className = "link";
link.innerHTML = `${linkData.name}: <a href="${linkData.file}" download>Download</a>`;
div.appendChild(link);
}
}
}
return div;
}
const VARIANT_COLORS = ["White", "Purple", "Blue", "Green", "Orange", "Red"];
function renderVariants(variant_list){
for (let variant of variant_list){
document.getElementById("holder").appendChild(variantToElement(variant))
}
}
function addAllVariants(){
let temp = variant_list_data;
temp.sort(orderVariants);
console.log(temp);
renderVariants(temp)
}