mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
ui: Fixed bug with Copied to clipboard.
This commit is contained in:
@@ -456,6 +456,8 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script>
|
<script>
|
||||||
|
let clickTimeout = null;
|
||||||
|
|
||||||
function copyToClipboard(text) {
|
function copyToClipboard(text) {
|
||||||
const el = document.createElement('textarea');
|
const el = document.createElement('textarea');
|
||||||
el.value = text;
|
el.value = text;
|
||||||
@@ -469,49 +471,47 @@
|
|||||||
const addressElement = document.getElementById(elementId);
|
const addressElement = document.getElementById(elementId);
|
||||||
if (!addressElement) return;
|
if (!addressElement) return;
|
||||||
const addressText = addressElement.innerText.trim();
|
const addressText = addressElement.innerText.trim();
|
||||||
|
|
||||||
|
if (addressText === 'Copied to clipboard') return;
|
||||||
|
|
||||||
copyToClipboard(addressText);
|
copyToClipboard(addressText);
|
||||||
addressElement.innerText = 'Copied to clipboard';
|
addressElement.innerText = 'Copied to clipboard';
|
||||||
|
|
||||||
const originalWidth = addressElement.offsetWidth;
|
const originalWidth = addressElement.offsetWidth;
|
||||||
|
|
||||||
addressElement.classList.add('copying');
|
addressElement.classList.add('copying');
|
||||||
|
|
||||||
addressElement.parentElement.style.width = `${originalWidth}px`;
|
addressElement.parentElement.style.width = `${originalWidth}px`;
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
addressElement.innerText = addressText;
|
addressElement.innerText = addressText;
|
||||||
addressElement.classList.remove('copying');
|
addressElement.classList.remove('copying');
|
||||||
addressElement.parentElement.style.width = '';
|
addressElement.parentElement.style.width = '';
|
||||||
}, 2000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const stealthAddressElement = document.getElementById('stealth_address');
|
const stealthAddressElement = document.getElementById('stealth_address');
|
||||||
if (stealthAddressElement) {
|
if (stealthAddressElement) {
|
||||||
stealthAddressElement.addEventListener('click', function() {
|
stealthAddressElement.addEventListener('click', function() {
|
||||||
copyAndShowMessage('stealth_address');
|
copyAndShowMessage('stealth_address');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainDepositAddressElement = document.getElementById('main_deposit_address');
|
const mainDepositAddressElement = document.getElementById('main_deposit_address');
|
||||||
if (mainDepositAddressElement) {
|
if (mainDepositAddressElement) {
|
||||||
mainDepositAddressElement.addEventListener('click', function() {
|
mainDepositAddressElement.addEventListener('click', function() {
|
||||||
copyAndShowMessage('main_deposit_address');
|
copyAndShowMessage('main_deposit_address');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const moneroMainAddressElement = document.getElementById('monero_main_address');
|
const moneroMainAddressElement = document.getElementById('monero_main_address');
|
||||||
if (moneroMainAddressElement) {
|
if (moneroMainAddressElement) {
|
||||||
moneroMainAddressElement.addEventListener('click', function() {
|
moneroMainAddressElement.addEventListener('click', function() {
|
||||||
copyAndShowMessage('monero_main_address');
|
copyAndShowMessage('monero_main_address');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const moneroSubAddressElement = document.getElementById('monero_sub_address');
|
const moneroSubAddressElement = document.getElementById('monero_sub_address');
|
||||||
if (moneroSubAddressElement) {
|
if (moneroSubAddressElement) {
|
||||||
moneroSubAddressElement.addEventListener('click', function() {
|
moneroSubAddressElement.addEventListener('click', function() {
|
||||||
copyAndShowMessage('monero_sub_address');
|
copyAndShowMessage('monero_sub_address');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<section class="p-6">
|
<section class="p-6">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user