Commit 574a3a82 authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

amélioration cartes zh

parent 547104d1
......@@ -253,13 +253,9 @@ function writeGraph(graph,phon){
graphSpan.setAttribute("id", phon+"-g"+Math.random().toString(36).substring(2,9))
graphSpan.setAttribute("class", 'text '+phon+stress+textClip)
graphSpan.setAttribute('onclick', "putAnchor(this.id)")
if (thisPageLang != "zh") {
graph = graph.replace("","")
graphSpan.innerHTML = graph
} else {
graphSpan.appendChild(writeHan(graph));
graphSpan.style.display = "inline";
}
graph = graph.replace("","")
graphSpan.innerHTML = graph
insertAfter(document.getElementById(curseurPos), graphSpan)
document.getElementById(curseurPos).classList.remove('startPoint')
curseurPos = graphSpan.id
......@@ -774,7 +770,9 @@ let syll0 = {
"glide": { "rect":"", "phon":""},
"tonale": { "rect":"", "phon":""},
"finale": { "rect":"", "phon":""},
"tone": 0
"tone": 0,
"api": "",
"pinyin": ""
}
let syll = syll0;
let syllFinie = {};
......@@ -792,7 +790,9 @@ function zhPhon(rectId) {
"glide": { "rect":"", "phon":""},
"tonale": { "rect":"", "phon":""},
"finale": { "rect":"", "phon":""},
"tone": 0
"tone": 0,
"api": "",
"pinyin": ""
};
currentSyll = [];
}
......@@ -815,12 +815,16 @@ function zhPhon(rectId) {
console.log("RÉINITIALISATION SYLL");
syllFinie = syll;
syllFinie.api = currentAPI;
syllFinie.pinyin = getPinyin(currentAPI);
syll = {
"initiale": { "rect":"", "phon":""},
"glide": { "rect":"", "phon":""},
"tonale": { "rect":"", "phon":""},
"finale": { "rect":"", "phon":""},
"tone": 0
"tone": 0,
"api": "",
"pinyin": ""
};
currentSyll = [];
} else console.log("MANQUE",phon,"DANS PHON2API !")
......@@ -842,7 +846,7 @@ function zhPhon(rectId) {
for(let char=0; char<charlist.length; char++) {
console.log(charlist[char],freqlist[char]);
var newHan = writeHan(charlist[char],getSize(freqlist[char]));
newHan.setAttribute("onclick","writeGraph('"+charlist[char]+"','')");
newHan.setAttribute("onclick","writeGraphZh('"+charlist[char]+"','')");
hanDiv.appendChild(newHan);
}
}
......@@ -882,6 +886,20 @@ function getChars(api) {
return [charlist, freqlist]
}
function getPinyin(api) {
var pinyin = "";
var x = ""; // api sans ton
var y = ""; // ton seul
if (["0","1","2","3","4","5"].includes(api[api.length-1])) {
x = api.slice(0,api.length-1);
y = api[api.length-1];
}
if (x in syllonAPI2pinyin && syllonAPI2pinyin[x]+y in syll2chars) {
pinyin = syllonAPI2pinyin[x]+y;
}
return pinyin
}
function writeHan(char,size=1){
var newHan = document.createElement("div");
newHan.classList = "align-self-center han han"+size;
......@@ -894,6 +912,38 @@ function writeHan(char,size=1){
return newHan
}
function writeGraphZh(char, phon){
var rectId = char
var newCarte = document.createElement('div')
newCarte.classList = "carteZh text";
newCarte.draggable = true
if (char != "space") newCarte.appendChild(writeHan(char));
newCarte.setAttribute("data-api",syllFinie.api);
newCarte.setAttribute("data-pinyin",syllFinie.pinyin);
newCarte.addEventListener('dragstart', () => {
newCarte.classList.add('dragging')
console.log('DRAGGING ', rectId)
})
newCarte.addEventListener('dragend', () => {
newCarte.classList.remove('dragging')
console.log('STOP DRAGGING ', rectId)
})
newCarte.setAttribute("id", "syllzh-g"+Math.random().toString(36).substring(2,9))
newCarte.setAttribute('onclick', "putAnchor(this.id)")
insertAfter(document.getElementById(curseurPos), newCarte)
document.getElementById(curseurPos).classList.remove('startPoint')
curseurPos = newCarte.id
document.getElementById(curseurPos).classList.add('startPoint')
playEffect("select")
// saveTrace('add phon '+rectId)
}
function makeNewSyll(syllFinie) {
let newSyll = document.createElement('div')
newSyll.classList = "syll"
......@@ -1044,24 +1094,29 @@ function checkWord() {
var w = []; // phonographie du mot courant
for (r of rep) {
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);
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])
}
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])
}
}
console.log(ww);
......
......@@ -56,7 +56,6 @@ function selectLang(lang, p="default", f="default"){
if (pageId == '0') window.history.pushState("", "", "/fr");
interface("fr");
document.getElementById('textZone').classList.remove("d-flex");
} else if (lang=="en"){
var phonoEnAlem = document.createElement('option');
......@@ -77,8 +76,6 @@ function selectLang(lang, p="default", f="default"){
if (pageId == '0') window.history.pushState("", "", "/en");
interface("en");
document.getElementById('textZone').classList.remove("d-flex");
} else if (lang == "zh") {
var phonoZhJiao = document.createElement('option');
phonoZhJiao.value = "phonoZhJi";
......@@ -98,7 +95,6 @@ function selectLang(lang, p="default", f="default"){
if (pageId == '0') window.history.pushState("", "", "/zh");
interface("zh");
document.getElementById('textZone').classList.add("d-flex");
}
selectPanneau(p);
selectFidel(f);
......
......@@ -166,6 +166,15 @@
cursor: grab;
}
.carteZh {
border: solid 1px black;
border-radius: 5px;
display: inline-block;
position: relative;
margin: 2px;
cursor: grab;
}
.carteIn {
position:absolute;
width:100%;
......
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