ver 20120112

This commit is contained in:
Tan, Kian-ting 2021-01-12 23:12:44 +08:00
parent ff00cdbbdc
commit 6f4c237be4
3 changed files with 23 additions and 11 deletions

15
conj.js
View file

@ -4,7 +4,7 @@ var startConj = document.getElementById('start-conjugate');
var original = document.getElementById('original'); var original = document.getElementById('original');
var conjStem = document.getElementById('conj-stem'); var conjStem = document.getElementById('conj-stem');
var conj_no = parseInt(conjNoList.value); var conj_no = parseInt(conjNoList.value);
var type_of_conj1 = null; var type_of_conj1 = "general";
var typesOfConj1Rads = document.getElementsByName("types-of-conj1"); var typesOfConj1Rads = document.getElementsByName("types-of-conj1");
// reset the dropdown list and the 1st conj opt div while refreshing the page. // reset the dropdown list and the 1st conj opt div while refreshing the page.
window.addEventListener('pageshow', function (event) { window.addEventListener('pageshow', function (event) {
@ -34,7 +34,12 @@ function emptyString(str) {
var isReallyEmpty = (str == ""); var isReallyEmpty = (str == "");
return isReallyEmpty || isContainedSpace; return isReallyEmpty || isContainedSpace;
} }
startConj.addEventListener('click', function (event) { original.addEventListener('keypress', generateConjMain);
conjStem.addEventListener('keypress', generateConjMain);
original.addEventListener('change', generateConjMain);
conjStem.addEventListener('change', generateConjMain);
startConj.addEventListener('click', generateConjMain);
function generateConjMain(event) {
var original_text = original.value; var original_text = original.value;
var conjstem_text = conjStem.value; var conjstem_text = conjStem.value;
if (emptyString(original_text) && emptyString(conjstem_text)) { if (emptyString(original_text) && emptyString(conjstem_text)) {
@ -47,7 +52,7 @@ startConj.addEventListener('click', function (event) {
; ;
generateConj(original_text, conjstem_text, conj_no); generateConj(original_text, conjstem_text, conj_no);
} }
}); }
function checkedIfBroadEnd(str_array) { function checkedIfBroadEnd(str_array) {
for (var i = str_array.length - 1; i >= 0; i--) { for (var i = str_array.length - 1; i >= 0; i--) {
if (str_array[i].match(/[aouáóúAOUÁÓÚ]/)) { if (str_array[i].match(/[aouáóúAOUÁÓÚ]/)) {
@ -193,9 +198,9 @@ function generateConj(orig_txt, stem_txt, conj_no) {
// general 1st vonj verbs // general 1st vonj verbs
firstConjFillTheArray(); firstConjFillTheArray();
// irreagularity of the pres. auto. form of lean // irreagularity of the pres. auto. form of lean
if (stem_txt == "lean") { if (stem_txt.match(/[lL][eE][aA][nN]/)) {
var relPres = document.getElementById("pres").getElementsByTagName("td")[7]; var relPres = document.getElementById("pres").getElementsByTagName("td")[7];
relPres.innerHTML = "leanas"; relPres.innerHTML = stem_txt + "as";
} }
} }
} }

17
conj.ts
View file

@ -5,7 +5,7 @@ var original = (<HTMLInputElement> document.getElementById('original'));
var conjStem = (<HTMLInputElement> document.getElementById('conj-stem')); var conjStem = (<HTMLInputElement> document.getElementById('conj-stem'));
var conj_no = parseInt(conjNoList.value); var conj_no = parseInt(conjNoList.value);
var type_of_conj1 = null; var type_of_conj1 = "general";
var typesOfConj1Rads = document.getElementsByName("types-of-conj1"); var typesOfConj1Rads = document.getElementsByName("types-of-conj1");
@ -39,7 +39,14 @@ function emptyString(str : string){
return isReallyEmpty || isContainedSpace; return isReallyEmpty || isContainedSpace;
} }
startConj.addEventListener('click', (event) => {
original.addEventListener('keypress', generateConjMain);
conjStem.addEventListener('keypress', generateConjMain);
original.addEventListener('change', generateConjMain);
conjStem.addEventListener('change', generateConjMain);
startConj.addEventListener('click', generateConjMain);
function generateConjMain(event : any){
var original_text = original.value; var original_text = original.value;
var conjstem_text = conjStem.value; var conjstem_text = conjStem.value;
if (emptyString(original_text) && emptyString(conjstem_text)){ if (emptyString(original_text) && emptyString(conjstem_text)){
@ -50,7 +57,7 @@ startConj.addEventListener('click', (event) => {
conjstem_text = original_text; conjstem_text = original_text;
}; };
generateConj(original_text, conjstem_text, conj_no); generateConj(original_text, conjstem_text, conj_no);
}}); }}
function checkedIfBroadEnd(str_array : string[]){ function checkedIfBroadEnd(str_array : string[]){
for (var i = str_array.length - 1; i >=0; i--){ for (var i = str_array.length - 1; i >=0; i--){
@ -236,9 +243,9 @@ function generateConj(orig_txt : string, stem_txt : string, conj_no : Number){
firstConjFillTheArray(); firstConjFillTheArray();
// irreagularity of the pres. auto. form of lean // irreagularity of the pres. auto. form of lean
if (stem_txt == "lean"){ if (stem_txt.match(/[lL][eE][aA][nN]/)){
var relPres = document.getElementById("pres").getElementsByTagName("td")[7]; var relPres = document.getElementById("pres").getElementsByTagName("td")[7];
relPres.innerHTML = "leanas"; relPres.innerHTML = stem_txt + "as";
} }
} }

View file

@ -7,7 +7,7 @@
<div> <div>
<h1>愛爾蘭語動詞變化產生器</h1> <h1>愛爾蘭語動詞變化產生器</h1>
<p><i>Gineadóir Réimniú na Gaeilge</i></p> <p><i>Gineadóir Réimniú na Gaeilge</i></p>
version 20210110<a href="https://github.com/Yoxem/irish-verb-conjugator">Github repo</a></div> version 20210112<a href="https://github.com/Yoxem/irish-verb-conjugator">Github repo</a></div>
<div><br> <div><br>
</div> </div>
<div>詞彙原形:<input id="original" type="text"></div> <div>詞彙原形:<input id="original" type="text"></div>