From 237359d107c5f8fb3e1f7a3532696eb19a6c56fc Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 2 May 2022 15:20:34 -0700 Subject: web: buffer player info and flush on state change Constant calls from Wasm to JS to replace unchanged elements in the DOM is not very efficient. --- web/static/dartboat.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/static/dartboat.js') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 8716185..13a5da4 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -98,15 +98,15 @@ function hidePlayerInfo(n) { } function updatePlayerName(n, ptr) { - $(`#p${n}-name`).textContent = UTF8ToString(ptr); + $(`#p${n}-name`).textContent = ptr && UTF8ToString(ptr); } function updatePlayerRem(n, ptr) { - $(`#p${n}-rem`).textContent = UTF8ToString(ptr); + $(`#p${n}-rem`).textContent = ptr && UTF8ToString(ptr); } function updatePlayerSugg(n, ptr) { - $(`#p${n}-sugg`).textContent = UTF8ToString(ptr); + $(`#p${n}-sugg`).textContent = ptr && UTF8ToString(ptr); } function updatePlayerAvg(n, avg) { -- cgit v1.2.3-70-g09d2