aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com> 2021-05-14 21:07:14 +0200
committerMango0x45 <thomasvoss@live.com> 2021-05-14 21:07:14 +0200
commite132cff4df6e08c54b185af87dd547072b0a8f9a (patch)
tree974ba4b159c2da5bafec395d94fb7ff6067a08e7
parentc1b4fa4d3223f5373138a4e0e7f73b91239d656e (diff)
Use bitwise operators to look cooler
-rw-r--r--main.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/main.js b/main.js
index 1e3d80c..2861b0b 100644
--- a/main.js
+++ b/main.js
@@ -19,8 +19,8 @@ function compute()
const seconds = Math.round(frames / fps * 1000) / 1000;
/* Show the time and mod message in the DOM. */
- const s_frame = Math.trunc(s_time * fps);
- const e_frame = Math.trunc(e_time * fps);
+ const s_frame = ~~(s_time * fps);
+ const e_frame = ~~(e_time * fps);
const time = time_format(seconds);
document.getElementById("time").value = time;
@@ -38,13 +38,16 @@ function generate_mod_message(
const hours = ~~(total_seconds / 3600)
const minutes = ~~((total_seconds % 3600) / 60);
- const seconds = Math.trunc(total_seconds % 60);
+ const seconds = ~~(total_seconds % 60);
const milliseconds = total_seconds % 60 % 1;
const padded_minutes = (minutes < 10) ? "0" + minutes : minutes;
const padded_seconds = (seconds < 10) ? "0" + seconds : seconds;
- /* TODO: THIS IS REALLY BAD CODE!! FIX THIS!! */
+ /*
+ * TODO: THIS IS REALLY STUPID CODE!!
+ * In a language as bloated as JS surely there is a better way??
+ */
const one_prec_millis = milliseconds.toFixed(1).replace("0.", "");
const two_prec_millis = milliseconds.toFixed(2).replace("0.", "");
const three_prec_millis = milliseconds.toFixed(3).replace("0.", "");