main.js: handle undefined styleName in style chooser

This commit is contained in:
Zankaria 2024-08-07 22:49:04 +02:00
parent 14272c87e9
commit 17f92344e9

View file

@ -216,16 +216,18 @@ function initStyleChooser() {
newElement.className = 'styles';
for (styleName in styles) {
var style = document.createElement('a');
style.innerHTML = '[' + styleName + ']';
style.onclick = function() {
changeStyle(this.innerHTML.substring(1, this.innerHTML.length - 1), this);
};
if (styleName == selectedstyle) {
style.className = 'selected';
if (styleName) {
var style = document.createElement('a');
style.innerHTML = '[' + styleName + ']';
style.onclick = function() {
changeStyle(this.innerHTML.substring(1, this.innerHTML.length - 1), this);
};
if (styleName == selectedstyle) {
style.className = 'selected';
}
style.href = 'javascript:void(0);';
newElement.appendChild(style);
}
style.href = 'javascript:void(0);';
newElement.appendChild(style);
}
document.getElementById('bottom-hud').before(newElement);