fix edit method to allow adding phonemes
This commit is contained in:
parent
1a131f74f1
commit
78aa2ce3f1
@ -559,6 +559,7 @@ document.querySelectorAll("#editLanguageSubmit p")[0].onclick = function() {
|
|||||||
}
|
}
|
||||||
info = info.split("\n");
|
info = info.split("\n");
|
||||||
var newPhonemes = {};
|
var newPhonemes = {};
|
||||||
|
console.log(info);
|
||||||
for(var i = 0; i < info.length; i++) {
|
for(var i = 0; i < info.length; i++) {
|
||||||
info[i] = info[i].split(/[ ,]+/);
|
info[i] = info[i].split(/[ ,]+/);
|
||||||
var num = parseFloat(info[i][1]);
|
var num = parseFloat(info[i][1]);
|
||||||
@ -569,26 +570,32 @@ document.querySelectorAll("#editLanguageSubmit p")[0].onclick = function() {
|
|||||||
}
|
}
|
||||||
newPhonemes[info[i][0]] = num;
|
newPhonemes[info[i][0]] = num;
|
||||||
}
|
}
|
||||||
|
console.log(newPhonemes);
|
||||||
|
|
||||||
this.innerText = "Processing...";
|
this.innerText = "Processing...";
|
||||||
this.style.backgroundColor = "rgba(0,0,0,0.2)";
|
this.style.backgroundColor = "rgba(0,0,0,0.2)";
|
||||||
var p = this;
|
var p = this;
|
||||||
|
|
||||||
var diffChange = [];
|
var oldPhoneset = new Set(Object.keys(langInfo.phonemes));
|
||||||
var diffRemove = [];
|
var newPhoneset = new Set(Object.keys(newPhonemes));
|
||||||
var phoKeys = Object.keys(langInfo.phonemes);
|
var diffRemove = [...oldPhoneset].filter(x=>!newPhoneset.has(x));
|
||||||
for(var i = 0; i < phoKeys.length; i++) {
|
var diffChange = [...newPhoneset].filter(x=>!oldPhoneset.has(x));
|
||||||
if(newPhonemes[phoKeys[i]] === undefined) {
|
var union = [...newPhoneset].filter(x=>oldPhoneset.has(x));
|
||||||
diffRemove.push(phoKeys[i]);
|
|
||||||
} else if(langInfo.phonemes[phoKeys[i]] !== newPhonemes[phoKeys[i]]) {
|
for(var i = 0; i < union.length; i++) {
|
||||||
diffChange.push(phoKeys[i]);
|
console.log(langInfo.phonemes[union[i]]);
|
||||||
|
console.log(newPhonemes[union[i]]);
|
||||||
|
if(newPhonemes[union[i]] === undefined) {
|
||||||
|
diffRemove.push(union[i]);
|
||||||
|
} else if(langInfo.phonemes[union[i]] !== newPhonemes[union[i]]) {
|
||||||
|
diffChange.push(union[i]);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var todo = {
|
var todo = {
|
||||||
name: newLanguage.name !== langInfo.name,
|
name: name !== langInfo.name,
|
||||||
add: diffChange.length > 0,
|
add: diffChange.length > 0,
|
||||||
remove: diffRemove.length > 0
|
remove: diffRemove.length > 0
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user