Add copy link button. Enhance buttons by reverting their text when a new copy event occurs.

This commit is contained in:
2022-12-27 14:11:41 -06:00
parent 5ce04d5bb0
commit d5fa1ffd7a
4 changed files with 26 additions and 12 deletions

View File

@ -0,0 +1,23 @@
function copySecret(secret) {
var tempText = document.createElement('input');
tempText.style = 'position: absolute; left: -1000px; top: -1000px';
tempText.value = secret;
document.body.appendChild(tempText);
tempText.select();
document.execCommand('copy');
document.body.removeChild(tempText);
document.getElementById('secretButton').innerHTML = "- secret copied -";
document.getElementById('linkButton').innerHTML = "copy link";
}
function copyLink(link) {
var tempText = document.createElement('input');
tempText.style = 'position: absolute; left: -1000px; top: -1000px';
tempText.value = window.location.origin + '/pw/' + link;
document.body.appendChild(tempText);
tempText.select();
document.execCommand('copy');
document.body.removeChild(tempText);
document.getElementById('linkButton').innerHTML = "- link copied -";
document.getElementById('secretButton').innerHTML = "copy secret";
}

View File

@ -1,10 +0,0 @@
function copySecret(secret) {
var tempText = document.createElement('input');
tempText.style = 'position: absolute; left: -1000px; top: -1000px';
tempText.value = secret;
document.body.appendChild(tempText);
tempText.select();
document.execCommand('copy');
document.body.removeChild(tempText);
document.getElementById('copyButton').innerHTML = "- secret copied -";
}