-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
256 lines (256 loc) · 11.1 KB
/
index.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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="Quiz for learning Japanese kanji and Chinese hanzi">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/cjkquiz.css" rel="stylesheet" type="text/css">
<title>CJKQuiz</title>
<script>
function setZh()
{
var k,kmax,p;
var listJa=document.querySelectorAll(".selector.ja");
var listZh=document.querySelectorAll(".selector.zh");
var flagJa=document.querySelector(".flag.ja");
var flagZh=document.querySelector(".flag.zh");
kmax=listZh.length;
for(k=0;k<kmax;k++) listZh[k].style.display="block";
kmax=listJa.length;
for(k=0;k<kmax;k++) listJa[k].style.display="none";
flagJa.style.display="none";
flagZh.style.display="inline-block";
p=cjkq.getStore();
p.sourceLang="zh";
if(!/^(HSK|NHSK)[0-9]+$/.test(p.zhDicoName)) p.zhDicoName="NHSK1";
cjkq.setStore(p);
}
function setJa()
{
var k,kmax,p;
var listJa=document.querySelectorAll(".selector.ja");
var listZh=document.querySelectorAll(".selector.zh");
var flagJa=document.querySelector(".flag.ja");
var flagZh=document.querySelector(".flag.zh");
kmax=listZh.length;
for(k=0;k<kmax;k++) listZh[k].style.display="none";
kmax=listJa.length;
for(k=0;k<kmax;k++) listJa[k].style.display="block";
flagJa.style.display="inline-block";
flagZh.style.display="none";
p=cjkq.getStore();
p.sourceLang="ja";
if(!/^G[0-9]+$/.test(p.jaDicoName)) p.jaDicoName="G1";
cjkq.setStore(p);
}
function setEn()
{
var flagEn=document.querySelector(".flag.en");
var flagFr=document.querySelector(".flag.fr");
var settingsIcon=document.querySelector(".settingsIcon");
var reorderIcon=document.querySelector(".reorderIcon");
flagEn.style.display="inline-block";
flagFr.style.display="none";
settingsIcon.setAttribute("title","Settings");
settingsIcon.setAttribute("alt","Settings Icon");
reorderIcon.setAttribute("title","Reorder/Unorder");
reorderIcon.setAttribute("alt","Reorder Icon");
cjkq.setParamToStore("targetLang","en");
}
function setFr()
{
var flagEn=document.querySelector(".flag.en");
var flagFr=document.querySelector(".flag.fr");
var settingsIcon=document.querySelector(".settingsIcon");
var reorderIcon=document.querySelector(".reorderIcon");
flagEn.style.display="none";
flagFr.style.display="inline-block";
settingsIcon.setAttribute("title","Paramétrage");
settingsIcon.setAttribute("alt","Icône Paramétrage");
reorderIcon.setAttribute("title","Réordonner/Mélanger");
reorderIcon.setAttribute("alt","Icône Réordonner/Mélanger");
cjkq.setParamToStore("targetLang","fr");
}
function doCjkqOKSettings()
{
var e=document.querySelector(".settingsDialog");
cjkq.setParamToStore("numOfChars",e.querySelector('.numOfChars input').value);
cjkq.setParamToStore("timePerChar",e.querySelector('.timePerChar input').value);
cjkq.setParamToStore("reorderAtEnd",e.querySelector('.reorderAtEnd input').checked?"1":"0");
cjkq.setParamToStore("addSolutionAtEnd",e.querySelector('.addSolutionAtEnd input').checked?"1":"0");
function getSelectValue(name)
{
let select=document.querySelector('[name="'+name+'"]');
let v=select.options[select.selectedIndex].value;
if(v) return v;
return cjkq.params[name]; // change nothing
}
function getRadioValue(name)
{
let list=document.getElementsByName(name);
for(let k=0;k<list.length;k++) if (list[k].checked) return list[k].value;
return cjkq.params[name]; // change nothing
}
cjkq.setParamToStore("tileOrder",getSelectValue("tileOrder"));
cjkq.setParamToStore("displayMode",getRadioValue("displayMode"));
cjkq.start("");
}
function doCjkqSettings()
{
var e;
e=document.querySelector(".cjkq .settingsDialog");
if(!e)
{
let s,a,b={},v;
e=document.createElement("dialog");
e.classList.add("settingsDialog");
s="<form method=\"dialog\">";
s+="<h1>CJKQuiz</h1>";
a=(cjkq.params.targetLang=="fr")?"Nombre de caractères :":"Number of chars:";
s+="<label class=\"numOfChars\"><span>"+a+"</span><input type=\"number\" min=\"1\" max=\"30\"></label>";
a=(cjkq.params.targetLang=="fr")?"Temps par caractère :":"Time per char:";
s+="<label class=\"timePerChar\"><span>"+a+"</span><input type=\"number\" min=\"1\" max=\"30\"></label>";
s+="<fieldset>";
a=(cjkq.params.targetLang=="fr")?"Disposition initiale des tuiles":"Initial tile layout";
s+="<legend>"+a+"</legend>";
s+="<select name=\"tileOrder\">";
v="shuffled";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
a=(cjkq.params.targetLang=="fr")?"Mélangées":"Shuffled";
s+=a;
s+="</option>";
v="character transcription translation";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Kanji kana français":"Kanji Kana English";
b.zh=(cjkq.params.targetLang=="fr")?"Hanzi pinyin français":"Hanzi Pinyin English";
s+=b[cjkq.params.sourceLang];
s+="</option>";
v="character translation transcription";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Kanji français kana":"Kanji English Kana";
b.zh=(cjkq.params.targetLang=="fr")?"Hanzi français pinyin":"Hanzi English Pinyin";
s+=b[cjkq.params.sourceLang];
s+="</option>";
v="transcription translation character";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Kana français kanji":"Kana English Kanji";
b.zh=(cjkq.params.targetLang=="fr")?"Pinyin français hanzi":"Pinyin English Hanzi";
s+=b[cjkq.params.sourceLang];
s+="</option>";
v="transcription character translation";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Kana kanji français":"Kana Kanji English";
b.zh=(cjkq.params.targetLang=="fr")?"Pinyin hanzi français":"Pinyin Hanzi English";
s+=b[cjkq.params.sourceLang];
s+="</option>";
v="translation character transcription";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Français kanji kana":"English Kanji Kana";
b.zh=(cjkq.params.targetLang=="fr")?"Français hanzi pinyin":"English Hanzi Pinyin";
s+=b[cjkq.params.sourceLang];
s+="</option>";
v="translation transcription character";
s+="<option value=\""+v+"\""+(v==cjkq.params.tileOrder?" selected":"")+">";
b.ja=(cjkq.params.targetLang=="fr")?"Français kana kanji":"English Kana Kanji";
b.zh=(cjkq.params.targetLang=="fr")?"Français pinyin hanzi":"English Pinyin Hanzi";
s+=b[cjkq.params.sourceLang];
s+="</option>";
s+="</select>"
s+="</fieldset>";
a=(cjkq.params.targetLang=="fr")?"Réordonner à la fin":"Reorder at end";
s+="<label class=\"reorderAtEnd\"><input type=\"checkbox\"><span>"+a+"</span></label>";
a=(cjkq.params.targetLang=="fr")?"Numéros sur les solutions":"Numbers on the solutions";
s+="<label class=\"addSolutionAtEnd\"><input type=\"checkbox\"><span>"+a+"</span></label>";
s+="<fieldset>";
a=(cjkq.params.targetLang=="fr")?"Mode d'affichage":"Display mode";
s+="<legend>"+a+"</legend>";
a=(cjkq.params.targetLang=="fr")?"Sombre":"Dark";
s+="<label class=\"displayMode\"><input type=\"radio\" name=\"displayMode\" value=\"dark\"><span>"+a+"</span></label>";
a=(cjkq.params.targetLang=="fr")?"Clair":"Light";
s+="<label class=\"displayMode\"><input type=\"radio\" name=\"displayMode\" value=\"light\"><span>"+a+"</span></label>";
s+="</fieldset>";
s+="<button value=\"OK\">OK</button>";
s+="<button value=\"cancel\">"+((cjkq.params.targetLang=="fr")?"Annuler":"Cancel")+"</button>";
s+="</form>";
e.innerHTML=s;
e.addEventListener("close",function()
{
if(this.returnValue=="OK") doCjkqOKSettings();
});
document.querySelector(".cjkq").appendChild(e);
}
e.querySelector('.numOfChars input').value=cjkq.params.numOfChars;
e.querySelector('.timePerChar input').value=cjkq.params.timePerChar;
e.querySelector('.reorderAtEnd input').checked=(cjkq.params.reorderAtEnd=="1");
e.querySelector('.addSolutionAtEnd input').checked=(cjkq.params.addSolutionAtEnd=="1");
function setSelectValue(name,value)
{
let list=document.getElementsByName(name);
for(let k=0;k<list.length;k++) list[k].selected=(list[k].value==value);
return cjkq.params[name]; // change nothing
}
function setRadioValue(name,value)
{
let list=document.getElementsByName(name);
for(let k=0;k<list.length;k++) list[k].checked=(list[k].value==value);
}
setSelectValue("tileOrder",cjkq.params.tileOrder);
setRadioValue("displayMode",cjkq.params.displayMode);
e.showModal();
}
function doCjkqReorder()
{
if(cjkq.reordered) cjkq.unorder();
else cjkq.reorder();
}
</script>
</head>
<body>
<main>
<ul class="selector settings">
<li class="flag zh"><button onclick="setJa();cjkq.start('');"><img alt="中国国旗" title="中国话" src="_img/chn23.svg" width="48" height="32"></button></li>
<li class="flag ja"><button onclick="setZh();cjkq.start('');"><img alt="日本の国旗" title="日本語" src="_img/jap23.svg" width="48" height="32"></button></li>
<li class="icon"><button onclick="doCjkqSettings();"><img class="settingsIcon" alt="Settings Icon" title="Settings" src="_img/settings.svg" width="32" height="32"></button></li>
<li class="icon"><button onclick="doCjkqReorder()"><img class="reorderIcon" alt="Reorder Icon" title="Reorder" src="_img/reorder.svg" width="32" height="32"></button></li>
<li class="flag en"><button onclick="setFr();cjkq.start('');"><img alt="British flag" title="English" src="_img/gbr23.svg" width="48" height="32"></button></li>
<li class="flag fr"><button onclick="setEn();cjkq.start('');"><img alt="Drapeau français" title="Français" src="_img/fra23.svg" width="48" height="32"></button></li>
</ul>
<ul class="selector ja">
<!--<li><button onclick="cjkq.start('TestJa');">Test</button></li>-->
<li><button onclick="cjkq.start('G1');">1</button></li>
<li><button onclick="cjkq.start('G2');">2</button></li>
<li><button onclick="cjkq.start('G3');">3</button></li>
<li><button onclick="cjkq.start('G4');">4</button></li>
<li><button onclick="cjkq.start('G5');">5</button></li>
<li><button onclick="cjkq.start('G6');">6</button></li>
<li><button onclick="cjkq.start('G7');">7</button></li>
<li><button onclick="cjkq.start('G8');">8</button></li>
</ul>
<ul class="selector zh">
<!--<li><button onclick="cjkq.start('TestZh');">Test</button></li>-->
<li><button onclick="cjkq.start('NHSK1');">1</button></li>
<li><button onclick="cjkq.start('NHSK2');">2</button></li>
<li><button onclick="cjkq.start('NHSK3');">3</button></li>
<li><button onclick="cjkq.start('NHSK4');">4</button></li>
<li><button onclick="cjkq.start('NHSK5');">5</button></li>
<li><button onclick="cjkq.start('NHSK6');">6</button></li>
<li><button onclick="cjkq.start('NHSK7');">7</button></li>
<li><button onclick="cjkq.start('NHSK8');">8</button></li>
<li><button onclick="cjkq.start('NHSK9');">9</button></li>
</ul>
<script src="cjkquiz.js"></script>
<script>
window.addEventListener("load",function()
{
if(cjkq.getParamFromStore("sourceLang")=="zh") setZh();
else setJa();
if(cjkq.getParamFromStore("targetLang")=="en") setEn();
else setFr();
cjkq.start();
}
);
</script>
</main>
</body>
</html>