djtkana: recognize kana shortcuts

This commit is contained in:
postautistic 2017-05-04 19:31:19 -04:00
parent 69fd68b0c5
commit 8d0b3df329
4 changed files with 42 additions and 18 deletions

View File

@ -183,4 +183,9 @@ ul#tools li a {
#explanation {
line-height:1.6em;
}
.help {
cursor:help;
border-bottom:1px dotted #aaa;
}

View File

@ -120,10 +120,16 @@ var kana = {
var show_tools = ['あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ', 'そ', 'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま', 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', 'を', 'ん', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', '', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ヲ', 'ン'];
var replacements = {
'tu' : 'tsu',
'ti' : 'chi',
'ci' : 'chi',
'wo' : 'o'
'o': ['wo'],
'chi': ['ci'],
'shi': ['si'],
'tsu': ['tu'],
'zu': ['du'],
'ji': ['di', 'zi'],
'fu': ['hu'],
'ja': ['dya'],
'jo': ['dyo'],
'ju': ['dyu']
};
var active = [];
@ -281,20 +287,33 @@ function check_answer() {
answer = 'x';
}
for (orig in replacements) {
if(answer == orig) {
answer = replacements[orig];
chars = answer.split('');
possible = [cur_reading];
if(cur_reading in replacements) {
possible = possible.concat(replacements[cur_reading]);
}
for (i = 0; i < chars.length; i++) {
var err = true;
for (x = 0; x < possible.length; x++) {
if(chars[i] == possible[x].charAt(i)) {
err = false;
}
if(answer == possible[x]) {
answer = cur_reading;
}
}
if(err) {
break;
}
}
chars = answer.split('');
chars_correct = cur_reading.split('');
for (i = 0; i < chars.length; i++) {
if(chars[i] != chars_correct[i] && answer != 'w') {
document.getElementById('message').innerHTML = '<span id="wrong">' + cur_kana + ' = ' + cur_reading + '</span>';
wrong = true;
}
if(err) {
wrong = true;
document.getElementById('message').innerHTML = '<span id="wrong">' + cur_kana + ' = ' + cur_reading + '</span>';
}
if(answer == cur_reading) {

View File

@ -8,10 +8,10 @@ Word audio from JapanesePod101: http://assets.languagepod101.com/dictionary/japa
<head>
<meta charset="UTF-8">
<title>DJT Kana</title>
<link rel="stylesheet" href="djtkana.css?5" />
<link rel="stylesheet" href="djtkana.css" />
</head>
<body>
<script src="djtkana.js?5"></script>
<script src="djtkana.js"></script>
<h1>DJT Kana</h1>
@ -432,7 +432,7 @@ Word audio from JapanesePod101: http://assets.languagepod101.com/dictionary/japa
<h3>Explanation</h3>
<div id="explanation">
<p>Grind a row of kana until you stop making mistakes, then add another row. Press the <code>Play sound</code> link to make sure you are pronouncing the kana correctly. If you wish to write, the <code>Stroke order</code> link will show you the proper form.</p>
<p>Grind a row of kana until you stop making mistakes, then add another row. Press the <code>Play sound</code> link to make sure you are pronouncing the kana correctly. If you wish to write, the <code>Stroke order</code> link will show you the proper form. You can save a few keystrokes on DJT Kana and your <span class="help" title="Input Method Editor: program that converts romaji keyboard input to kana">IME</span> with <a href="shortcuts.png">these shortcuts</a>.</p>
<p>The two dots (<a href="https://en.wikipedia.org/wiki/Dakuten">dakuten</a>) next to certain kana indicate that the consonant is "muddied". For example, か (ka) becomes が (ga). The consonants transform as follows:
<ul>

BIN
kana/shortcuts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB