summaryrefslogtreecommitdiff
path: root/web/static/dartboat.js
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-29 03:30:38 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-29 03:30:38 -0700
commitfbdb393ae1e2ea5d368e4dda1577a10715e26a75 (patch)
tree829940532fd9933d067a09ccff223f3c2ef6c789 /web/static/dartboat.js
parentabc559995546eda81a51ad7d03422b5c7e09fa87 (diff)
downloaddartboat-fbdb393ae1e2ea5d368e4dda1577a10715e26a75.tar.gz
dartboat-fbdb393ae1e2ea5d368e4dda1577a10715e26a75.tar.xz
web: clean up svg generation code
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r--web/static/dartboat.js26
1 files changed, 3 insertions, 23 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index c17e29d..8716185 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -136,7 +136,7 @@ function drawVisit(visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts) {
e.scrollTop = e.scrollHeight;
}
-function drawElemv(elemc, elemv, off_name, off_n_attrs, off_attr_names,
+function svgDrawElemv(layer, elemc, elemv, off_name, off_n_attrs, off_attr_names,
off_attr_vals, off_content) {
for (let ptr = elemv; ptr < elemv + 4*elemc; ptr += 4) {
const struct = HEAP32[ptr>>2];
@@ -156,31 +156,11 @@ function drawElemv(elemc, elemv, off_name, off_n_attrs, off_attr_names,
const content = HEAP32[(struct + off_content)>>2];
if (content) e.textContent = UTF8ToString(content);
- $('#dartboard').appendChild(e);
+ $(`#dartboard${layer ? '-points' : ''}`).appendChild(e);
}
}
-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() {
+function svgClearPoints() {
$('#dartboard-points').textContent = '';
}