Refactoring.

This commit is contained in:
doncr 2016-12-27 21:08:59 +00:00
parent 9f8093c0e0
commit d0c1b0eeb7

View File

@ -1,11 +1,13 @@
// drill.js
var conjugations = {
var words = {
"行く" : {
"group" : "iku",
"conjugations" : {
"plain" : "行[い]く",
"negative" : "行[い]かない",
"polite" : "行[い]きます",
@ -31,11 +33,14 @@ var conjugations = {
"polite progressive" : "行[い]っています",
"polite progressive negative" : "行[い]っていません",
},
},
"飲む" : {
"group" : "godan",
"conjugations" : {
"plain" : "飲[の]む",
"negative" : "飲[の]まない",
"polite" : "飲[の]みます",
@ -61,11 +66,14 @@ var conjugations = {
"polite progressive" : "飲[の]んでいます",
"polite progressive negative" : "飲[の]んでいません",
},
},
"作る" : {
"group" : "godan",
"conjugations" : {
"plain" : "作[つく]る",
"negative" : "作[つく]らない",
"polite" : "作[つく]ります",
@ -91,11 +99,14 @@ var conjugations = {
"polite progressive" : "作[つく]っています",
"polite progressive negative" : "作[つく]っていません",
},
},
"買い戻す" : {
"group" : "godan",
"conjugations" : {
"plain" : "買[か]い戻[もど]す",
"negative" : "買[か]い戻[もど]さない",
"polite" : "買[か]い戻[もど]します",
@ -121,11 +132,14 @@ var conjugations = {
"polite progressive" : "買[か]い戻[もど]しています",
"polite progressive negative" : "買[か]い戻[もど]していません",
},
},
"見る" : {
"group" : "ichidan",
"conjugations" : {
"plain" : "見[み]る",
"negative" : "見[み]ない",
"polite" : "見[み]ます",
@ -151,11 +165,14 @@ var conjugations = {
"polite progressive" : "見[み]ています",
"polite progressive negative" : "見[み]ていません",
},
},
"食べる" : {
"group" : "ichidan",
"conjugations" : {
"plain" : "食[た]べる",
"negative" : "食[た]べない",
"polite" : "食[た]べます",
@ -181,11 +198,14 @@ var conjugations = {
"polite progressive" : "食[た]べています",
"polite progressive negative" : "食[た]べていません",
},
},
"起きる" : {
"group" : "ichidan",
"conjugations" : {
"plain" : "起[お]きる",
"negative" : "起[お]きない",
"polite" : "起[お]きます",
@ -211,11 +231,14 @@ var conjugations = {
"polite progressive" : "起[お]きています",
"polite progressive negative" : "起[お]きていません",
},
},
"買い換える" : {
"group" : "ichidan",
"conjugations" : {
"plain" : "買[か]い換[か]える",
"negative" : "買[か]い換[か]えない",
"polite" : "買[か]い換[か]えます",
@ -241,11 +264,14 @@ var conjugations = {
"polite progressive" : "買[か]い換[か]えています",
"polite progressive negative" : "買[か]い換[か]えていません",
},
},
"来る" : {
"group" : "kuru",
"conjugations" : {
"plain" : "来[く]る",
"negative" : "来[こ]ない",
"polite" : "来[き]ます",
@ -271,11 +297,14 @@ var conjugations = {
"polite progressive" : "来[き]ています",
"polite progressive negative" : "来[き]ていません",
},
},
"する" : {
"group" : "suru",
"conjugations" : {
"plain" : "する",
"negative" : "しない",
"polite" : "します",
@ -291,11 +320,14 @@ var conjugations = {
"polite progressive" : "しています",
"polite progressive negative" : "していません",
},
},
"勉強する" : {
"group" : "suru",
"conjugations" : {
"plain" : "勉[べん]強[きょう]する",
"negative" : "勉[べん]強[きょう]しない",
"polite" : "勉[べん]強[きょう]します",
@ -311,11 +343,14 @@ var conjugations = {
"polite progressive" : "勉[べん]強[きょう]しています",
"polite progressive negative" : "勉[べん]強[きょう]していません",
},
},
"電話する" : {
"group" : "suru",
"conjugations" : {
"plain" : "電[でん]話[わ]する",
"negative" : "電[でん]話[わ]しない",
"polite" : "電[でん]話[わ]します",
@ -331,11 +366,14 @@ var conjugations = {
"polite progressive" : "電[でん]話[わ]しています",
"polite progressive negative" : "電[でん]話[わ]していません",
},
},
"読む" : {
"group" : "godan",
"conjugations" : {
"plain" : "読[よ]む",
"negative" : "読[よ]まない",
"polite" : "読[よ]みます",
@ -361,11 +399,14 @@ var conjugations = {
"polite progressive" : "読[よ]んでいます",
"polite progressive negative" : "読[よ]んでいません",
},
},
"思う" : {
"group" : "godan",
"conjugations" : {
"plain" : "思[おも]う",
"negative" : "思[おも]わない",
"polite" : "思[おも]います",
@ -391,11 +432,14 @@ var conjugations = {
"polite progressive" : "思[おも]っています",
"polite progressive negative" : "思[おも]っていません",
},
},
"買い与える" : {
"group" : "ichidan",
"conjugations" : {
"plain" : "買[か]い与[あた]える",
"negative" : "買[か]い与[あた]えない",
"polite" : "買[か]い与[あた]えます",
@ -421,11 +465,14 @@ var conjugations = {
"polite progressive" : "買[か]い与[あた]えています",
"polite progressive negative" : "買[か]い与[あた]えていません",
},
},
"座る" : {
"group" : "godan",
"conjugations" : {
"plain" : "座[すわ]る",
"negative" : "座[すわ]らない",
"polite" : "座[すわ]ります",
@ -451,11 +498,14 @@ var conjugations = {
"polite progressive" : "座[すわ]っています",
"polite progressive negative" : "座[すわ]っていません",
},
},
"休む" : {
"group" : "godan",
"conjugations" : {
"plain" : "休[やす]む",
"negative" : "休[やす]まない",
"polite" : "休[やす]みます",
@ -481,11 +531,14 @@ var conjugations = {
"polite progressive" : "休[やす]んでいます",
"polite progressive negative" : "休[やす]んでいません",
},
},
"足す" : {
"group" : "godan",
"conjugations" : {
"plain" : "足[た]す",
"negative" : "足[た]さない",
"polite" : "足[た]します",
@ -511,11 +564,14 @@ var conjugations = {
"polite progressive" : "足[た]しています",
"polite progressive negative" : "足[た]していません",
},
},
"歌う" : {
"group" : "godan",
"conjugations" : {
"plain" : "歌[うた]う",
"negative" : "歌[うた]わない",
"polite" : "歌[うた]います",
@ -541,11 +597,14 @@ var conjugations = {
"polite progressive" : "歌[うた]っています",
"polite progressive negative" : "歌[うた]っていません",
},
},
"高い" : {
"group" : "i-adjective",
"conjugations" : {
"plain" : "高[たか]い",
"negative" : "高[たか]くない",
"polite" : "高[たか]いです",
@ -555,11 +614,14 @@ var conjugations = {
"polite past" : "高[たか]かったです",
"polite past negative" : "高[たか]くなかったです",
},
},
"面白い" : {
"group" : "i-adjective",
"conjugations" : {
"plain" : "面白[おもしろ]い",
"negative" : "面白[おもしろ]くない",
"polite" : "面白[おもしろ]いです",
@ -569,11 +631,14 @@ var conjugations = {
"polite past" : "面白[おもしろ]かったです",
"polite past negative" : "面白[おもしろ]くなかったです",
},
},
"暗い" : {
"group" : "i-adjective",
"conjugations" : {
"plain" : "暗[くら]い",
"negative" : "暗[くら]くない",
"polite" : "暗[くら]いです",
@ -583,11 +648,14 @@ var conjugations = {
"polite past" : "暗[くら]かったです",
"polite past negative" : "暗[くら]くなかったです",
},
},
"いい" : {
"group" : "i-adjective",
"conjugations" : {
"plain" : "いい",
"negative" : "良[よ]くない",
"polite" : "いいです",
@ -597,11 +665,14 @@ var conjugations = {
"polite past" : "良[よ]かったです",
"polite past negative" : "良[よ]くなかったです",
},
},
"有名な" : {
"group" : "na-adjective",
"conjugations" : {
"plain" : "有名[ゆうめい]だ",
"negative" : "有名[ゆうめい]ではない",
"polite" : "有名[ゆうめい]です",
@ -611,11 +682,14 @@ var conjugations = {
"polite past" : "有名[ゆうめい]でした",
"polite past negative" : "有名[ゆうめい]ではありませんでした",
},
},
"好きな" : {
"group" : "na-adjective",
"conjugations" : {
"plain" : "好[き]だ",
"negative" : "好[き]ではない",
"polite" : "好[き]です",
@ -625,11 +699,14 @@ var conjugations = {
"polite past" : "好[き]でした",
"polite past negative" : "好[き]ではありませんでした",
},
},
"元気な" : {
"group" : "na-adjective",
"conjugations" : {
"plain" : "元[げん]気[き]だ",
"negative" : "元[げん]気[き]ではない",
"polite" : "元[げん]気[き]です",
@ -639,11 +716,14 @@ var conjugations = {
"polite past" : "元[げん]気[き]でした",
"polite past negative" : "元[げん]気[き]ではありませんでした",
},
},
"意地悪な" : {
"group" : "na-adjective",
"conjugations" : {
"plain" : "意[い]地[じ]悪[わる]だ",
"negative" : "意[い]地[じ]悪[わる]ではない",
"polite" : "意[い]地[じ]悪[わる]です",
@ -653,7 +733,7 @@ var conjugations = {
"polite past" : "意[い]地[じ]悪[わる]でした",
"polite past negative" : "意[い]地[じ]悪[わる]ではありませんでした",
},
},
};
var transformations = {
@ -901,10 +981,10 @@ function getVerbForms(entry) {
"furigana": { }
};
Object.keys(conjugations[entry]).forEach(function (key) {
result["kanji"][key] = kanjiForm(conjugations[entry][key]);
result["hiragana"][key] = kanaForm(conjugations[entry][key]);
result["furigana"][key] = conjugations[entry][key];
Object.keys(words[entry].conjugations).forEach(function (key) {
result["kanji"][key] = kanjiForm(words[entry].conjugations[key]);
result["hiragana"][key] = kanaForm(words[entry].conjugations[key]);
result["furigana"][key] = words[entry].conjugations[key];
});
return result;
@ -1029,7 +1109,7 @@ function generateQuestion() {
return;
}
entry = Object.keys(conjugations).randomElement();
entry = Object.keys(words).randomElement();
to_form = Object.keys(transformations).randomElement();
from_form = Object.keys(transformations[to_form]).randomElement();
@ -1046,7 +1126,7 @@ function generateQuestion() {
}
});
if ($('#' + conjugations[entry].group).is(':checked') == false) {
if ($('#' + words[entry].group).is(':checked') == false) {
valid = false;
}