-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlearn.html
269 lines (245 loc) · 12.1 KB
/
learn.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
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html lang="zh-Hant-TW" >
<head>
<meta charset="UTF-8" />
<title>單字查詢 | 篆來篆去</title>
<link rel="stylesheet" href="assets/css/main.css" />
<script src = "./assets/db/essential.js"></script>
<script src = "./assets/db/fontmap.js"></script>
<script src = "./assets/db/tree.js"></script>
<style type="text/css">
[onClick] {
cursor:pointer;
}
</style>
</head>
<body align = "center">
<style type="text/css">
input[type="text"]:focus {
border-color: rgba(255, 255, 255, 1);
box-shadow: 0 0 0 1px #CCCCCC;
color: #ffFFFF;
}
</style>
<script>
var str_url = window.location.href;
var this_url = new URL(str_url);
var thisidx = 1;
function GenerateTable(query,ischild) {
//Build an array containing Customer records.
if (ischild)
thismap = zhuan_map_child;
else
thismap = zhuan_map_parent;
var pics = new Array();
if (!(query in thismap))
thismap[query] = new Array();
for (var i = 0; i < thismap[query].length; i+=5) {
var row_data = thismap[query].slice(i,i+5);
pics.push(row_data);
}
//Create a HTML Table element.
var table = document.createElement("TABLE");
table.border = "0";
//Get the count of columns.
//Add the data rows.
for (var i = 0; i < pics.length; i++) {
row = table.insertRow(-1);
row.style["white-space"] = "nowrap";
row.align="center";
for (var j = 0; j < pics[i].length; j++) {
var cell = row.insertCell(-1);
cell.style["display"] = "inline-block";
cell.style["padding"] = "20px";
var img_inc = document.createElement("img");
img_inc.src = "./assets/db/img/"+pics[i][j]+".png";
img_inc.alt = pics[i][j];
img_inc.style = "height:100px;width:100px;";
img_inc.onclick = function() {goto_word(this.alt);};
img_inc.style.cursor = "pointer";
img_inc.onmouseover = function() {hover(this);};
img_inc.onmouseout = function() {unhover(this);};
cell.appendChild(img_inc);
}
}
if (ischild)
var dvTable = document.getElementById("pic_zhuan_child");
else
var dvTable = document.getElementById("pic_zhuan_parent");
dvTable.innerHTML = "";
dvTable.appendChild(table);
}
function find_word(){
var thiskey = document.getElementById("query").value;
if (thiskey.length == 0) {
return;
} else if (thiskey.length >= 1) {
if (!(thiskey in h2z)){
canvas_clear();
document.getElementById("zhuan_def").innerHTML = thiskey + "不在我們的資料庫裡!";
adjust_padding();
return;
}
query_img = h2z[thiskey];
} else { //TODO multitext support
query_img = h2z[thiskey][0];
}
thisidx = z2i[h2z[thiskey]];
goto_word(query_img);
}
function goto_word(query_img){
//alert(query_img)
document.getElementById("meassage_ex").style.display = "none";
document.getElementById("pic_zhuan").src = "./assets/db/img/"+query_img+".png";
document.getElementById("pic_zhuan").alt = query_img;
document.getElementById("pic_kai").src = "./assets/db/img/"+z2k[query_img]+".png";
document.getElementById("pic_kai").alt = z2k[query_img];
//document.getElementById("debugger").innerHTML = thiskey.length.toString();
document.getElementById("zhuan_def").innerHTML = zhuanid_map_all[z2i[query_img]]['meaning'];
document.getElementById("zhuan_main").innerHTML = "部首";
document.getElementById("pic_zhuan_main").src = "./assets/db/img/"+zhuanid_map_all[zhuanid_map_all[z2i[query_img]]['major']]['fonts'][1][0]+".png";
document.getElementById("pic_zhuan_main").alt = zhuanid_map_all[zhuanid_map_all[z2i[query_img]]['major']]['fonts'][1][0];
document.getElementById("zhuan_child").innerHTML = "子部件";
document.getElementById("zhuan_parent").innerHTML = "衍生字";
document.getElementById("query").value = "";
GenerateTable(query_img,true);
GenerateTable(query_img,false);
//adjust padding
setTimeout(adjust_padding, 100);
}
function random_word(){
var randomIndex = Math.floor(Math.random() * 9831)+1;
thisidx = randomIndex;
var thiskey = zhuanid_map_all[randomIndex]['han'][0]
document.getElementById("query").value = thiskey
//thiskey = document.getElementById("query").value;
if (thiskey.length == 0) {
return;
} else if (thiskey.length >= 1) {
query_img = zhuanid_map_all[randomIndex]['fonts'][1][0];
} else { //TODO multitext support
query_img = zhuanid_map_all[randomIndex]['fonts'][1][0];
}
goto_word(query_img);
}
</script>
<!--style="border-color:#ff3366;border-width: 5px; border-style: solid;" for debugging div-->
<header id="header" class="alt">
<div class="logo"><a href="index.html">篆來篆去</a></div>
<div align="right" style="width: 15%; display: inline-block; ">
<button id="btn_fuzzy" onclick="random_word()" style="background-color: Transparent; border:none;font-size: 16px">藥房抓一帖</button>
</div>
<div align="center" style="width: 10%; display: inline-block; ">
<input id="query" type="text" style=" text-align: center; border-color: white;border-width: 1px;color: white"></input>
</div>
<div align="left" style="width: 25%; display: inline-block; ">
<button id="btn_search" onclick="find_word()" style="background-color: Transparent; border:none;font-size: 16px">搜 尋</button>
</div>
<div align="right" style="width: 20%; display: inline-block; ">
<a href="#menu" ><span > Menu </span></a>
</div>
</header>
<!-- Nav -->
<nav id="menu">
<ul class="links" style="text-align: left;">
<li><a href="index.html">首頁</a></li>
<li><a href="generic.html">作品詳介</a></li>
<li><a href="index.html#two">開始學習</a></li>
</ul>
</nav>
<section id="post" class="wrapper bg-img" data-bg="banner8.jpeg" style="padding-bottom: 120px">
<div id="canvas" class="inner" >
<article class="box" style="background-color: rgba(255, 255, 255, 0.7); color: black; padding: 20px 10px;">
<!--div style = "float: left;"><a href="game_character.html" style =""><button style = "float: left;">回遊戲選單</button></a></div>
<div id = "btn_next_div" style = "float: right;">
<button type="button" style = "float: right;" id="btn_next" onclick="gen_q()" >下一題</button>
</div>
<div>
<p id="now_q_idx" align="center"></p>
</div-->
<p id="meassage_ex" style="font-size: 24pt;" text-align="center"><br>~說明~<br> 歡迎使用篆來篆去查詢系統!<br>輸入您想要查詢的字,或利用「藥房抓一帖」隨機產生<br>「子部件」以及「衍生字」欄位的字都可以進一步點選觀看喔<br> </p>
<div>
<img id="pic_zhuan" src="" alt = "" width="27.5%">
<img id="pic_kai" src="" alt = "" width="27.5%">
</div>
<div id = "debugger"></div>
<div id = "zhuan_def" style="font-size: 40px;"></div>
<div id = "zhuan_main" style="font-size: 24px;"></div>
<div>
<img id="pic_zhuan_main" src="" alt = "" width="27.5%" onclick = "goto_word(this.alt)" onmouseover = "hover(this)" onmouseout = "unhover(this)" style = "height:100px;width:100px;">
</div>
<div id = "zhuan_child" style="font-size: 24px;"></div>
<div id="pic_zhuan_child" align="center"></div>
<div id = "zhuan_parent" style="font-size: 24px;"></div>
<div id="pic_zhuan_parent" align="center"></div>
</article>
</div>
</section>
<script type="text/javascript">
var query = this_url.searchParams.get("query");
if (query) {
document.getElementById("query").value = query;
find_word();
}
//initialize padding
function adjust_padding() {
var wheight = window.innerHeight;
var heading = document.getElementById("post");
var canvas = document.getElementById("canvas");
var eheight = canvas.clientHeight;
var to_pad = wheight - eheight - 160;
if (to_pad <= 120)
to_pad = 120;
var to_pad_str = to_pad.toString()+"px";
heading.style["padding-bottom"] = to_pad_str;
window.scrollTo(0,0);
}
adjust_padding();
function canvas_clear(){
var canvas = document.getElementById("canvas");
canvas.innerHTML = String.raw `<article class="box" style="background-color: rgba(255, 255, 255, 0.7); color: black; padding: 20px 10px;">
<!--div style = "float: left;"><a href="game_character.html" style =""><button style = "float: left;">回遊戲選單</button></a></div>
<div id = "btn_next_div" style = "float: right;">
<button type="button" style = "float: right;" id="btn_next" onclick="gen_q()" >下一題</button>
</div>
<div>
<p id="now_q_idx" align="center"></p>
</div-->
<p id="meassage_ex" style="font-size: 24pt;display:none;" text-align="center";><br>~說明~<br> 歡迎使用篆來篆去查詢系統!<br>輸入您想要查詢的字,或利用「藥房抓一帖」隨機產生<br>「子部件」以及「衍生字」欄位的字都可以進一步點選觀看喔<br> </p>
<div>
<img id="pic_zhuan" src="" alt = "" width="27.5%">
<img id="pic_kai" src="" alt = "" width="27.5%">
</div>
<div id = "debugger"></div>
<div id = "zhuan_def" style="font-size: 40px;"></div>
<div id = "zhuan_main" style="font-size: 24px;"></div>
<div>
<img id="pic_zhuan_main" src="" alt = "" width="27.5%" onclick = "goto_word(this.alt)" onmouseover = "hover(this)" onmouseout = "unhover(this)" style = "height:100px;width:100px;">
</div>
<div id = "zhuan_child" style="font-size: 24px;"></div>
<div id="pic_zhuan_child" align="center"></div>
<div id = "zhuan_parent" style="font-size: 24px;"></div>
<div id="pic_zhuan_parent" align="center"></div>
</article>`;
}
function hover(element) {
element.setAttribute('src', "./assets/db/img/"+z2k[element.alt]+".png");
}
function unhover(element) {
element.setAttribute('src', "./assets/db/img/"+element.alt+".png");
}
document.onkeydown = function(e){
if(e.keyCode == 13){
find_word();// submit
}
};
</script>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>