Skip to content

Commit

Permalink
copy command link
Browse files Browse the repository at this point in the history
  • Loading branch information
miaawong committed Oct 14, 2024
1 parent c0cc179 commit bf10e8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions kurl_proxy/assets/insecure.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,12 @@
<pre>
<code id="verify-snippet">
</code>
<span id="copy-command">Copy command</span>
</pre>
<div class="copy-command">
<a id="copy-command" class="replicated-link"
>Copy command</a
>
</div>
</div>
</div>
<div class="CodeSnippet">
Expand Down Expand Up @@ -235,15 +239,19 @@
document
.getElementById("copy-command")
.addEventListener("click", function () {
// Get the code inside the <code> element
const codeSnippet =
document.getElementById("verify-snippet").textContent;

// Copy the code to the clipboard
navigator.clipboard
.writeText(codeSnippet)
.then(() => {
alert("Command copied to clipboard!");
const copyCommandElement = document.getElementById("copy-command");
const originalText = copyCommandElement.textContent;
copyCommandElement.textContent = "Copied!";

setTimeout(() => {
copyCommandElement.textContent = originalText;
}, 3000);
})
.catch((err) => {
console.error("Failed to copy text: ", err);
Expand Down
5 changes: 5 additions & 0 deletions kurl_proxy/assets/tls-custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,8 @@ p.hidden {
.cursor {
cursor: pointer;
}

.copy-command {
font-size: 12px;
padding-top: 8px;
}

0 comments on commit bf10e8c

Please sign in to comment.