-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
168 lines (168 loc) · 6.68 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
<!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="Draw kanji of hanzi">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/cjkdraw.css" rel="stylesheet" type="text/css">
<title>CJKDraw</title>
<script>
function setAnimCJKDir()
{
// change this to any convenient path to animCJK
cjkd.setParamToStore("animCJKDir","/animCJK/official/");
}
function doCjkdOKSettings()
{
var e=document.querySelector(".settingsDialog");
cjkd.setParamToStore("gridOn",e.querySelector('.gridOn input').checked?"1":"0");
cjkd.setParamToStore("hintOn",e.querySelector('.hintOn input').checked?"1":"0");
cjkd.params.gridOn=cjkd.getParamFromStore("gridOn");
cjkd.params.hintOn=cjkd.getParamFromStore("hintOn");
if(cjkd.params.gridOn=="0") document.querySelector(".cjkd .grid").style.display="none";
else document.querySelector(".cjkd .grid").style.display="block";
if(cjkd.params.hintOn=="0") document.querySelector(".cjkd .hint").style.display="none";
else document.querySelector(".cjkd .hint").style.display="block";
}
function doCjkdSettings()
{
var e;
e=document.querySelector(".cjkd .settingsDialog");
if(!e)
{
let s,a;
e=document.createElement('dialog');
e.classList.add("settingsDialog");
s="<form method='dialog'>";
s+="<h1>CJKDraw</h1>";
a=(cjkd.params.targetLang=="fr")?"Grille":"Grid";
s+="<label class='gridOn'><input type='checkbox'><span>"+a+"</span></label>";
a=(cjkd.params.targetLang=="fr")?"Indication":"Hint";
s+="<label class='hintOn'><input type='checkbox'><span>"+a+"</span></label>";
s+="<button value='OK'>OK</button>";
s+="<button value='cancel'>"+((cjkd.params.targetLang=="fr")?"Annuler":"Cancel")+"</button>";
s+="</form>";
e.innerHTML=s;
e.addEventListener('close',function()
{
if(this.returnValue=="OK") doCjkdOKSettings();
});
document.querySelector(".cjkd").appendChild(e);
}
e.querySelector('.gridOn input').checked=(cjkd.params.gridOn=="1");
e.querySelector('.hintOn input').checked=(cjkd.params.hintOn=="1");
e.showModal();
}
function doCjkdScore()
{
let a,s="";
if(cjkd.params.results[cjkd.params.sourceLang])
a=cjkd.params.results[cjkd.params.sourceLang][cjkd.dicoName];
if (a&&cjkd.dico)
{
let k,km,n,m;
km=cjkd.dico.length;
s+="<div class='charScoreList'>";
for(k=0;k<km;k++)
{
if(a[cjkd.dico[k][0]])
{
m=a[cjkd.dico[k][0]][1];
n=a[cjkd.dico[k][0]][0];
}
else
{
m=0;
n=0;
}
s+="<div>";
s+="<span lang='"+cjkd.params.sourceLang+"'>"+cjkd.dico[k][0]+"</span>: ";
s+=m+"/"+n;
s+="</div>";
}
s+="</div>";
}
if(!s) s=(cjkd.params.targetLang=="fr")?"Pas de données !":"No data!";
s="<div class='scoreDicoName'>"+cjkd.dicoName+"</div>"+s;
cjkd.alert(s,"Score","scoreAlert");
}
</script>
</head>
<body>
<h1>CJKDraw</h1>
<ul class="selector settings">
<li class="flag zhHans"><button onclick="cjkd.setSourceLang('ja');cjkd.start('');"><img alt="中国国旗" title="中国话" src="_img/chn23.svg" width="48" height="32"></button></li>
<li class="flag ja"><button onclick="cjkd.setSourceLang('zhHans');cjkd.start('');"><img alt="日本の国旗" title="日本語" src="_img/jap23.svg" width="48" height="32"></button></li>
<li class="icon"><button onclick="doCjkdSettings();"><img class="settingsIcon" alt="Settings Icon" title="Settings" src="_img/settings.svg" width="32" height="32"></button></li>
<li class="icon"><button onclick="doCjkdScore();"><img class="scoreIcon" alt="Score Icon" title="Score" src="_img/score.svg" width="32" height="32"></button></li>
<li class="flag en"><button onclick="cjkd.setTargetLang('fr');cjkd.start('');"><img alt="British flag" title="English" src="_img/gbr23.svg" width="48" height="32"></button></li>
<li class="flag fr"><button onclick="cjkd.setTargetLang('en');cjkd.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="cjkd.start('G1');">1</button></li>
<li><button onclick="cjkd.start('G2');">2</button></li>
<li><button onclick="cjkd.start('G3');">3</button></li>
<li><button onclick="cjkd.start('G4');">4</button></li>
<li><button onclick="cjkd.start('G5');">5</button></li>
<li><button onclick="cjkd.start('G6');">6</button></li>
<li><button onclick="cjkd.start('G7');">7</button></li>
<li><button onclick="cjkd.start('G8');">8</button></li>
</ul>
<ul class="selector zhHans">
<li><button onclick="cjkd.start('NHSK1');">1</button></li>
<li><button onclick="cjkd.start('NHSK2');">2</button></li>
<li><button onclick="cjkd.start('NHSK3');">3</button></li>
<li><button onclick="cjkd.start('NHSK4');">4</button></li>
<li><button onclick="cjkd.start('NHSK5');">5</button></li>
<li><button onclick="cjkd.start('NHSK6');">6</button></li>
<li><button onclick="cjkd.start('NHSK7');">7</button></li>
<li><button onclick="cjkd.start('NHSK8');">8</button></li>
<li><button onclick="cjkd.start('NHSK9');">9</button></li>
</ul>
<script src="cjkdraw.js"></script>
<script>
cjkd.setSourceLang=function(lang)
{
let k,kmax,p;
let listJa=document.querySelectorAll(".selector.ja");
let listZhHans=document.querySelectorAll(".selector.zhHans");
let flagJa=document.querySelector(".flag.ja");
let flagZhHans=document.querySelector(".flag.zhHans");
kmax=listJa.length;
for(k=0;k<kmax;k++) listJa[k].style.display=(lang=="ja")?"block":"none";
kmax=listZhHans.length;
for(k=0;k<kmax;k++) listZhHans[k].style.display=(lang=="zhHans")?"block":"none";
flagJa.style.display=(lang=="ja")?"inline-block":"none";
flagZhHans.style.display=(lang=="zhHans")?"inline-block":"none";
p=cjkd.getStore();
p.sourceLang=lang;
if(!/^G[0-9]+$/.test(p.jaDicoName)) p.jaDicoName="G1";
if(!/^(HSK|NHSK)[0-9]+$/.test(p.zhHansDicoName)) p.zhHansDicoName="NHSK1";
cjkd.setStore(p);
}
cjkd.setTargetLang=function(lang)
{
let flagEn=document.querySelector(".flag.en");
let flagFr=document.querySelector(".flag.fr");
let settingsIcon=document.querySelector(".settingsIcon");
let scoreIcon=document.querySelector(".scoreIcon");
flagEn.style.display=(lang=="en")?"inline-block":"none";
flagFr.style.display=(lang=="fr")?"inline-block":"none";
settingsIcon.setAttribute("title",(lang=="fr")?"Settings":"Paramètres");
settingsIcon.setAttribute("alt",(lang=="fr")?"Settings Icon":"Icône paramètres");
scoreIcon.setAttribute("title",(lang=="fr")?"Score":"Score");
scoreIcon.setAttribute("alt",(lang=="fr")?"Score Icon":"Icône score");
cjkd.setParamToStore("targetLang",lang);
}
window.addEventListener("load",function()
{
cjkd.setSourceLang(cjkd.getParamFromStore("sourceLang"));
cjkd.setTargetLang(cjkd.getParamFromStore("targetLang"));
setAnimCJKDir();
cjkd.init();
}
);
</script>
</body>
</html>