-
Notifications
You must be signed in to change notification settings - Fork 0
/
revise.html
101 lines (95 loc) · 3.35 KB
/
revise.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
---
permalink: /revise.html
layout: default
author_profile: false
---
<link href="https://fonts.googleapis.com/css?family=Shippori Mincho" rel="stylesheet">
<script src="./kanji.js" type="module"></script>
<script type="module">
import kanjiJS from "./kanji.js";
const kanji_db = kanjiJS.kanji_db;
const searchParams = new URLSearchParams(window.location.search);
const kanji_q = searchParams.get("");
if(!kanji_q) window.location.href = "?=一#a";
else window.location.href = "#a";
const kanji = kanji_db[kanji_q];
const createPartial = (func, ...args) => {
// const args = Array.prototype.slice.call(arguments, 1);
return function () {
// const allArguments = args.concat(Array.prototype.slice.call(arguments));
return func.apply(this, args);
};
}
const parseReadings = () => {
const readings = kanji["readings"];
const res = Array();
for(const [x,p] of Object.entries(readings)) res.push(`${x} (${p})`);
return res.join("、");
}
document.getElementById("kanji-name").innerHTML = kanji["kanji"];
document.getElementById("rtk-num").innerHTML = `RTK: ${kanji["no"]}`;
document.getElementById("rtk-kw").innerHTML = kanji["kw"];
document.getElementById("grade").innerHTML = kanji["type"];
document.getElementById("readings").innerHTML = parseReadings();
document.getElementById("words").innerHTML = kanjiJS.format_words(kanji);
document.getElementById("prv-btn").onclick = createPartial(kanjiJS.nav, kanji, -1);
document.getElementById("nxt-btn").onclick = createPartial(kanjiJS.nav, kanji, 1);
document.addEventListener("keydown", e => {
if (e.key == "." && e.ctrlKey) kanjiJS.nav(kanji, 1);
else if (e.key == "," && e.ctrlKey) kanjiJS.nav(kanji, -1);
})
</script>
<section id="a" data-instant-mousedown-shortcut data-instant-intensity="viewport-all">
<div class="wrapper">
<div style="text-align: center;">
<p><span id="kanji-name"></span><br>
<span id="rtk-kw"></span><br></p>
<p>
<span id="rtk-num"></span><br>
<span id="grade"></span><br></p>
</div>
<div>
<p id="readings"></p><br>
<p id="words"></p><br>
</div>
<div style="margin-top: 20px;">
<button id="prv-btn">Previous</button>
</div>
<div style="margin-top: 20px; text-align: right;">
<button id="nxt-btn">Next</button>
</div>
</div>
</section>
<style>
.wrapper {
display: grid;
grid-template-columns: 1fr 2fr;
grid-column-gap: 1rem;
font-family: "Shippori Mincho";
border: 2px solid whitesmoke;
padding: 2rem;
}
#kanji-name{
font-size: calc(1rem + 10vw);
}
#rtk-kw{
font-size: calc(1rem + 4vw);
}
#rtk-num{
font-size: calc(1rem + 2vw);
}
#grade{
font-size: calc(1rem + 2vw);
}
#readings{
font-size: calc(1rem + 1vw);
text-align: justify;
}
#words{
font-size: calc(1rem + 1vw);
line-height: 3rem;
text-align: justify;
}
</style>
<script src="//instant.page/5.2.0" type="module"
integrity="sha384-jnZyxPjiipYXnSU0ygqeac2q7CVYMbh84q0uHVRRxEtvFPiQYbXWUorga2aqZJ0z"></script>