summaryrefslogtreecommitdiff
path: root/web/static/dartboat.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r--web/static/dartboat.js34
1 files changed, 11 insertions, 23 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 94337be..44daabb 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -60,6 +60,11 @@ function elemSetUniqClass(sel, c, sel_set) {
e.classList[sel && e.matches(selstr) ? 'add' : 'remove'](cstr));
}
+function elemScrollToBottom(sel) {
+ const e = $(UTF8ToString(sel));
+ e.scrollTop = e.scrollHeight;
+}
+
function promptHandle(command, data) {
const str_c = toCString(command);
const str_d = data && toCString(data);
@@ -69,34 +74,17 @@ function promptHandle(command, data) {
if (str_d) _free(str_d);
}
-const POINT_CLASSES = [180, 140, 100, 60, 40, 20, 0];
-function drawVisit(visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts) {
- const e = $('#visits');
-
- for (const [i, ptr] of [
- p1_pts, p1_rem, visit_no, p2_rem, p2_pts, p2_darts].entries()) {
-
- const div = e.appendChild(document.createElement('div'));
- const v = div.textContent = UTF8ToString(ptr);
- div.classList.add(`visit-col${i+1}`);
- if (i == 0 || i == 4)
- div.classList.add(`p${POINT_CLASSES.find(x => x <= v)}`);
- else if (i == 5 && v)
- div.textContent = `… ${v}`;
- }
-
- e.scrollTop = e.scrollHeight;
-}
-
-function svgAppendElemv(sel, elemc, elemv, off_name, off_n_attrs,
- off_attr_names, off_attr_vals, off_content) {
+function elemAppendElemv(sel, elemc, elemv, off_ns, off_name, off_content,
+ off_n_attrs, off_attr_names, off_attr_vals) {
const target = $(UTF8ToString(sel));
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 nsptr = HEAP32[(struct + off_ns)>>2];
+ const name = UTF8ToString(HEAP32[(struct + off_name)>>2]);
+ const e = nsptr ? document.createElementNS(UTF8ToString(nsptr), name) :
+ document.createElement(name);
const n_attrs = HEAP32[(struct + off_n_attrs)>>2];
if (n_attrs) {