aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com> 2021-02-05 20:58:27 +0100
committerMango0x45 <thomasvoss@live.com> 2021-02-05 20:58:27 +0100
commit5d0f583a9f85346b885bc536690fde417184ffa7 (patch)
treea333d29af57b0ccba7e9e67397f897db6877c071
parent807c552ca9f0ad5a504301be3b1b4d7288508e3b (diff)
Use named functions
-rw-r--r--.clang-format2
-rw-r--r--main.js42
2 files changed, 21 insertions, 23 deletions
diff --git a/.clang-format b/.clang-format
index 3044a0c..2aceea2 100644
--- a/.clang-format
+++ b/.clang-format
@@ -57,4 +57,4 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 8
UseCRLF: false
-UseTab: ForIndentation \ No newline at end of file
+UseTab: Always \ No newline at end of file
diff --git a/main.js b/main.js
index d544795..fd77355 100644
--- a/main.js
+++ b/main.js
@@ -1,15 +1,12 @@
+/* Compute the total duration of the run */
function compute()
{
- /*
- * Get framerate, start frame, and end frame from corresponding elements
- * Double check they all have a value
- */
const fps = parseInt(document.getElementById("framerate").value);
const sframe = document.getElementById("startobj").value;
const eframe = document.getElementById("endobj").value;
if (typeof (sframe) === "undefined" || typeof (eframe) === "undefined"
- || typeof (fps) === "undefined")
+ || typeof (fps) === "undefined")
return;
const frames = (eframe - sframe) * fps;
@@ -58,25 +55,26 @@ function copy_mod_message()
}
/* If framerate is invalid, show an error message and disable start and end frame fields */
-const check_fps =
- (event) => {
- if (event.target.value === "" || parseInt(event.target.value) <= 0
- || isNaN(parseInt(event.target.value))) {
- document.getElementById("framerate")
- .setCustomValidity("Please enter a valid framerate.");
- document.getElementById("framerate").reportValidity();
- document.getElementById("startobj").disabled = true;
- document.getElementById("endobj").disabled = true;
- document.getElementById("compute_button").disabled = true;
- } else {
- document.getElementById("startobj").disabled = false;
- document.getElementById("endobj").disabled = false;
- document.getElementById("compute_button").disabled = false;
- }
- }
+function check_fps(event)
+{
+ if (event.target.value === "" || parseInt(event.target.value) <= 0
+ || isNaN(parseInt(event.target.value))) {
+ document.getElementById("framerate")
+ .setCustomValidity("Please enter a valid framerate.");
+ document.getElementById("framerate").reportValidity();
+ document.getElementById("startobj").disabled = true;
+ document.getElementById("endobj").disabled = true;
+ document.getElementById("compute_button").disabled = true;
+ } else {
+ document.getElementById("startobj").disabled = false;
+ document.getElementById("endobj").disabled = false;
+ document.getElementById("compute_button").disabled = false;
+ }
+}
/* Get current frame from input field (either start time or end time) */
-const parse_time = (event) => {
+function parse_time(event)
+{
let inptext_frame = (JSON.parse(event.target.value)).lct;
if (typeof inptext_frame !== "undefined") {
const fps = parseInt(document.getElementById("framerate").value);