diff options
-rw-r--r-- | index.html | 7 | ||||
-rw-r--r-- | main.js | 20 |
2 files changed, 14 insertions, 13 deletions
@@ -8,7 +8,6 @@ <title>YouTube Frame Timer</title> <link rel="stylesheet" href="https://stackedit.io/style.css" /> <script src="main.js"></script> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body class="stackedit"> @@ -42,9 +41,9 @@ <h3 id="video-time">Video Time</h3> <button id="computeButton" onclick="compute()">Compute time</button> <input type="text" id="time" readonly size="20" /> - <p id="modMessage"></p> - <button id="modMessageButton" disabled>Copy Mod Message to Clipboard</button> + <p><textarea id="modMessage" cols="40" rows="5"></textarea></p> + <button id="modMessageButton" onclick="copyModMessage()" disabled>Copy Mod Message to Clipboard</button> </div> </body> -</html>
\ No newline at end of file +</html> @@ -41,15 +41,17 @@ function compute() { 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://mattbraddock.com/yt-frame-timer)`; document.getElementById('time').value = finalTime; - document.getElementById('modMessage').innerHTML = modMessage + ' ' + credits; - - // Allow user to copy mod message to clipboard + document.getElementById('modMessage').innerText = modMessage + ' ' + credits; document.getElementById("modMessageButton").disabled = false; - $("#modMessageButton").click(function () { - navigator.clipboard.writeText(modMessage + ' ' + credits) - .then(() => { alert(`The mod message has been copied to clipboard! Please paste it into the comment of the run you are verifying.`) }) - .catch((error) => { alert(`Failed to copy to clipboard! ${error}`) }) - }); +} + +function copyModMessage() { + // Allow user to copy mod message to clipboard + const textArea = document.getElementById('modMessage'); + textArea.focus(); + textArea.select(); + document.execCommand('copy'); + alert(`The mod message has been copied to clipboard! Please paste it into the comment of the run you are verifying.`); } const validateFPS = (event) => { @@ -79,4 +81,4 @@ const parseForTime = (event) => { // Update the DOM document.getElementById(event.target.id).value = `${finalFrame}`; } -}
\ No newline at end of file +} |