-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.html
196 lines (169 loc) · 4.78 KB
/
template.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Thailand driving exam questions by artslob</title>
<script>
var is_hided = true;
// { page_number } original source page
var options = [
{{ for variant in answer_choices }}
'<p {{ if variant.is_answer }}class="answer"{{ endif }}>{ variant.text }</p>',
{{ endfor }}
];
window.onload = function () \{
options = shuffle(options);
var options_div = document.getElementById('options');
for (var q = 0; q < options.length; q++) \{
options_div.insertAdjacentHTML('beforeend', options[q]);
}
};
function answer() \{
is_hided = !is_hided;
var answer_variants = document.getElementsByClassName('answer');
for (var i = 0; i < answer_variants.length; i++) \{
answer_variants[i].style.color = (is_hided) ? 'black' : 'red';
}
}
function rnd() \{
var max = { total };
var min = 1;
var res = Math.floor(Math.random() * (max - min + 1)) + min;
location.href = '../' + res;
}
function shuffle(array) \{
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) \{
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function prev_page() \{
{{ if previous_index }}
location.href='../{ previous_index }';
{{ endif }}
}
function next_page() \{
{{ if next_index }}
location.href='../{ next_index }';
{{ endif }}
}
window.addEventListener("keydown", function (event) \{
if (event.defaultPrevented)
return;
switch (event.key) \{
case "a":
case "A":
case "ArrowLeft":
prev_page();
break;
case "d":
case "D":
case "ArrowRight":
next_page();
break;
case "w":
case "W":
case "ArrowUp":
answer();
break;
case "s":
case "S":
case "ArrowDown":
rnd();
break;
default:
return;
}
event.preventDefault();
}, true);
</script>
<style>
button \{
width: 25%;
}
h1 \{
font-size: 2.5rem;
}
h2 \{
font-size: 2.25rem;
}
h3 \{
font-size: 2rem;
}
h4 \{
font-size: 1.75rem;
}
h5 \{
font-size: 1.5rem;
}
h6 \{
font-size: 1.25rem;
}
p \{
font-size: 2rem;
}
button \{
font-size: 2rem;
}
@media (max-width: 480px) \{
html \{
font-size: 30px;
}
}
@media (min-width: 480px) \{
html \{
font-size: 30px;
}
}
@media (min-width: 768px) \{
html \{
font-size: 30px;
}
}
@media (min-width: 992px) \{
html \{
font-size: 20px;
}
}
@media (min-width: 1200px) \{
html \{
font-size: 20px;
}
}
</style>
</head>
<body>
<h3>{ title }</h3>
{{ if img_src }}
<img src="../{ img_src }" />
{{ endif }}
<div id="options"></div>
<div style="text-align: center">
<button onclick="answer()">Answer!</button>
<br/><br/>
<button onclick="rnd();" id="rnd" type="button" style="float: none">
Random question
</button>
</div>
{{ if previous_index }}
<button onclick="prev_page()" type="button" style="float: left">
Previous page
</button>
{{ endif }}
{{ if next_index }}
<button onclick="next_page()" type="button" style="float: right">
Next page
</button>
{{ endif }}
<br/>
<br/>
</body>
</html>