diff --git a/resources/glyphEditor.html b/resources/glyphEditor.html index cd550becd8a091c0c9b547f2fa36dd493c9c8c41..3125189c60ac7e58e1fc5987d5786f1e85d43de7 100644 --- a/resources/glyphEditor.html +++ b/resources/glyphEditor.html @@ -164,13 +164,17 @@ const char My_Font[] PROGMEM = { // Should we have a Char and a Pixel class ? not sure it's worth it. // Let's use the DOM to store everything for now + static updateCaption(element, code) { + element.textContent = `Char #${code}`; + } + // Add a pixel matrix to draw a new character // jumpaData not used for now: some day, use the last byte for optimisation addChar(jumpData, charData) { let charContainer = this.fontContainer.appendChild(document.createElement("table")); charContainer.setAttribute("code", this.currentCharCode); let caption = charContainer.appendChild(document.createElement("caption")); - caption.textContent =`Char #${this.currentCharCode}`; + Font.updateCaption(caption, this.currentCharCode); let header = charContainer.appendChild(document.createElement("tr")); header.innerHTML = '<th title="Delete this char" action="delete">✗</th>' + '<th title="Add a char above" action="add">+</th>' @@ -298,7 +302,7 @@ const char My_Font[] PROGMEM = { // Browse each character for(let ch = 0; ch < charCount; ch++) { // Fix renumbering in case first char code was modified - chars[ch].getElementsByTagName('caption')[0].textContent = `Char #${ch + firstCharCode}`; + Font.updateCaption(chars[ch].getElementsByTagName('caption')[0], ch + firstCharCode); let charBytes = []; let charCode = ch + firstCharCode; let rows = chars[ch].getElementsByTagName('tr'); @@ -403,7 +407,7 @@ const char My_Font[] PROGMEM = { currentContainer.parentNode.insertBefore(nextContainer, currentContainer); do { nextContainer.setAttribute('code', code); - nextContainer.getElementsByTagName('caption')[0].textContent = `Char #${code}`; + Font.updateCaption(nextContainer.getElementsByTagName('caption')[0], code); code ++; } while (nextContainer = nextContainer.nextSibling); break; @@ -415,7 +419,7 @@ const char My_Font[] PROGMEM = { nextContainer = currentContainer; while (nextContainer = nextContainer.nextSibling) { nextContainer.setAttribute('code', code); - nextContainer.getElementsByTagName('caption')[0].textContent = `Char #${code}`; + Font.updateCaption(nextContainer.getElementsByTagName('caption')[0], code); code ++; } currentContainer.parentNode.removeChild(currentContainer);