aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMammad <67197540+Mammad900@users.noreply.github.com>2021-12-14 08:06:23 +0330
committerAliaksei Levin <22669599+levlam@users.noreply.github.com>2021-12-17 17:02:25 +0300
commit8408c187d6147914c671ede4c5d620886adb344c (patch)
tree53d86eed05805de43761fd4de495098f43f4c31a
parent34b8e7d15e37ee39085b13f5fe92a557a9266ed1 (diff)
Add copy button to build.html
-rw-r--r--build.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/build.html b/build.html
index b9ce4bd..7e8eb73 100644
--- a/build.html
+++ b/build.html
@@ -265,6 +265,9 @@
<div id="buildCommandsDiv" class="hide">
<p id="buildPre">Hidden text</p>
<code id="buildCommands">Empty commands</code>
+ <button id="copyBuildCommandsButton" onclick="copyBuildInstructions()">
+ <span id="copyBuildCommandsText">Copy</span>
+ </button>
</div>
</div>
@@ -652,6 +655,26 @@ function onOptionsChanged() {
}
commands.push((use_powershell ? 'dir ' : 'ls -l ') + install_dir + '/bin/telegram-bot-api*');
document.getElementById('buildCommands').innerHTML = '<ul><li>' + commands.join('</li><li>') + '</li></ul>';
+ document.getElementById('copyBuildCommandsButton').style.display = commands.includes('exit') ? 'none' : 'block';
+}
+
+function copyBuildInstructions() {
+ var text = document.getElementById('buildCommands').innerText;
+
+ function resetButtonState (state) {
+ document.getElementById('copyBuildCommandsButton').classList.remove(state);
+ document.getElementById('copyBuildCommandsText').innerText = "Copy";
+ }
+
+ navigator.clipboard.writeText(text).then(result => {
+ document.getElementById('copyBuildCommandsButton').classList.add('success');
+ document.getElementById('copyBuildCommandsText').innerText = "Copied!";
+ setTimeout(() => resetButtonState('success'), 5000);
+ }, error => {
+ document.getElementById('copyBuildCommandsButton').classList.add('fail');
+ document.getElementById('copyBuildCommandsText').innerText = "Couldn't copy :(";
+ setTimeout(() => resetButtonState('fail'), 5000);
+ })
}
</script>