forked from jschof1/DataEthicsCanvas-TranslationTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.js
129 lines (96 loc) · 3.83 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
async function getJson(url) {
return await fetch(url).then(response => response.json()).then(json => json);
}
const bubble = ["NA"]
for(let i = 1; i<16; i++){
bubble.push(document.getElementById(`container-${i}`))
}
function main(collection, color) {
getJson(collection).then(data => {
for (let i = 0; i < 15; i++) {
let div = document.createElement('div')
div.id = `data-container${i+1}`
let listContainer = document.createElement('ul')
listContainer.setAttribute("class", "list-container")
//Storing Data
let newArr = Object.values(data)
//Printing Titles
let h3 = document.createElement('h3')
let titles = newArr[i].title
h3.innerHTML = titles
div.appendChild(h3)
//Printing Questions
let questions = newArr[i].questions
questions.map((props) => {
let li = document.createElement('li')
li.innerHTML = props
listContainer.appendChild(li)
div.appendChild(listContainer)
document.body.appendChild(div)
})
}
let info = Object.values(data.corners)
let largeTitle = info[1]
let logo = info[0]
let bottomLeftText = info[2]
let link = info[3]
let date = info[4]
let licenseLogo = info[5][0]
let licenseText = info[5][1]
let topRight = document.getElementById("top-right")
let topRightDate = document.getElementById("top-right-date")
let topLeft = document.getElementById("top-left")
let bottomLeft = document.getElementById("bottom-left")
let bottomRightLogo = document.getElementById("license-logo")
let bottomRightLink = document.getElementById("bottom-right-link")
let bottomRightText = document.getElementById("bottom-right-license")
topRight.append(largeTitle)
topRightDate.append(date)
topLeft.src = "assets/" + color + "/" + logo
bottomLeft.append(bottomLeftText)
bottomRightLogo.src = "assets/" + color + "/" + licenseLogo
bottomRightLink.append(link)
bottomRightText.append(licenseText)
let dataContainer = ["NA"]
for(let i = 1; i<16; i++){
dataContainer.push(document.getElementById(`data-container${i}`))
}
//CHANGE CODE HERE
// bubble[BUBBLE POSITION].appendChild(dataContainer[CONTAINER POSITION IN YOUR CANVAS JSON])
// bubble[1].appendChild(dataContainer[13])
bubble[1].appendChild(dataContainer[1])
bubble[2].appendChild(dataContainer[5])
bubble[3].appendChild(dataContainer[2])
bubble[4].appendChild(dataContainer[4])
bubble[5].appendChild(dataContainer[13])
bubble[6].appendChild(dataContainer[6])
bubble[7].appendChild(dataContainer[8])
bubble[8].appendChild(dataContainer[9])
bubble[9].appendChild(dataContainer[10])
bubble[10].appendChild(dataContainer[14])
bubble[11].appendChild(dataContainer[11])
bubble[12].appendChild(dataContainer[7])
bubble[13].appendChild(dataContainer[12])
bubble[14].appendChild(dataContainer[3])
bubble[15].appendChild(dataContainer[15])
// for(let i = 1; i<16; i++){
// bubble[i].appendChild(dataContainer[i])
// }
return data;
});
}
var url = new URL(window.location.href);
var color = url.searchParams.get("color") || "colour";
if (color == "greyscale") {
document.getElementsByTagName("body")[0].style.backgroundImage = "url('assets/greyscale/template-blank.jpg')";
document.getElementsByTagName("body")[0].style.color = "black";
var h2Elements = document.getElementsByTagName("h2");
for(var i = 0; i < h2Elements.length; i++) {
h2Elements[i].style.color = "black";
}
}
var lang = url.searchParams.get("lang") || "en";
lang == "nl" ? document.getElementById('container-8').style.fontSize = "10px !important" : "10px !important"
document.getElementById('container-8').style.setProperty( 'property', 'newValue', 'important' );
console.log(lang)
main("./lang/" + lang + ".json", color);