From 1ab3c4995e44f44a845dce7b241554c0621527b9 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 3 May 2022 21:25:44 -0700 Subject: web: use generic JS function for updating opt elems --- web/static/dartboat.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'web/static') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 44daabb..4edba8a 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -37,6 +37,10 @@ function elemSetContent(sel, str) { $(UTF8ToString(sel)).textContent = str ? UTF8ToString(str) : ''; } +function elemSetValue(sel, str) { + $(UTF8ToString(sel)).value = str ? UTF8ToString(str) : ''; +} + function elemHasClass(sel, c) { return $(UTF8ToString(sel)).classList.contains(UTF8ToString(c)); } @@ -65,15 +69,6 @@ function elemScrollToBottom(sel) { e.scrollTop = e.scrollHeight; } -function promptHandle(command, data) { - const str_c = toCString(command); - const str_d = data && toCString(data); - _prompt_handle(str_c, str_d); - - _free(str_c); - if (str_d) _free(str_d); -} - function elemAppendElemv(sel, elemc, elemv, off_ns, off_name, off_content, off_n_attrs, off_attr_names, off_attr_vals) { const target = $(UTF8ToString(sel)); @@ -102,12 +97,13 @@ function elemAppendElemv(sel, elemc, elemv, off_ns, off_name, off_content, } } -function updateDelay(val) { - $('#delay').value = val; -} +function promptHandle(command, data) { + const str_c = toCString(command); + const str_d = data && toCString(data); + _prompt_handle(str_c, str_d); -function updateStdev(val) { - $('#stdev').value = parseFloat(val.toFixed(2).slice(0, 4)); + _free(str_c); + if (str_d) _free(str_d); } function setOpt(opt, val, update_opts = true) { -- cgit v1.2.3-70-g09d2