From 36c8f1e48f5ca0d6ae215ebed98a21069e312c71 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Mon, 2 Jun 2025 13:47:02 +0200 Subject: [PATCH] Avoid spurious errors while display is initializing --- buba/static/display.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buba/static/display.js b/buba/static/display.js index 18ccfe5..9bc5652 100644 --- a/buba/static/display.js +++ b/buba/static/display.js @@ -1,5 +1,6 @@ export default class { constructor(container, config = {}) { + this.ready = false; this.svgns = "http://www.w3.org/2000/svg"; this.config = Object.assign({ templateSvgUrl: "static/geascript-proportional.svg", @@ -19,6 +20,7 @@ export default class { let parser = new DOMParser(); this.segmentsDom = parser.parseFromString(new TextDecoder().decode(blob), 'image/svg+xml'); this.buildDisplay() + this.ready = true; console.log("Done building display"); }) .catch(err => console.log(err)); @@ -47,8 +49,6 @@ export default class { rowSvg.id = `geavision__row_${r}_svg`; const width = this.config.stripWidth * this.config.cols rowSvg.setAttribute("viewBox", `0 0 ${parseInt(width)} ${parseInt(viewBox[3])}`); - // rowSvg.setAttribute("width", "320"); - // rowSvg.setAttribute("height", "15"); for (let c = 0; c < this.config.cols; c++) { let g = document.createElementNS(this.svgns, "g"); @@ -67,6 +67,8 @@ export default class { } eraseCol(row, col) { + if (!this.ready) + return; for (let i = 1; i <= this.config.segments; i++) { const e = this.container.querySelector(`#geavision__row_${row}_${col}_${i}`) if (e) { @@ -88,6 +90,8 @@ export default class { } applyCharacter(row, col, char) { + if (!this.ready) + return; let f = this.font[char]; if (f === undefined) return 0;