Commit 4131b57e authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

mise à jour et déploiement arabe

parent 5f8009e7
......@@ -48,6 +48,7 @@ urlpatterns = [
path('fr/', clavier_views.newPage),
path('en/', clavier_views.newPage),
path('zh/', clavier_views.newPage),
path('dz/', clavier_views.newPage),
path('id-<str:pageId>/', clavier_views.loadPage),
path('id-<str:pageId>/page', clavier_views.getPageContent),
path('<str:pageLang>/id-<str:pageId>/', clavier_views.loadPage),
......
......@@ -25,7 +25,7 @@ var pageId = '0'
if (dataPage == 0) {
// Chargement d'une page vierge
console.log("Chargement d'une page vierge.")
var thisRawURL = thisURL.replace('/fr','').replace('/en','').replace('/zh','');
var thisRawURL = thisURL.replace('/fr','').replace('/en','').replace('/zh','').replace('/dz','');
setLangFromUrl()
} else {
console.log("Chargement de la page",dataPage.pageId)
......@@ -120,6 +120,8 @@ function switchMode(){
document.documentElement.style.setProperty('--clavSize', '60%');
document.documentElement.style.setProperty('--graphSize', '40%');
hideGraphies();
} else {
// Mode PHONOGRAPHIE
console.log('Passage en mode PHONOGRAPHIE')
......@@ -129,9 +131,19 @@ function switchMode(){
document.documentElement.style.setProperty('--clavSize', '50%');
document.documentElement.style.setProperty('--graphSize', '50%');
hideGraphies();
}
}
let hamzah = [
"ِ",
"َ",
"ُ",
"ّ",
"ٔ"
]
function recupPhon(identifiant){
if (!modeGraphies) {
//////////////////////////////
......@@ -183,33 +195,72 @@ function recupPhon(identifiant){
//// IF modeGraphies
//// → lister les graphies
currentPhon = identifiant
var graphZone = document.getElementById("graphiesZone")
var gz = ''
console.log(id2class[identifiant])
var fid = fidel[id2class[identifiant]]
//console.log(fid)
if (bgWhite) gz += "<table class='graphiesZoneTable graphiesZoneTable-white"; else gz += "<table class='graphiesZoneTable"
gz += "' id='graphiesZoneTable'>"
for (let i in fid){
gz += "<tr>"
for (let j in fid[i]){
//console.log(fid[i][j])
gz += "<td>"
if (fid[i][j][2] == 1) {
var graphie = fid[i][j][0]
if (maj) graphie = graphie[0].toUpperCase()+graphie.slice(1)
if (fid[i][j].length == 4) phonId = fid[i][j][3]; else phonId = id2class[identifiant]; // Traitement des mélanges de phonèmes dans une même zone de graphies
gz += '<div onClick="writeGraph(\''+graphie+'\',\''+phonId+'\');" class="graph graph'+fid[i][j][1]+' '+phonId+'"> '+graphie+' </div>'
if (thisPageLang != "dz") {
currentPhon = identifiant
var graphZone = document.getElementById("graphiesZone")
var gz = ''
console.log(id2class[identifiant])
var fid = fidel[id2class[identifiant]]
//console.log(fid)
if (bgWhite) gz += "<table class='graphiesZoneTable graphiesZoneTable-white"; else gz += "<table class='graphiesZoneTable"
gz += "' id='graphiesZoneTable'>"
for (let i in fid){
gz += "<tr>"
for (let j in fid[i]){
//console.log(fid[i][j])
gz += "<td>"
if (fid[i][j][2] == 1) {
var graphie = fid[i][j][0]
if (maj) graphie = graphie[0].toUpperCase()+graphie.slice(1)
if (fid[i][j].length == 4) phonId = fid[i][j][3]; else phonId = id2class[identifiant]; // Traitement des mélanges de phonèmes dans une même zone de graphies
gz += '<div onClick="writeGraph(\''+graphie+'\',\''+phonId+'\');" class="graph graph'+fid[i][j][1]+' '+phonId+'"> '+graphie+' </div>'
}
gz += "</td>"
}
gz += "</td>"
gz += "</tr>"
}
gz += "</tr>"
}
gz += "</table>"
gz += "</table>"
graphZone.innerHTML = gz
} else {
// ARABE ALGÉRIEN - traitement plus simple
var graphZone = document.getElementById("graphiesZone")
graphlist = api2ar[phon2api[identifiant.replace('rect_', 'phon_')]]
// console.log(identifiant, graphlist)
graphZone.innerHTML = "";
var hanDiv = document.createElement("div");
hanDiv.id = "hanDiv";
hanDiv.style.width = "100%";
hanDiv.style.height = "100%";
hanDiv.classList = "d-flex justify-content-evenly align-content-around flex-wrap";
document.getElementById('graphiesZone').innerHTML = "";
document.getElementById('graphiesZone').appendChild(hanDiv);
document.getElementById('graphiesZone').appendChild(hanDiv);
for (g in graphlist) {
newg = document.createElement('div')
newg.innerHTML = graphlist[g]
newg.classList.add('graph')
newg.classList.add('graph6')
newg.classList.add(identifiant.replace('rect_', 'phon_'))
newg.classList.add('noUnderLine')
if (hamzah.includes(graphlist[g])) {
newg.classList.add('noTextClipGraphZone')
newg.innerHTML = ""+newg.innerHTML;
newg.setAttribute('onClick', "writeGraph('"+graphlist[g]+"','"+identifiant.replace('rect_', 'phon_')+" noTextClip noUnderLine')")
} else {
newg.setAttribute('onClick', "writeGraph('"+graphlist[g]+"','"+identifiant.replace('rect_', 'phon_')+" noUnderLine')")
}
graphZone.innerHTML = gz
hanDiv.appendChild(newg)
}
}
showGraphies()
}
}
......@@ -249,6 +300,35 @@ function writeGraph(graph,phon){
var textClip = "";
if (graph == "͜") textClip = " noTextClip";
// SI ARABE
if (thisPageLang == "dz") {
stress = " arabe"
graph = graph.replace(/ـ/g, '')
console.log(graph, phon)
// Éviter la ligature du "laa" (pour conserver la couleur du a court)
// if (document.getElementById(curseurPos).classList.contains("phon_a") && document.getElementById(curseurPos).previousSibling.classList.contains("phon_l") && phon=="phon_a_long noUnderLine") {
// console.log("La+A")
// graph = "&zwj;"+graph;
// }
// if (document.getElementById(curseurPos).classList.contains("phon_l") && phon=="phon_a_long noUnderLine") {
// console.log("L+AA")
// graph = "&zwj;"+graph;
// }
// Forcer la ligature "le"
// MARCHE PAS
if (graph=="" && document.getElementById(curseurPos).classList.contains("phon_l")) {
graph = "&zwj;"+graph;
}
// Désactiver la modification auto de caractère pour voyelles courtes après shaddah ou autre NoTextClip
if (document.getElementById(curseurPos).classList.contains("noTextClip")) {
console.log('NoTextClip Detected')
graph = "&zwj;"+graph;
}
// if (hamzah.includes(graph)) graph = "&zwj;"+graph;
}
var graphSpan = document.createElement("span")
graphSpan.setAttribute("id", phon+"-g"+Math.random().toString(36).substring(2,9))
graphSpan.setAttribute("class", 'text '+phon+stress+textClip)
......@@ -448,6 +528,7 @@ var phonA = getComputedStyle(document.documentElement).getPropertyValue('--phon_
function bg2white() {
if (!bgWhite) {
// SI ON PASSE DU NOIR AU BLANC
document.getElementById('textZoneBack').classList.add('textZone-white')
document.getElementById('textZoneBack').classList.add('graphContours')
......@@ -456,7 +537,9 @@ function bg2white() {
if (tabbl) tabbl.classList.add('graphiesZoneTable-white')
document.getElementById('graphiesZone').classList.add('graphContours')
document.documentElement.style.setProperty('--phon_a', '#000000')
if (thisPageLang!='zh'){
document.documentElement.style.setProperty('--phon_a', '#000000')
}
//setKeyboards('white')
bgWhite = true
} else {
......@@ -519,7 +602,7 @@ function getPopUp() {
finalOutput += "<br>";
} else if (m[2] != "&nbsp;") {
var classs = m[1].split(' ');
var expFonte = "font-family: Palatino, Times, Calibri;";
var expFonte = "font-family: Ubuntu, KaiTi, Palatino, Times, Calibri;";
var expCoulBase = "color:#cccccc;";
var expSizeBase = "font-size:30pt;";
......@@ -534,7 +617,7 @@ function getPopUp() {
newOutputSpan = "<span style='" + expFonte + expBold + expSizeBase; // PAR DEFAUT
if (classs.includes("punct")) newOutputSpan = "<span style='" + expFonte + expSizeBase;
if (classs.includes("unstressed")) newOutputSpan = "<span style='" + expFonte + expNoBold + expSizeBase;
if (classs.includes("unstressed") || classs.includes("arabe")) newOutputSpan = "<span style='" + expFonte + expNoBold + expSizeBase;
if (classs.includes("schwa")) newOutputSpan = "<span style='" + expFonte + expNoBold + expSizeSchwa;
if (classs.includes("stress1")) newOutputSpan = "<span style='" + expFonte + expSizeStress1;
if (classs.includes("stress2")) newOutputSpan = "<span style='" + expFonte + expSizeStress2;
......@@ -545,7 +628,7 @@ function getPopUp() {
for (i=0; i<classs.length; i++) {
if (classs[i].match(/phon_.*/)) phonClass = classs[i];
}
if (phonClass.match(/.*_long/)) newOutputSpan += expLong;
if (phonClass.match(/.*_long/) && !classs.includes("arabe")) newOutputSpan += expLong;
if (phonClass != "") newOutputSpan += phon2color(phonClass);
newOutputSpan += "'>"+m[2]+"</span>";
......@@ -563,6 +646,7 @@ function getPopUp() {
var col2 = getComputedStyle(document.documentElement).getPropertyValue(bicol2colcol[p1][1])
var res = 'background-color:'+col1+';color:'+col2+';-webkit-text-stroke-width: 0.5px;-webkit-text-stroke-color: #000000;'
} else {
if (p1.slice(p1.length-5)=="_long") p1 = p1.slice(0,p1.length-5);
var col = getComputedStyle(document.documentElement).getPropertyValue('--'+p1)
var res = 'color:'+col+';-webkit-text-stroke-width: 0.5px;-webkit-text-stroke-color: #000000;'
}
......@@ -849,6 +933,7 @@ function zhPhon(rectId) {
newHan.setAttribute("onclick","writeGraphZh('"+charlist[char]+"','')");
hanDiv.appendChild(newHan);
}
showGraphies()
}
}
function recupTone(tonId){
......@@ -941,6 +1026,7 @@ function writeGraphZh(char, phon){
document.getElementById(curseurPos).classList.add('startPoint')
playEffect("select")
if (document.body.clientWidth < 850) hideGraphies();
// saveTrace('add phon '+rectId)
}
......@@ -1119,29 +1205,33 @@ function checkWord() {
}
console.log(ww);
let cptw = 0;
for (w of ww) {
cptw++;
var word = "";
var phono = "";
var listSpans = []; // tous les spans concernés, qu'il faudra souligner le cas échéant
for (p of w) {
word += p[0];
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]];
if (thisPageLang != "dz") {
let cptw = 0;
for (w of ww) {
cptw++;
var word = "";
var phono = "";
var listSpans = []; // tous les spans concernés, qu'il faudra souligner le cas échéant
for (p of w) {
word += p[0];
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]);
}
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.trim(),thisPageLang,listSpans,fin);
}
var fin = false;
if (cptw == ww.length) fin = true;
document.getElementById('checkWordValid').style.display = "none";
document.getElementById('checkWordLoading').style.display = "block";
reqWiki(word,phono.trim(),thisPageLang,listSpans,fin);
} else {
window.alert("Cette fonctionnalité n'est pas encore disponible pour cette langue");
}
}
......
......@@ -6,13 +6,14 @@ var thisPageLang = "";
// set page target language
function setLangFromUrl() {
var pageLang = thisURL.match(/.*\/(fr|en|zh)/);
var pageLang = thisURL.match(/.*\/(fr|en|zh|dz)/);
if (pageLang) {
console.log("Langue indiquée par l'url:",pageLang[1]);
thisPageLang = pageLang[1];
if (pageLang[1]=="fr") selectLang("fr");
if (pageLang[1]=="en") selectLang("en");
if (pageLang[1]=="zh") selectLang("zh");
if (pageLang[1]=="dz") selectLang("dz");
} else {
console.log("Chargement langue par défaut (fr)");
thisPageLang = "fr"
......@@ -95,6 +96,25 @@ function selectLang(lang, p="default", f="default"){
if (pageId == '0') window.history.pushState("", "", "/zh");
interface("zh");
} else if (lang == "dz") {
var phonoDzSb2 = document.createElement('option');
phonoDzSb2.value = "phonoDzSb2";
phonoDzSb2.innerHTML = "Arabe algérien S. Benbouaziz v2";
phonolist.appendChild(phonoDzSb2);
var phonoDzSb3 = document.createElement('option');
phonoDzSb3.value = "phonoDzSb3";
phonoDzSb3.selected = "True";
phonoDzSb3.innerHTML = "Arabe algérien S. Benbouaziz v3";
phonolist.appendChild(phonoDzSb3);
var newFid = document.createElement('option');
newFid.value = "fidelSb";
newFid.innerHTML = "Fidel S. Benbouaziz";
fidellist.appendChild(newFid);
if (pageId == '0') window.history.pushState("", "", "/dz");
interface("dz");
}
selectPanneau(p);
selectFidel(f);
......@@ -109,6 +129,8 @@ function selectPanneau(p){
p = "phonoEnAlem";
} else if (p=="default" && thisPageLang=="zh") {
p = "phonoZhJi"
} else if (p=="default" && thisPageLang=="dz") {
p = "phonoDzSb3"
}
var svgFrKinephones = document.getElementById('svgFrKinephones'); // Panneau FR Kinephones
......@@ -130,6 +152,9 @@ function selectPanneau(p){
var svgZhMa = document.getElementById('svgZhMa'); // Panneau Mandarin Aurélie Mariscalchi
var svgZhJi = document.getElementById('svgZhJi'); // Panneau Mandarin Shuman Jiao
var svgZhP7 = document.getElementById('svgZhP7'); // Panneau Mandarin P7 2021
var svgDzSb2 = document.getElementById('svgDzSb2'); // Panneau Arabe Algérien Sarra Benbouaziz v2
var svgDzSb3 = document.getElementById('svgDzSb3'); // Panneau Arabe Algérien Sarra Benbouaziz v3
function resetPanneaux() {
// FR DO
......@@ -161,6 +186,11 @@ function selectPanneau(p){
svgZhJi.style.display = 'none';
// ZH P7
svgZhP7.style.display = 'none';
// DZ SB v2
svgDzSb2.style.display = 'none';
// DZ SB v3
svgDzSb3.style.display = 'none';
}
......@@ -224,6 +254,16 @@ function selectPanneau(p){
// ZH P7
svgZhP7.style.display = 'block';
} else if (p == 'phonoDzSb2') {
resetPanneaux();
// DZ SB v2
svgDzSb2.style.display = 'block';
} else if (p == 'phonoDzSb3') {
resetPanneaux();
// DZ SB v2
svgDzSb3.style.display = 'block';
}
}
......@@ -235,6 +275,8 @@ function selectFidel(f){
f = "fidelEnPSUK";
} else if (f=="default" && thisPageLang=="zh") {
f = "cedict";
} else if (f=="default" && thisPageLang=="dz") {
f = "fidelSb";
}
fidel = dicoFidels[f];
document.getElementById('selectFidel').value = f;
......@@ -256,27 +298,70 @@ function interface(lang) {
title.title = langJson[title.id][lang];
}
function initInterface() {
document.getElementById('barreTitre').classList.remove('ms-auto');
document.getElementById('barreTitre').classList.add('me-auto');
document.getElementById('ti_maj').style.display = "block";
document.getElementById('svgEnPronSciBr').style.display = "none";
document.getElementById('btnSwitchStress').style.display = "none";
document.getElementsByClassName('btnPros')[0].style.display = "none";
document.getElementById('textZone').style.direction = "ltr";
document.getElementById('textZoneBack').classList.remove('justify-content-end')
document.getElementById('textZoneBack').classList.add('justify-content-between')
// Position curseur par défaut : sur la droite
document.documentElement.style.setProperty('--startPointLtr', 'solid');
document.documentElement.style.setProperty('--startPointRtl', 'hidden');
document.getElementById("msg_dz").style.display = "none";
}
if (lang == "en") {
initInterface();
document.getElementById('btnSwitchStress').style.display = "";
document.getElementsByClassName('btnPros')[0].style.display = "";
// Indiquer le lien de Page Vierge
document.getElementById('hrefNewPage').href = thisRawURL+'en/';
} else if (lang == "zh") {
document.getElementById('svgEnPronSciBr').style.display = "none";
document.getElementById('btnSwitchStress').style.display = "none";
document.getElementsByClassName('btnPros')[0].style.display = "none";
initInterface();
document.getElementById('ti_maj').style.display = "none";
// Indiquer le lien de Page Vierge
document.getElementById('hrefNewPage').href = thisRawURL+'zh/';
} else if (lang == "dz") {
initInterface();
document.getElementById('barreTitre').classList.remove('me-auto');
document.getElementById('barreTitre').classList.add('ms-auto');
document.getElementById('ti_maj').style.display = "none";
// Indiquer le lien de Page Vierge
document.getElementById('hrefNewPage').href = thisRawURL+'dz/';
document.getElementById('textZone').style.direction = "rtl";
document.getElementById('textZoneBack').classList.remove('justify-content-between')
document.getElementById('textZoneBack').classList.add('justify-content-end')
document.documentElement.style.setProperty('--startPointLtr', 'hidden');
document.documentElement.style.setProperty('--startPointRtl', 'solid');
document.getElementById("msg_dz").style.display = "block";
} else { // "fr" par défaut
document.getElementById('svgEnPronSciBr').style.display = "none";
document.getElementById('btnSwitchStress').style.display = "none";
document.getElementsByClassName('btnPros')[0].style.display = "none";
initInterface();
// Indiquer le lien de Page Vierge
document.getElementById('hrefNewPage').href = thisRawURL+'fr/';
}
}
\ No newline at end of file
var phon2api = {
"phon_1":"ɨ",
"phon_2":"ø",
"phon_3":"ɜ",
"phon_3_slash":"ɞ",
"phon_3_long":"ɜː",
"phon_3_rho":"ɝ",
"phon_3_slash":"ɞ",
"phon_3":"ɜ",
"phon_4":"ɾ",
"phon_5":"ɫ",
"phon_5":"",
"phon_5X":"ɫ",
"phon_6":"ɐ",
"phon_7_rho":"ɤ˞",
"phon_7":"ɤ",
"phon_8":"ɵ",
"phon_9":"œ",
"phon_9_maj":"ɶ",
"phon_9_nas":"œ̃",
"phon_a":"a",
"phon_9":"œ",
"phon_a_centr":"ä",
"phon_a_maj":"ɑ",
"phon_a_maj_long":"ɑː",
"phon_a_maj_nas":"ɑ̃",
"phon_arobase":"ə",
"phon_arobase_rho":"ɚ",
"phon_a_maj":"ɑ",
"phon_a_majr":"ɑɹ",
"phon_a_rho":"",
"phon_7_rho":"ɤ˞",
"phon_a":"a",
"phon_ai_maj":"",
"phon_ai_majarobase":"aɪə",
"phon_arobase_rho":"ɚ",
"phon_arobase_slash":"ɘ",
"phon_b":"b",
"phon_arobase":"ə",
"phon_arobasel":"əl",
"phon_arobasem":"əm",
"phon_arobasen":"ən",
"phon_arobaseu_maj":"əʊ",
"phon_au_maj":"",
"phon_au_majwarobase":"aʊwə",
"phon_b_chev":"ɓ",
"phon_b_maj":"β",
"phon_b_maj_slash":"ʙ",
"phon_c":"c",
"phon_b_maj":"β",
"phon_b":"b",
"phon_bb_maj":"",
"phon_bv":"bv",
"phon_c_maj":"ç",
"phon_c":"c",
"phon_cbrack":"æ",
"phon_cbrack2":"ʉ",
"phon_cc_maj":"",
"phon_chevron_slash":"ʢ",
"phon_chevron2_slash":"ʡ",
"phon_d":"d",
"phon_d_chev":"ɗ",
"phon_d_maj":"ð",
"phon_d_retr":"ɖ",
"phon_e":"e",
"phon_e_maj":"ɛ",
"phon_d_slashz_retr":"ɖʐ",
"phon_d":"d",
"phon_dd_maj":"",
"phon_dz_maj":"",
"phon_dz_retr":"",
"phon_dz_slash":"",
"phon_dz":"dz",
"phon_e_maj_nas":"ɛ̃",
"phon_e_maj":"ɛ",
"phon_e_maj_long":"ɛː",
"phon_e":"e",
"phon_e_long":"",
"phon_earobase":"",
"phon_ef":"ef",
"phon_egal_slash":"ǂ",
"phon_ei_maj":"",
"phon_er":"",
"phon_exclam_slash":"ǃ",
"phon_f":"f",
"phon_f_maj":"ɱ",
"phon_g":"ɡ",
"phon_f":"f",
"phon_g_chev":"ɠ",
"phon_g_maj":"ɣ",
"phon_g_maj_slash":"ɢ",
"phon_g_maj_slash_chev":"ʛ",
"phon_glottstop":"ʔ",
"phon_g_maj_slash":"ɢ",
"phon_g_maj_slashr_maj":"ɢʁ",
"phon_g_maj":"ɣ",
"phon_g_majw":"ɣw",
"phon_g_majwX":"ɣʷ",
"phon_g":"ɡ",
"phon_gb":"ɡb",
"phon_gg_maj":"ɡɣ",
"phon_glottstop_slash":"ʕ",
"phon_h":"h",
"phon_h_maj":"ɥ",
"phon_glottstop":"ʔ",
"phon_glottstoph":"ʔh",
"phon_gw":"ɡw",
"phon_gwX":"ɡʷ",
"phon_gz_maj":"ɡʒ",
"phon_gz":"ɡz",
"phon_h_maj_i":"ɥi",
"phon_h_maj_slash":"ʜ",
"phon_h_maj":"ɥ",
"phon_h_slash":"ɦ",