www/src/layouts/partials/click-to-copy.html
2023-05-13 15:34:58 +02:00

32 lines
1.2 KiB
HTML

<div class="flex pt-1 pb-1 ps-4 pe-1 mb-3 black-bg copy-section" style="max-width: 800px; margin-left:auto; margin-right:auto; height:60px; border: 1px solid #949494;">
<code class="white copy-text" style="font-size:16px;">sh <(curl tea.xyz)</code>
<button class="hbtn hb-fill-right copy-button" style="height:100%; width:30%;">Copy</button>
</div>
<script>
$(".copy-button").on("click", function() {
var copyText = $(this).siblings(".copy-text").text();
// Update the command to copy 'sh <(curl https://tea.xyz)'
copyText = copyText.replace("sh <(curl tea.xyz)", "sh <(curl https://tea.xyz)");
var tempInput = document.createElement("input");
tempInput.style = "position: absolute; left: -1000px; top: -1000px";
tempInput.value = copyText;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
// Change the button text to 'Copied'
var button = $(this);
var originalText = button.text();
button.text("Copied!");
// Change the button text back to original after 2 seconds
setTimeout(function() {
button.text(originalText);
}, 2000);
});
</script>