add langauge debugging. fix corner cases with favorite device selection
This commit is contained in:
parent
780e283931
commit
99b2d4a021
2 changed files with 33 additions and 5 deletions
|
|
@ -15,16 +15,29 @@ var gs_kiri_lang = exports;
|
|||
LANG.set = (key) => {
|
||||
if (LANG[key]) {
|
||||
let map = LANG[key];
|
||||
let missing = [];
|
||||
let invalid = [];
|
||||
// default to EN values when missing
|
||||
Object.keys(LANG.en).forEach(key => {
|
||||
if (!map[key]) {
|
||||
map[key] = LANG.en[key];
|
||||
missing.push(key);
|
||||
}
|
||||
});
|
||||
// update current map from chosen map
|
||||
Object.keys(map).forEach(key => {
|
||||
LANG.current[key] = map[key];
|
||||
if (LANG.en[key]) {
|
||||
LANG.current[key] = map[key];
|
||||
} else {
|
||||
invalid.push(key);
|
||||
}
|
||||
});
|
||||
if (missing.length) {
|
||||
console.log(`language map "${key}" missing keys [${missing.length}]: ${missing.join(', ')}`);
|
||||
}
|
||||
if (invalid.length) {
|
||||
console.log(`language map "${key}" invalid keys [${invalid.length}]: ${invalid.join(', ')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,6 +67,7 @@ var gs_kiri_lang = exports;
|
|||
};
|
||||
|
||||
LANG.test = {
|
||||
bogus: "not a valid key",
|
||||
version: "_version_",
|
||||
dev_name: "_name_"
|
||||
};
|
||||
|
|
|
|||
22
js/kiri.js
22
js/kiri.js
|
|
@ -3229,6 +3229,9 @@ self.kiri.license = exports.LICENSE;
|
|||
};
|
||||
|
||||
UI.deviceSelect.innerHTML = '';
|
||||
let incr = 0;
|
||||
let found = false;
|
||||
let first = devices[0];
|
||||
devices.forEach(function(device, index) {
|
||||
var opt = DOC.createElement('option'),
|
||||
fav = isFavoriteDevice(device),
|
||||
|
|
@ -3236,13 +3239,20 @@ self.kiri.license = exports.LICENSE;
|
|||
if (showFavorites && !(fav || loc)) {
|
||||
return;
|
||||
}
|
||||
if (incr === 0) {
|
||||
first = device;
|
||||
}
|
||||
opt.appendChild(DOC.createTextNode(device));
|
||||
opt.onclick = function() { selectDevice(device) };
|
||||
opt.ondblclick = function() {
|
||||
if (settings.favorites[device]) {
|
||||
delete settings.favorites[device];
|
||||
if (confirm(`remove "${device}" from favorites`)) {
|
||||
delete settings.favorites[device];
|
||||
}
|
||||
} else {
|
||||
settings.favorites[device] = true;
|
||||
if (confirm(`add "${device}" to favorites`)) {
|
||||
settings.favorites[device] = true;
|
||||
}
|
||||
}
|
||||
showDevices();
|
||||
};
|
||||
|
|
@ -3251,7 +3261,11 @@ self.kiri.license = exports.LICENSE;
|
|||
if (loc) opt.setAttribute("local", 1);
|
||||
}
|
||||
UI.deviceSelect.appendChild(opt);
|
||||
if (device === selected) selectedIndex = index;
|
||||
if (device === selected) {
|
||||
selectedIndex = incr;
|
||||
found = true;
|
||||
}
|
||||
incr++;
|
||||
});
|
||||
|
||||
if (selectedIndex >= 0) {
|
||||
|
|
@ -3259,7 +3273,7 @@ self.kiri.license = exports.LICENSE;
|
|||
selectDevice(selected);
|
||||
} else {
|
||||
UI.deviceSelect.selectedIndex = 0;
|
||||
selectDevice(devices[0]);
|
||||
selectDevice(first);
|
||||
}
|
||||
|
||||
showDialog('devices', true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue