Commit 13f04b8a authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

debug checkWord zh

parent 574a3a82
......@@ -1094,30 +1094,28 @@ function checkWord() {
var w = []; // phonographie du mot courant
for (r of rep) {
if (thisPageLang == "zh") {
document.getElementById("textZone").children[1].children[0].children[1].innerText
} else {
if (r.classList.contains("punct") || r.classList.contains("pause") || r.classList.contains("space") || r.id == "gEnd" || r.innerText == "") {
if (w.length>0) {
ww.push(w);
}
w = [];
} else if (r.innerText != "" && r.id != "g0") {
var rinner = r.innerText
var stress = 0
if (r.innerText == "͜") rinner = "";
if (r.classList.contains('stress1')) stress = 1
if (r.classList.contains('stress2')) stress = 2
w.push([rinner, r.classList[1], r.id, stress])
} else if (r.classList[0]=="carte") {
var stress = 0
if (r.classList.contains('stress1')) stress = 1
if (r.classList.contains('stress2')) stress = 2
w.push(["",r.classList[2],r.id, stress])
if (r.classList.contains("punct") || r.classList.contains("pause") || r.classList.contains("space") || r.id == "gEnd" || r.innerText == "") {
if (w.length>0) {
ww.push(w);
}
w = [];
} else if (r.classList[0]=="carteZh") {
w.push([r.children[0].children[1].innerText, r.dataset.pinyin, r.id, 0])
} else if (r.innerText != "" && r.id != "g0") {
var rinner = r.innerText
var stress = 0
if (r.innerText == "͜") rinner = "";
if (r.classList.contains('stress1')) stress = 1
if (r.classList.contains('stress2')) stress = 2
w.push([rinner, r.classList[1], r.id, stress])
} else if (r.classList[0]=="carte") {
var stress = 0
if (r.classList.contains('stress1')) stress = 1
if (r.classList.contains('stress2')) stress = 2
w.push(["",r.classList[2],r.id, stress])
}
}
console.log(ww);
......@@ -1129,21 +1127,26 @@ function checkWord() {
var listSpans = []; // tous les spans concernés, qu'il faudra souligner le cas échéant
for (p of w) {
word += p[0];
if (p[3]==1) phono += "ˈ"
if (p[3]==2) phono += "ˌ"
if (thisPageLang=="en" && p[1]=="phon_e") phono += phon2api["phon_e_maj"]
else phono += phon2api[p[1]];
if (thisPageLang=="zh") phono += " "+p[1];
else {
if (p[3]==1) phono += "ˈ"
if (p[3]==2) phono += "ˌ"
if (thisPageLang=="en" && p[1]=="phon_e") phono += phon2api["phon_e_maj"]
else phono += phon2api[p[1]];
}
listSpans.push(p[2]);
}
var fin = false;
if (cptw == ww.length) fin = true;
document.getElementById('checkWordValid').style.display = "none";
document.getElementById('checkWordLoading').style.display = "block";
reqWiki(word,phono,thisPageLang,listSpans,fin);
reqWiki(word,phono.trim(),thisPageLang,listSpans,fin);
}
}
async function reqWiki(word,phono,lang,listSpans,fin) {
console.log("reqWiki",word,phono,lang,listSpans,fin);
const response = await fetch(`https://wikicolor.alem-app.fr/checkWord?w=${word}&t=${phono}&lang=${lang}`);
const data = await response.json();
......@@ -1152,8 +1155,9 @@ async function reqWiki(word,phono,lang,listSpans,fin) {
for (span of listSpans){
var el = document.getElementById(span);
if (el.classList[0]=="carte") {
if (el.classList[0]=="carte" || el.classList[0]=="carteZh") {
el.classList.remove("FBphonoCarte");
if (!data.rep.w) el.classList.add("FBortho");
if (!data.rep.t) el.classList.add("FBphonoCarte");
} else {
el.classList.remove("FBortho");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment