From 8408c187d6147914c671ede4c5d620886adb344c Mon Sep 17 00:00:00 2001 From: Mammad <67197540+Mammad900@users.noreply.github.com> Date: Tue, 14 Dec 2021 08:06:23 +0330 Subject: [PATCH] Add copy button to build.html --- build.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/build.html b/build.html index b9ce4bd..7e8eb73 100644 --- a/build.html +++ b/build.html @@ -265,6 +265,9 @@

Hidden text

Empty commands +
@@ -652,6 +655,26 @@ function onOptionsChanged() { } commands.push((use_powershell ? 'dir ' : 'ls -l ') + install_dir + '/bin/telegram-bot-api*'); document.getElementById('buildCommands').innerHTML = ''; + 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); + }) }