aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.js
diff options
context:
space:
mode:
authorMatt Braddock <matt.braddock@gmail.com> 2019-01-01 10:50:32 -0500
committerMatt Braddock <matt.braddock@gmail.com> 2019-01-01 10:50:32 -0500
commit6ea7063ac4a1d417711bc1b36574419542b6688d (patch)
tree211459254bad2b08f4ea08fe5360b0e4e8b22228 /main.js
parentcce22684bff556b3a71b7cd9038765308b6b2ca5 (diff)
initial version
Diffstat (limited to 'main.js')
-rw-r--r--main.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..66e1e10
--- /dev/null
+++ b/main.js
@@ -0,0 +1,42 @@
+function compute() {
+ let startObj = JSON.parse(document.getElementById('startobj').value);
+ let endObj = JSON.parse(document.getElementById('endobj').value);
+ let framerate = document.getElementById('framerate').value;
+ if (startObj == undefined || endObj == undefined || framerate == undefined) return;
+ let hours = 0;
+ let minutes = 0;
+ let seconds = 0;
+ let milliseconds = 0;
+ let frameRate = parseInt(framerate);
+ let diff = (endObj.lct - startObj.lct) * frameRate;
+ let frames = diff;
+ if (frames >= frameRate) {
+ seconds = Math.floor(frames / frameRate);
+ frames = frames % frameRate;
+ milliseconds = Math.round(frames / frameRate * 1000);
+ if (milliseconds < 10) {
+ milliseconds = '00' + milliseconds;
+ } else if (milliseconds < 100) {
+ milliseconds = '0' + milliseconds;
+ }
+ if (seconds >= 60) {
+ minutes = Math.floor(seconds / 60);
+ seconds = seconds % 60;
+ seconds = seconds < 10 ? '0' + seconds : seconds;
+ }
+ if (minutes >= 60) {
+ hours = Math.floor(minutes / 60);
+ minutes = minutes % 60;
+ minutes = minutes < 10 ? '0' + minutes : minutes;
+ }
+ } else {
+ milliseconds = Math.round(frames / frameRate * 1000);
+ if (milliseconds < 10) {
+ milliseconds = '00' + milliseconds;
+ } else if (milliseconds < 100) {
+ milliseconds = '0' + milliseconds;
+ }
+ }
+ let print = hours.toString() + 'h ' + minutes.toString() + 'm ' + seconds.toString() + 's ' + milliseconds.toString() + 'ms';
+ document.getElementById('time').value = print;
+} \ No newline at end of file