diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-29 02:06:33 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-29 02:06:33 -0700 |
commit | abc559995546eda81a51ad7d03422b5c7e09fa87 (patch) | |
tree | de64d607576596c0d60ede8aab5183df97c122c6 /web/static/dartboat.js | |
parent | 0fdc050919f0a7a2dce53baf348ab1f9b328d6da (diff) | |
download | dartboat-abc559995546eda81a51ad7d03422b5c7e09fa87.tar.gz dartboat-abc559995546eda81a51ad7d03422b5c7e09fa87.tar.xz |
web: javascript needs more pointers
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r-- | web/static/dartboat.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 53a113a..c17e29d 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 drawElemv(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]; + + const e = document.createElementNS('http://www.w3.org/2000/svg', + UTF8ToString(HEAP32[(struct + off_name)>>2])); + + const n_attrs = HEAP32[(struct + off_n_attrs)>>2]; + if (n_attrs) { + const attr_names = HEAP32[(struct + off_attr_names)>>2]; + const attr_vals = HEAP32[(struct + off_attr_vals)>>2]; + for (let i = 0; i < n_attrs; ++i) + e.setAttribute(UTF8ToString(HEAP32[(attr_names + i*4)>>2]), + UTF8ToString(HEAP32[(attr_vals + i*4)>>2])); + } + + const content = HEAP32[(struct + off_content)>>2]; + if (content) e.textContent = UTF8ToString(content); + + $('#dartboard').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)); |