summaryrefslogtreecommitdiff
path: root/web/static/dartboat.js
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-28 18:27:47 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-28 18:27:47 -0700
commit0fdc050919f0a7a2dce53baf348ab1f9b328d6da (patch)
tree5fa41806e0eb8140b815a4dd901de31a12fabe24 /web/static/dartboat.js
parentfcc02efbff337c05bf448231cd8bfbe016939f8a (diff)
downloaddartboat-0fdc050919f0a7a2dce53baf348ab1f9b328d6da.tar.gz
dartboat-0fdc050919f0a7a2dce53baf348ab1f9b328d6da.tar.xz
web: less javascript, more c
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r--web/static/dartboat.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 98bbb37..53a113a 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -136,6 +136,30 @@ function drawVisit(visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts) {
e.scrollTop = e.scrollHeight;
}
+function drawElem(target, name, n_attrs, attr_names, attr_vals, content) {
+ const e = document.createElementNS('http://www.w3.org/2000/svg',
+ UTF8ToString(name));
+ if (content) e.textContent = UTF8ToString(content);
+
+ for (let i = 0; i < n_attrs; ++i)
+ e.setAttribute(UTF8ToString(HEAP32[(attr_names + i*4)>>2]),
+ UTF8ToString(HEAP32[(attr_vals + i*4)>>2]));
+
+ target.appendChild(e);
+}
+
+function drawElemBoard(...args) {
+ drawElem($('#dartboard'), ...args);
+}
+
+function drawElemPoint(...args) {
+ drawElem($('#dartboard-points'), ...args);
+}
+
+function clearPoints() {
+ $('#dartboard-points').textContent = '';
+}
+
function updateDelay(val) {
$('#delay').value = val;
}