forked from 9Axes/9axes.github.io
-
Notifications
You must be signed in to change notification settings - Fork 5
/
results.html
385 lines (366 loc) · 17.6 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<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>Resultados - 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">
<script type="application/javascript">
version = "Versão #3.0" //Remember to update this before making changes to the test itself!
</script>
</head>
<script type="application/javascript"
src="parties.js">
</script>
<body>
<h1>9Axes</h1>
<hr>
<h1>Resultados</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>
<hr/>
<h2>Partido mais próximo: <span class="weight-300" id="party-label"></span></h2>
<p>A correspondência de partido é um trabalho em andamento e não é muito preciso.</p>
<hr/>
<canvas style="display: none" id="banner" width=800 height=1200 style="font-family:Montserrat"></canvas>
<a id="link"><button class="button" onclick="resultsdownload();" style="background-color: #2196f3;">Salvar Resultados</button></a> <br>
<button class="button" onclick="location.href='index.html';" style="background-color: #f44336;">Voltar</button> <br>
<script>
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
function resultsdownload()
{
if(isMobile.any()) {
var canvas = document.getElementsByTagName('canvas')[0];
var link = document.getElementById('link');
link.setAttribute('download', 'results.png');
link.setAttribute('href', canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"));
} else {
var canvas = document.getElementsByTagName('canvas')[0];
var link = document.getElementById('link');
link.setAttribute('download', 'results.png');
link.setAttribute('href', canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"));
}
}
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"
}
}
diviArray = ["Separatista","Confederalista","Descentralista","Neutro","Devolucionista","Centralista","Unitário"]
govtArray = ["Anarquista","Libertário","Liberal","Moderado","Estatista","Autoritário","Totalitário"]
diplArray = ["Cosmopolitano","Internacionalista","Conformista","Equilibrado","Patriótico","Nacionalista","Chauvinista"]
miliArray = ["Junta Militar","Militarista","Paramilitarista","Militar Democrata","Neutro","Anti-Militarista","Pacifista"]
protArray = ["Vigilância em massa Global","Vigilância em massa","Vigilância Policial","Neutro","Privacidade do Governo","Privacidade do Governo e Corporações","Privacidade Total"]
econArray = ["Comunista","Socialista","Social Democrata","Centrista","Apoiante de Livre Mercado","Capitalista","Laissez-Faire"]
reliArray = ["Anticlericalista","Laicista","Secularista","Neutro","Etocrata","Teocrata","Clericalista"]
sctyArray = ["Revolucionário","Muito Progressista","Progressista","Neutro","Tradicional","Conservador","Reacionário"]
cultArray = ["Monoculturalista","Multicomunitarista","Interculturalista","Neutro","Assimilacionista","Multiculturalista","Intraculturalista"]
function setCLabel(val,ary) {
if (val > 100) { return "" } else
if (val > 90) { return ary[0] } else
if (val > 75) { return ary[1] } else
if (val > 60) { return ary[2] } else
if (val >= 40) { return ary[3] } else
if (val >= 25) { return ary[4] } else
if (val >= 10) { return ary[5] } else
if (val >= 0) { return ary[6] } else
{return ""}
}
a = getQueryVariable("a")
b = getQueryVariable("b")
c = getQueryVariable("c")
d = getQueryVariable("d")
e = getQueryVariable("e")
f = getQueryVariable("f")
g = getQueryVariable("g")
h = getQueryVariable("h")
i = 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-i;
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", i)
setBarValue("multiculture", i2)
document.getElementById("a-label").innerHTML = setCLabel(a, diviArray)
document.getElementById("b-label").innerHTML = setCLabel(b, govtArray)
document.getElementById("c-label").innerHTML = setCLabel(c, diplArray)
document.getElementById("d-label").innerHTML = setCLabel(d, miliArray)
document.getElementById("e-label").innerHTML = setCLabel(e, protArray)
document.getElementById("f-label").innerHTML = setCLabel(f, econArray)
document.getElementById("g-label").innerHTML = setCLabel(g, reliArray)
document.getElementById("h-label").innerHTML = setCLabel(h, sctyArray)
document.getElementById("i-label").innerHTML = setCLabel(i, cultArray)
party = ""
partydist = Infinity
for (var pari = 0; pari < parties.length; pari++) {
dist = 0
dist += Math.pow(Math.abs(parties[pari].stats.divi - a), 2)
dist += Math.pow(Math.abs(parties[pari].stats.govt - b), 2)
dist += Math.pow(Math.abs(parties[pari].stats.dipl - c), 2)
dist += Math.pow(Math.abs(parties[pari].stats.mili - d), 1.73856063)
dist += Math.pow(Math.abs(parties[pari].stats.prot - e), 1.73856063)
dist += Math.pow(Math.abs(parties[pari].stats.econ - f), 2)
dist += Math.pow(Math.abs(parties[pari].stats.reli - g), 2)
dist += Math.pow(Math.abs(parties[pari].stats.scty - h), 2)
dist += Math.pow(Math.abs(parties[pari].stats.cult - i), 1.73856063)
if (dist < partydist) {
party = parties[pari].name
partydist = dist
}
}
document.getElementById("party-label").innerHTML = party
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*i-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, 65)
ctx.font="350 40px Montserrat"
ctx.textAlign="left"
ctx.fillText(party, 20, 100)
ctx.font="40px Montserrat"
ctx.textAlign="left"
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 (i > 20) {ctx.fillText(i + "%", 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("9axes.nadaradical.com", 780, 55)
ctx.fillText(version, 780, 90)
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>