forked from sosjo200548/9axes-korean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.html
334 lines (312 loc) · 14.8 KB
/
results.html
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:400,700" rel="stylesheet">
<link href='style.css' rel='stylesheet' type='text/css'>
<title>9Axes 결과</title>
<link rel="icon" type="x-icon" href="icon.png">
<link rel="shortcut icon" type="x-icon" href="icon.png">
<meta charset="utf-8">
</head>
<script type="application/javascript" src="ideologies.js">
</script>
<body>
<h1>9Axes</h1>
<hr>
<h1>결 과</h1>
<h2><span class="weight-300" id="a-label"></span></h2>
<div class="axis">
<img id="img-federal" src="value_images/federal.png" height="128pt"/>
<div class="bar federal" id="bar-federal"><div class="text-wrapper" id="federal"></div></div>
<div class="bar unitary" id="bar-unitary"><div class="text-wrapper" id="unitary"></div></div>
<img id="img-unitary" src="value_images/unitary.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="b-label"></span></h2>
<div class="axis">
<img id="img-democratic" src="value_images/democracy.png" height="128pt"/>
<div class="bar democratic" id="bar-democratic"><div class="text-wrapper" id="democratic"></div></div>
<div class="bar authority" id="bar-authority"><div class="text-wrapper" id="authority"></div></div>
<img id="img-authority" src="value_images/authority.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="c-label"></span></h2>
<div class="axis">
<img id="img-globalist" src="value_images/globalist.png" height="128pt"/>
<div class="bar globalist" id="bar-globalist"><div class="text-wrapper" id="globalist"></div></div>
<div class="bar isolation" id="bar-isolation"><div class="text-wrapper" id="isolation"></div></div>
<img id="img-isolation" src="value_images/isolationist.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="d-label"></span></h2>
<div class="axis">
<img id="img-militarist" src="value_images/militarist.png" height="128pt"/>
<div class="bar militarist" id="bar-militarist"><div class="text-wrapper" id="militarist"></div></div>
<div class="bar pacifist" id="bar-pacifist"><div class="text-wrapper" id="pacifist"></div></div>
<img id="img-pacifist" src="value_images/pacifist.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="e-label"></span></h2>
<div class="axis">
<img id="img-security" src="value_images/security.png" height="128pt"/>
<div class="bar security" id="bar-security"><div class="text-wrapper" id="security"></div></div>
<div class="bar freedom" id="bar-freedom"><div class="text-wrapper" id="freedom"></div></div>
<img id="img-freedom" src="value_images/freedom.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="f-label"></span></h2>
<div class="axis">
<img id="img-equality" src="value_images/equality.png" height="128pt"/>
<div class="bar equality" id="bar-equality"><div class="text-wrapper" id="equality"></div></div>
<div class="bar markets" id="bar-markets"><div class="text-wrapper" id="markets"></div></div>
<img id="img-markets" src="value_images/markets.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="g-label"></span></h2>
<div class="axis">
<img id="img-secular" src="value_images/secular.png" height="128pt"/>
<div class="bar secular" id="bar-secular"><div class="text-wrapper" id="secular"></div></div>
<div class="bar religious" id="bar-religious"><div class="text-wrapper" id="religious"></div></div>
<img id="img-religious" src="value_images/religious.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="h-label"></span></h2>
<div class="axis">
<img id="img-progress" src="value_images/progress.png" height="128pt"/>
<div class="bar progress" id="bar-progress"><div class="text-wrapper" id="progress"></div></div>
<div class="bar tradition" id="bar-tradition"><div class="text-wrapper" id="tradition"></div></div>
<img id="img-tradition" src="value_images/tradition.png" height="128pt"/>
</div>
<h2><span class="weight-300" id="i-label"></span></h2>
<div class="axis">
<img id="img-assimilation" src="value_images/assimilationist.png" height="128pt"/>
<div class="bar assimilation" id="bar-assimilation"><div class="text-wrapper" id="assimilation"></div></div>
<div class="bar multiculture" id="bar-multiculture"><div class="text-wrapper" id="multiculture"></div></div>
<img id="img-multiculture" src="value_images/multiculturalist.png" height="128pt"/>
</div>
<br><br>
<h2 class="ideology">가장 근접한 : <span class="weight-300" id="ideology-label"></span></h1>
<p class="ideology">8가지 가치 이념(자세한 내용은 https://8values.github.io 참조)</p>
<p class="ideology">이는 민주-권위주의, 세계주의-고립주의, 평등-시장, 진보-전통 축만 고려한 결과라는 점에 유의하시기 바랍니다.</p>
<br><br>
<canvas id="banner" width=800 height=1200 style="font-family:Montserrat"></canvas>
<button class="button" onclick="location.href='index.html';" style="background-color: #2196f3;">Back</button> <br>
<script>
function getQueryVariable(variable)
{
var query = window.location.search.substring(1)
var vars = query.split("&")
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=")
if(pair[0] == variable) {return pair[1]}
}
return(NaN);
}
function setBarValue(name, value) {
innerel = document.getElementById(name)
outerel = document.getElementById("bar-" + name)
outerel.style.width = (value + "%")
innerel.innerHTML = (value + "%")
if (innerel.offsetWidth + 20 > outerel.offsetWidth) {
innerel.style.visibility = "hidden"
}
}
leftArray = ["연방주의","민주주의","국제주의","군국주의","권위주의","평등주의","세속주의","진보주의","동화주의"]
rightArray = ["단일국가주의","독재주의","고립주의","평화주의","자유주의","시장주의","종교주의","전통주의","다문화주의"]
function setLabel(val,axis) {
if (val >= 90) { return "광적인 " + leftArray[axis] } else
if (val >= 80) { return "극단적인 " + leftArray[axis] } else
if (val >= 70) { return leftArray[axis] } else
if (val >= 60) { return "온건한 " + leftArray[axis] } else
if (val > 40) { return "중립" } else
if (val > 30) { return "온건한 " + rightArray[axis] } else
if (val > 20) { return rightArray[axis] } else
if (val > 10) { return "극단적인 " + rightArray[axis] } else
{return "광적인 " + rightArray[axis]}
}
a = getQueryVariable("a")
b = getQueryVariable("b")
c = getQueryVariable("c")
d = getQueryVariable("d")
e = getQueryVariable("e")
f = getQueryVariable("f")
g = getQueryVariable("g")
h = getQueryVariable("h")
i1 = getQueryVariable("i")
a2 = 100-a;
b2 = 100-b;
c2 = 100-c;
d2 = 100-d;
e2 = 100-e;
f2 = 100-f;
g2 = 100-g;
h2 = 100-h;
i2 = 100-i1;
setBarValue("federal", a)
setBarValue("unitary", a2)
setBarValue("democratic", b)
setBarValue("authority", b2)
setBarValue("globalist", c)
setBarValue("isolation", c2)
setBarValue("militarist", d)
setBarValue("pacifist", d2)
setBarValue("security", e)
setBarValue("freedom", e2)
setBarValue("equality", f)
setBarValue("markets", f2)
setBarValue("secular", g)
setBarValue("religious", g2)
setBarValue("progress", h)
setBarValue("tradition", h2)
setBarValue("assimilation", i1)
setBarValue("multiculture", i2)
document.getElementById("a-label").innerHTML = setLabel(a, 0)
document.getElementById("b-label").innerHTML = setLabel(b, 1)
document.getElementById("c-label").innerHTML = setLabel(c, 2)
document.getElementById("d-label").innerHTML = setLabel(d, 3)
document.getElementById("e-label").innerHTML = setLabel(e, 4)
document.getElementById("f-label").innerHTML = setLabel(f, 5)
document.getElementById("g-label").innerHTML = setLabel(g, 6)
document.getElementById("h-label").innerHTML = setLabel(h, 7)
document.getElementById("i-label").innerHTML = setLabel(i1, 8)
ideology = ""
ideodist = Infinity
for (var i = 0; i < ideologies.length; i++) {
dist = 0
dist += Math.pow(Math.abs(ideologies[i].stats.econ - f), 2)
dist += Math.pow(Math.abs(ideologies[i].stats.govt - b), 2)
dist += Math.pow(Math.abs(ideologies[i].stats.dipl - c), 1.73856063)
dist += Math.pow(Math.abs(ideologies[i].stats.scty - h), 1.73856063)
if (dist < ideodist) {
ideology = ideologies[i].name
ideodist = dist
}
}
document.getElementById("ideology-label").innerHTML = ideology
function createImage(src, x, y, w, h) {
img = new Image ()
img.src = src
img.onLoad = function() {
ctx.drawImage(img, x, y, w, h)
}
}
window.onload = function() {
var c = document.getElementById("banner")
var ctx = c.getContext("2d")
ctx.fillStyle = "#EEEEEE"
ctx.fillRect(0,0,800,1200)
img = document.getElementById("img-federal")
ctx.drawImage(img, 20, 120, 100, 100);
img = document.getElementById("img-unitary")
ctx.drawImage(img, 680, 120, 100, 100)
img = document.getElementById("img-democratic")
ctx.drawImage(img, 20, 240, 100, 100)
img = document.getElementById("img-authority")
ctx.drawImage(img, 680, 240, 100, 100)
img = document.getElementById("img-globalist")
ctx.drawImage(img, 20, 360, 100, 100)
img = document.getElementById("img-isolation")
ctx.drawImage(img, 680, 360, 100, 100)
img = document.getElementById("img-militarist")
ctx.drawImage(img, 20, 480, 100, 100)
img = document.getElementById("img-pacifist")
ctx.drawImage(img, 680, 480, 100, 100)
img = document.getElementById("img-security")
ctx.drawImage(img, 20, 600, 100, 100)
img = document.getElementById("img-freedom")
ctx.drawImage(img, 680, 600, 100, 100)
img = document.getElementById("img-equality")
ctx.drawImage(img, 20, 720, 100, 100)
img = document.getElementById("img-markets")
ctx.drawImage(img, 680, 720, 100, 100)
img = document.getElementById("img-secular")
ctx.drawImage(img, 20, 840, 100, 100)
img = document.getElementById("img-religious")
ctx.drawImage(img, 680, 840, 100, 100)
img = document.getElementById("img-progress")
ctx.drawImage(img, 20, 960, 100, 100)
img = document.getElementById("img-tradition")
ctx.drawImage(img, 680, 960, 100, 100)
img = document.getElementById("img-assimilation")
ctx.drawImage(img, 20, 1080, 100, 100)
img = document.getElementById("img-multiculture")
ctx.drawImage(img, 680, 1080, 100, 100)
ctx.fillStyle="#222222"
ctx.fillRect(120, 130, 560, 80)
ctx.fillRect(120, 250, 560, 80)
ctx.fillRect(120, 370, 560, 80)
ctx.fillRect(120, 490, 560, 80)
ctx.fillRect(120, 610, 560, 80)
ctx.fillRect(120, 730, 560, 80)
ctx.fillRect(120, 850, 560, 80)
ctx.fillRect(120, 970, 560, 80)
ctx.fillRect(120, 1090, 560, 80)
ctx.fillStyle="#ffeb3b"
ctx.fillRect(120, 134, 5.6*a-2, 72)
ctx.fillStyle="#f44336"
ctx.fillRect(682-5.6*a2, 134, 5.6*a2-2, 72)
ctx.fillStyle="#00897b"
ctx.fillRect(120, 254, 5.6*b-2, 72)
ctx.fillStyle="#ff9800"
ctx.fillRect(682-5.6*b2, 254, 5.6*b2-2, 72)
ctx.fillStyle="#03a9f4"
ctx.fillRect(120, 374, 5.6*(100-c2)-2, 72)
ctx.fillStyle="#9c27b0"
ctx.fillRect(682-5.6*c2, 374, 5.6*c2-2, 72)
ctx.fillStyle="#8bc34a"
ctx.fillRect(120, 494, 5.6*d-2, 72)
ctx.fillStyle="#ea90ab"
ctx.fillRect(682-5.6*d2, 494, 5.6*d2-2, 72)
ctx.fillStyle="#3f51b5"
ctx.fillRect(120, 614, 5.6*e-2, 72)
ctx.fillStyle="#ffeb3b"
ctx.fillRect(682-5.6*e2, 614, 5.6*e2-2, 72)
ctx.fillStyle="#f44336"
ctx.fillRect(120, 734, 5.6*f-2, 72)
ctx.fillStyle="#00897b"
ctx.fillRect(682-5.6*f2, 734, 5.6*f2-2, 72)
ctx.fillStyle="#ff9800"
ctx.fillRect(120, 854, 5.6*g-2, 72)
ctx.fillStyle="#03a9f4"
ctx.fillRect(682-5.6*g2, 854, 5.6*g2-2, 72)
ctx.fillStyle="#9c27b0"
ctx.fillRect(120, 974, 5.6*h-2, 72)
ctx.fillStyle="#8bc34a"
ctx.fillRect(682-5.6*h2, 974, 5.6*h2-2, 72)
ctx.fillStyle="#ea90ab"
ctx.fillRect(120, 1094, 5.6*i1-2, 72)
ctx.fillStyle="#3f51b5"
ctx.fillRect(682-5.6*i2, 1094, 5.6*i2-2, 72)
ctx.fillStyle="#222222"
ctx.font="700 80px Montserrat"
ctx.textAlign="left"
ctx.fillText("9Axes", 20, 90)
ctx.font="40px Montserrat"
ctx.textAlign="right"
ctx.font="50px Montserrat"
ctx.textAlign="left"
if (a > 20) {ctx.fillText(a + "%", 130, 187.5)}
if (b > 20) {ctx.fillText(b + "%", 130, 307.5)}
if ((100-c2) > 20) {ctx.fillText((100-c2) + "%", 130, 427.5)}
if (d > 20) {ctx.fillText(d + "%", 130, 547.5)}
if (e > 20) {ctx.fillText(e + "%", 130, 667.5)}
if (f > 20) {ctx.fillText(f + "%", 130, 787.5)}
if (g > 20) {ctx.fillText(g + "%", 130, 907.5)}
if (h > 20) {ctx.fillText(h + "%", 130, 1027.5)}
if (i1 > 20) {ctx.fillText(i1 + "%", 130, 1147.5)}
ctx.textAlign="right"
if (a2 > 20) {ctx.fillText(a2 + "%", 670, 187.5)}
if (b2 > 20) {ctx.fillText(b2 + "%", 670, 307.5)}
if (c2 > 20) {ctx.fillText(c2 + "%", 670, 427.5)}
if (d2 > 20) {ctx.fillText(d2 + "%", 670, 547.5)}
if (e2 > 20) {ctx.fillText(e2 + "%", 670, 667.5)}
if (f2 > 20) {ctx.fillText(f2 + "%", 670, 787.5)}
if (g2 > 20) {ctx.fillText(g2 + "%", 670, 907.5)}
if (h2 > 20) {ctx.fillText(h2 + "%", 670, 1027.5)}
if (i2 > 20) {ctx.fillText(i2 + "%", 670, 1147.5)}
ctx.font="300 30px Montserrat"
ctx.fillText("yangdoyun446.github.io", 780, 55)
ctx.textAlign="center"
ctx.fillText(document.getElementById("a-label").innerHTML, 400, 125)
ctx.fillText(document.getElementById("b-label").innerHTML, 400, 245)
ctx.fillText(document.getElementById("c-label").innerHTML, 400, 365)
ctx.fillText(document.getElementById("d-label").innerHTML, 400, 485)
ctx.fillText(document.getElementById("e-label").innerHTML, 400, 605)
ctx.fillText(document.getElementById("f-label").innerHTML, 400, 725)
ctx.fillText(document.getElementById("g-label").innerHTML, 400, 845)
ctx.fillText(document.getElementById("h-label").innerHTML, 400, 965)
ctx.fillText(document.getElementById("i-label").innerHTML, 400, 1085)
}
</script>
</body>