aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.js
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com> 2021-03-30 13:03:03 +0200
committerMango0x45 <thomasvoss@live.com> 2021-03-30 13:03:03 +0200
commit61460b52758297daf1d315ae7960d4ec9713b3af (patch)
tree0b6f9e8f698e1c29dba56d6fc2fa352a6fa177ee /main.js
parent971d279043e45c555d36502ae2bbaed2b81c2806 (diff)
Grab CSS from stackedit and remove all the bloat. Also start work on dark theme.
Diffstat (limited to 'main.js')
-rw-r--r--main.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/main.js b/main.js
index da3d68f..ff338a8 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,4 @@
-/* Compute the total duration of the run */
+/* Compute the total duration of the run. */
function compute()
{
const fps = parseInt(document.getElementById("framerate").value);
@@ -11,7 +11,7 @@ function compute()
const frames = (et - st) * fps;
const s = Math.round(frames / fps * 1000) / 1000;
- /* Show the time and mod message in the DOM */
+ /* Show the time and mod message in the DOM. */
const sf = Math.trunc(st * fps);
const ef = Math.trunc(et * fps);
const t = time_format(s);
@@ -24,7 +24,7 @@ function compute()
document.getElementById("mod_message_button").disabled = false;
}
-/* Convert seconds to human readable time */
+/* Convert seconds to human readable time. */
function time_format(t)
{
const h = ~~(t / 3600);
@@ -40,7 +40,7 @@ function time_format(t)
return ret;
}
-/* Allow user to copy mod message to clipboard */
+/* Allow user to copy mod message to clipboard. */
function copy_mod_message()
{
const text_area = document.getElementById("mod_message");
@@ -49,8 +49,10 @@ function copy_mod_message()
document.execCommand("copy");
}
-/* If framerate is invalid, show an error message and disable start and end
- * frame fields */
+/*
+ * If framerate is invalid, show an error message and disable start and end
+ * frame fields.
+ */
function check_fps(event)
{
fps = event.target.value;
@@ -68,9 +70,10 @@ function check_fps(event)
}
}
-/* Get current frame from input field (either start time or end time) */
+/* Get current frame from input field (either start time or end time). */
function parse_time(event)
{
+ let inptext_frame;
try {
inptext_frame = (JSON.parse(event.target.value)).cmt;
} catch {
@@ -90,3 +93,19 @@ function parse_time(event)
&& document.getElementById("endobj").value)
compute();
}
+
+/* Change the users preferred theme. */
+function change_preferance()
+{
+ const color_switch = document.getElementById("color_preference");
+
+ if (color_switch.checked) {
+ document.body.classList.add("dark");
+ document.body.classList.remove("light");
+ localStorage.setItem("preference", "dark");
+ } else {
+ document.body.classList.add("light");
+ document.body.classList.remove("dark");
+ localStorage.setItem("preference", "light");
+ }
+}