diff options
author | Thomas Voss <57815710+Mango0x45@users.noreply.github.com> | 2021-02-03 17:25:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-03 17:25:16 +0100 |
commit | 17f69120182b8e68f705b671c41a2a89ae8c8c2a (patch) | |
tree | 05ecb87eb3b45c83eb754dd4757ab8db3cb87863 | |
parent | fdaad44bc731c638a3931d697363e281184e6e30 (diff) |
Remove credits
-rw-r--r-- | main.js | 47 |
1 files changed, 24 insertions, 23 deletions
@@ -1,30 +1,31 @@ -function compute() { - - // Initiate basic time variables +function compute() +{ + /* Initiate basic time variables */ let hours = 0; let minutes = 0; let seconds = 0; let milliseconds = 0; - // Get framerate, start frame, and end frame from corresponding elements - // Double check they all have a value + /* + * Get framerate, start frame, and end frame from corresponding elements + * Double check they all have a value + */ let frameRate = parseInt(document.getElementById('framerate').value); let startFrame = document.getElementById('startobj').value; let endFrame = document.getElementById('endobj').value; - if (typeof (startFrame) === 'undefined' || endFrame === 'undefined' || framerate === 'undefined') { - return - }; + if (typeof (startFrame) === 'undefined' || endFrame === 'undefined' || framerate === 'undefined') + return; - // Calculate framerate + /* Calculate framerate */ let frames = (endFrame - startFrame) * frameRate; seconds = Math.floor(frames / frameRate); frames = frames % frameRate; milliseconds = Math.round(frames / frameRate * 1000); - if (milliseconds < 10) { + if (milliseconds < 10) milliseconds = '00' + milliseconds; - } else if (milliseconds < 100) { + else if (milliseconds < 100) milliseconds = '0' + milliseconds; - } + if (seconds >= 60) { minutes = Math.floor(seconds / 60); seconds = seconds % 60; @@ -36,18 +37,18 @@ function compute() { minutes = minutes < 10 ? '0' + minutes : minutes; } - // Show the time and mod message in the DOM + /* Show the time and mod message in the DOM */ let finalTime = hours.toString() + 'h ' + minutes.toString() + 'm ' + seconds.toString() + 's ' + milliseconds.toString() + 'ms'; - let modMessage = `Mod Message: Time starts at ${parseFloat(startFrame).toFixed(3)} and ends at ${parseFloat(endFrame).toFixed(3)} at ${frameRate} fps to get a final time of ${finalTime}.`; - let credits = `Retimed using [yt-frame-timer](https://slashinfty.github.io/yt-frame-timer)`; + let modMessage = `Mod Note: Retimed (Start: Frame ${startFrame}, End: Frame ${endFrame}, FPS: ${frameRate}, Total Time: ${finalTime})`; document.getElementById('time').value = finalTime; document.getElementById('modMessage').disabled = false; - document.getElementById('modMessage').innerText = modMessage + ' ' + credits; + document.getElementById('modMessage').innerText = modMessage; document.getElementById("modMessageButton").disabled = false; } -function copyModMessage() { - // Allow user to copy mod message to clipboard +/* Allow user to copy mod message to clipboard */ +function copyModMessage() +{ const textArea = document.getElementById('modMessage'); textArea.focus(); textArea.select(); @@ -55,8 +56,8 @@ function copyModMessage() { alert(`The mod message has been copied to clipboard! Please paste it into the comment of the run you are verifying.`); } +/* If framerate is invalid, show an error message and disable start and end frame fields */ const validateFPS = (event) => { - // If framerate is invalid, show an error message and disable start and end frame fields 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(); @@ -71,15 +72,15 @@ const validateFPS = (event) => { } const parseForTime = (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) */ let frameFromInputText = (JSON.parse(event.target.value)).lct; if (typeof frameFromInputText !== 'undefined') { - // Get the framerate + /* Get the framerate */ let frameRate = parseInt(document.getElementById('framerate').value); - // Calculate the frame + /* Calculate the frame */ let frameFromObj = (time, fps) => Math.floor(time * fps) / fps; //round to the nearest frame let finalFrame = frameFromObj(frameFromInputText, frameRate); - // Update the DOM + /* Update the DOM */ document.getElementById(event.target.id).value = `${finalFrame}`; } } |