-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdic.html
executable file
·101 lines (101 loc) · 4.19 KB
/
dic.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>mỉetōa</title>
<link rel="stylesheet" type="text/css" href="./dic.css" media="screen">
<script src="./toaq_dict.js"></script>
<script>
function cz(e) {
this.e = e;
this.b = (e.style["background-color"]==="rgb(206, 12, 120)")?(true):(false);
this.m = function() { this.c(); return this.b = !this.b }
this.s = function(bool) { if (!this.b) { this.c() }; return this.b = bool }
this.c = function() { this.e.style.background=(this.b)?("#333"):("#ce0c78"); }
}
function undiak(toa) {
return toa.replace(/[áàâāãǎả]/g,"a").replace(/[éèêēẽěẻ]/g,"e").replace(/[íìîīĩǐỉ]/g,"i").replace(/[óòôōõǒỏ]/g,"o").replace(/[úùûūũǔủ]/g,"u")
}
function kaoti(i) {
return "<tr><td>" + data[i].dtoaq + "</td><td>" + data[i].ten + "</td></tr><tr><td>" + data[i].den + "</td></tr>";
}
function dmea(args,toa) {
return args.map(e => e.indexOf(toa)+1).reduce((a,x) => a || x)
}
function djeq(args,toa) {
return args.map(e => e == toa).reduce((a,x) => a || x)
}
function dsiao(args,toa) {
return args.map(e => e.indexOf(toa) == 0).reduce((a,x) => a || x)
}
function duasho(ta) {
var mea = ""
var fields = keyczs.filter(j => czs[j].b ).map(j => (e => data[e][j]))
if (fields.length) {
if (ta) {
var jeq = ""
var siao = ""
toa=undiak(ta);
for (i in data) {
var rec = fields.map(e => e(i)).filter(e => e !== undefined)
if (djeq(rec,toa)) { jeq += kaoti(i) } else if (dsiao(rec,toa)) { siao += kaoti(i) } else if (dmea(rec,toa)) { mea += kaoti(i) }
}
gosho.innerHTML = (jeq+siao+mea)?(jeq+siao+mea):("<tr><td>Nothing found!</td></tr>")
window.history.pushState({}, null, "dic.html#"+ta);
document.title = "mỉetōa: "+ta
} else {
gosho.innerHTML = "<tr><td>Empty search!</td></tr>"
window.history.pushState({}, null, "dic.html#");
document.title = "mỉetōa"
}
} else { for (i in data) {
mea += kaoti(i) }; gosho.innerHTML = mea
window.history.pushState({}, null, "dic.html#");
document.title = "mỉetōa"
}
nitoa.focus();
}
function urldua() {
var p = location.href.indexOf("#")
if (p!==-1) {
var a = location.href.slice(p+1).split("&")
var b = decodeURI(a[0]);
for (i in keyczs) { if (a.slice(1).includes(keyczs[i])) { czs[keyczs[i]].s(true)} }
nitoa.value = b; duasho(b);
}
}
function nitov() {
return nitoa.value.toLowerCase()
}
window.onload = function() {
toaqcz = new cz(document.getElementById("toaq"));
dencz = new cz(document.getElementById("den"));
gencz = new cz(document.getElementById("gen"));
tencz = new cz(document.getElementById("ten"));
czs = {"toaq":toaqcz,"den":dencz,"ten":tencz,"gen":gencz}
keyczs = Object.keys(czs)
nitoa = document.getElementById("nitoa");
gosho = document.getElementById("gosho")
window.addEventListener('popstate', urldua);
nitoa.focus();
urldua();
}
</script>
</head>
<body>
<fieldset>
<form>
<span class="check" onclick="toaqcz.m();duasho(nitov());"><span class="sao"><span class="nui" id="toaq" style="background:#ce0c78"></span></span><label>toaq</label></span>
<span class="check" onclick="dencz.m();duasho(nitov());"><span class="sao"><span class="nui" id="den" style="background:#ce0c78"></span></span><label>description</label></span>
<span class="check" onclick="tencz.m();duasho(nitov());"><span class="sao"><span class="nui" id="ten"></span></span><label>type</label></span>
<span class="check" onclick="gencz.m();duasho(nitov());"><span class="sao"><span class="nui" id="gen"></span></span><label>gloss</label></span>
</form>
</fieldset>
<div id="tuai">
<input id="nitoa" type="text" placeholder="" size="14" onkeyup="duasho(nitov());" />
<br /><br />
<table id="gosho"></table>
<noscript>Your browser does not support JavaScript, which is required to make this dictionary works.</noscript>
</div>
</body>
</html>