-
Notifications
You must be signed in to change notification settings - Fork 0
/
poltest.html
61 lines (60 loc) · 4.71 KB
/
poltest.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
<html>
<head>
</head>
<body>
<div style="display:none;">
<img id="dot" src="dot.png"><img id="line" src="line.png">
</div>
</body>
<script>
const english = ["The authority of the state should be challenged.","One's rights are defined by the law of the jurisdiction they are under.","Identity (such as nationality, race, gender, sexuality) is something of importance.","It is an objective fact that some sentient beings have more moral worth than others.","Even through significant political disagreement, a nation should always remain united.","Whether or not it is a good thing to do, people have a right to use violence against unjustifiably violent groups.","It is possible for the existence of a state to be just.","Follwing traditions for the sake of it can be described as a 'dangerous, emotional reaction'.","Some acts that do not impact other sentient beings can be considered immoral.","It is fair that political discussions should sometimes be deliberately avoided.", "The power of authority should be limited as much as is safe."]
const resus = [true, false, false, false, false, true, false, true, false, false, true]
const english2 = ['Agree', 'Neutral', 'Disagree', 'Result', 'Score', 'left', 'right', '(complete centre)']
const engdesc = "This test attempts to use a set of questions to assess whether the user is left or right wing, and to what extent. Unlike most other tests, this tries to refer to the general ideas of being left or right rather than focusing on more specific issues, which in reality cannot always be fit as nicely on this spectrum as many may believe, and many movements considered left or right are often the opposite. It therefore is possible that your result will be different to your expectations. The left can be defined as wanting to minimise social hierarchy, whereas the right can be defined as wanting to keep or increase it. Seeing these definitions alone, it can be seen that the left is generally libertarian and the right authoritarian, almost by definition. The right will also in order to protect power oppose progressive movements trying to reduce authority, and the left will support them.</br></br>This test will give you a score between 0 and 1 (0 being centre, 1 being far left or right) and a picture showing the result on a chart. If you do not understand any of the terms, please look them up, as putting Neutral or skipping a question will still have an impact on the final score. If you have any feedback or questions, please feel free to contact me using <a href='mailto:[email protected]'>[email protected]</a>.</br></br>"
const agreed = english2
const questions = english
const desc = engdesc
document.body.innerHTML += desc
var i = 0n
while (i < questions.length) {
var ia = resus[i] ? 'l' : 'r'
var ib = resus[i] ? 'r' : 'l'
document.body.innerHTML += "<span id='q" + i + "'>" + questions[i] +"</span></br><input type='radio' name='q" + i + "' value='Agree' id='" + ia + i +"'></input> " + agreed[0] + "</br><input type='radio' name='q" + i + "' value='Neutral'></input> " + agreed[1] + "</br><input type='radio' name='q" + i + "' value='Disagree' id='" + ib + i +"'></input> " + agreed[2] + "</br>"
i += 1n
}
document.body.innerHTML += "<input type='button' onclick='scoref()' value='" + agreed[3] + "'><span id='result'></span>"
function scorestr(score) {
score *= 10n
const characters = "0123456789"
var str = "0."
str += characters[score/BigInt(questions.length)]
score = (score % BigInt(questions.length))*10n
str += characters[score/BigInt(questions.length)]
return str
}
function scoref() {
var score = 0n
i = 0n
while (i < questions.length) {
if (document.getElementById("r" + i).checked) score += 1n
if (document.getElementById("l" + i).checked) score -= 1n
i += 1n
}
const pos = ((Number(score))/questions.length + 1) * 75 - 8
if (!score) document.getElementById("result").innerHTML = agreed[4] + ": 0.00 " + agreed[7]
else if (score < 0n) {
score = -score
if (score == questions.length) document.getElementById("result").innerHTML = agreed[4] + ": 1.00 " + agreed[5]
else document.getElementById("result").innerHTML = agreed[4] + ": " + scorestr(score) + " " + agreed[5]
}
else {
if (score == questions.length) document.getElementById("result").innerHTML = agreed[4] + ": 1.00 " + agreed[6]
else document.getElementById("result").innerHTML = agreed[4] + ": " + scorestr(score) + " " + agreed[6]
}
document.getElementById("result").innerHTML += "<canvas id='resultpic' width='150' height='45'>"
var resultp = document.getElementById("resultpic").getContext("2d")
resultp.drawImage(document.getElementById("line"), 0, 0)
resultp.drawImage(document.getElementById("dot"), pos, 14)
}
</script>
</html>