aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Braddock <matt.braddock@gmail.com> 2020-08-07 20:37:07 -0400
committerGitHub <noreply@github.com> 2020-08-07 20:37:07 -0400
commit2c0a0a13aeb2c00f7805e22175656b11845f9c1e (patch)
treef481b42c54e9fb1ac7aef6e1c71d3b8a198065e4
parent05563419cd447ed2c91ef635db4c91cf05803325 (diff)
parentc6d6bc1a9c2bdb6f42d70ee027bf97ccda1976a9 (diff)
Merge pull request #5 from zromick/modMessageButton
Created a mod message button to copy mod message to clipboard
-rw-r--r--index.html11
-rw-r--r--main.js12
2 files changed, 11 insertions, 12 deletions
diff --git a/index.html b/index.html
index b8b1cb1..bf39a95 100644
--- a/index.html
+++ b/index.html
@@ -8,6 +8,7 @@
<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">
@@ -39,14 +40,10 @@
<input type="text" id="endobj" style='width:100%' onchange='parseForTime(event)' />
</p>
<h3 id="video-time">Video Time</h3>
- <p>
- <button id="computeButton" onclick="compute()">Compute time</button>&nbsp;<input type="text" id="time" readonly
- size="20" />
- </p>
+ <button id="computeButton" onclick="compute()">Compute time</button>&nbsp;<input type="text" id="time" readonly
+ size="20" />
<p id="modMessage"></p>
- <b>
- <p id="postModMessage"></p>
- </b>
+ <button id="modMessageButton" disabled>Copy Mod Message to Clipboard</button>
</div>
</body>
diff --git a/main.js b/main.js
index 12b6140..d3a3250 100644
--- a/main.js
+++ b/main.js
@@ -41,13 +41,15 @@ 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('postModMessage').innerHTML = "The mod message has been copied to clipboard! Please paste the it into the comment of the run you are verifying.";
document.getElementById('modMessage').innerHTML = modMessage + ' ' + credits;
- // Copy mod message to clipboard
- navigator.clipboard.writeText(modMessage)
- .then(() => { alert(`Copied to clipboard!`) })
- .catch((error) => { alert(`Copy failed! ${error}`) })
+ // Allow user to copy mod message to clipboard
+ 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}`) })
+ });
}
const validateFPS = (event) => {