summaryrefslogtreecommitdiff
path: root/scripts/gui-common/log.js
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2025-12-20 17:16:29 -0500
committerKai Gunger <kgunger12@gmail.com>2025-12-20 17:16:29 -0500
commitfdb7c090df9b86304ca6f6f202a39a0f63ed0b03 (patch)
tree9e937245be7c61a04f0b2d00ba6041e9801947c7 /scripts/gui-common/log.js
parentd036ac50abc68a28270773009c1c005de788296b (diff)
Add debug log to tell what is going on on mobile
Diffstat (limited to 'scripts/gui-common/log.js')
-rw-r--r--scripts/gui-common/log.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/gui-common/log.js b/scripts/gui-common/log.js
new file mode 100644
index 0000000..dcf5ac2
--- /dev/null
+++ b/scripts/gui-common/log.js
@@ -0,0 +1,38 @@
+'use strict';
+
+
+const LOG_EL = document.getElementsByTagName("log")[0];
+let LAST_LOG_TYPE = "";
+
+function at_bot(el) {
+ return el.scrollTop >= (el.scrollHeight - el.clientHeight)
+}
+
+function addLogEntry(object) {
+
+ let do_scroll = at_bot(LOG_EL);
+
+ let out = {
+ type: object.type,
+ target: object.target.classList.toString()
+ };
+
+ if (LAST_LOG_TYPE == "mousemove" || LAST_LOG_TYPE == "touchmove") {
+ if (LAST_LOG_TYPE == out.type)
+ return;
+ }
+
+ LAST_LOG_TYPE = out.type;
+
+ let entry = document.createElement("entry");
+ entry.innerText = JSON.stringify(out);
+
+ LOG_EL.appendChild(entry);
+
+ if (do_scroll) {
+ LOG_EL.scroll({
+ top: LOG_EL.scrollHeight,
+ behavior: "instant",
+ });
+ }
+} \ No newline at end of file