Update copy labels for copy buttons in decrypt and paste views

This commit is contained in:
Vikas
2024-06-23 12:25:27 +05:30
parent eec79dc9d9
commit 6488883f3c
6 changed files with 6 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ templ Decrypt(text string) {
<div>
<pre id="pastedContent" style="padding: 1rem; min-height: 10rem; max-height: 30rem;">{text}</pre>
<div>
<button onclick="copyText(this, '#pastedContent')" data-tooltip="Click to copy">Copy content</button>
<button onclick="copyText(this, '#pastedContent')" data-copy-label="Copy content" data-tooltip="Click to copy">Copy content</button>
</div>
</div>
</div>

View File

@@ -42,7 +42,7 @@ func Decrypt(text string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre><div><button onclick=\"copyText(this, &#39;#pastedContent&#39;)\" data-tooltip=\"Click to copy\">Copy content</button></div></div></div>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre><div><button onclick=\"copyText(this, &#39;#pastedContent&#39;)\" data-copy-label=\"Copy content\" data-tooltip=\"Click to copy\">Copy content</button></div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -14,7 +14,7 @@ templ PasteSuccess(url string) {
<div>
<pre id="url" style="padding: 1rem; min-height: 3rem;">{url}</pre>
<div>
<button onclick="copyText(this, '#url')" data-tooltip="Click to copy">Copy content</button>
<button onclick="copyText(this, '#url')" data-copy-label="Copy URL" data-tooltip="Click to copy">Copy URL</button>
<a href={ templ.SafeURL(url) } style="margin-left: 1rem;">View Paste</a>
</div>
</div>

View File

@@ -42,7 +42,7 @@ func PasteSuccess(url string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre><div><button onclick=\"copyText(this, &#39;#url&#39;)\" data-tooltip=\"Click to copy\">Copy content</button> <a href=\"")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre><div><button onclick=\"copyText(this, &#39;#url&#39;)\" data-copy-label=\"Copy URL\" data-tooltip=\"Click to copy\">Copy URL</button> <a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -17,7 +17,7 @@ templ copyTextScript() {
event.dataset.tooltip = 'Copied!';
event.innerText = 'Copied!';
setTimeout(function() {
event.innerText = 'Copy content';
event.innerText = event.dataset.copyLabel;
event.dataset.tooltip = 'Click to copy';
event.blur();
}, 1000);

View File

@@ -23,7 +23,7 @@ func copyTextScript() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\n function copyText(event, selector) {\n var pastedContent = document.querySelector(selector);\n\n // Create a range and select the text\n var range = document.createRange();\n range.selectNode(pastedContent);\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(range);\n\n // Copy the selected text\n if (navigator.clipboard) {\n navigator.clipboard.writeText(pastedContent.innerText).then(function() {\n event.dataset.tooltip = 'Copied!';\n event.innerText = 'Copied!';\n setTimeout(function() {\n event.innerText = 'Copy content';\n event.dataset.tooltip = 'Click to copy';\n event.blur();\n }, 1000);\n });\n }\n }\n </script>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\n function copyText(event, selector) {\n var pastedContent = document.querySelector(selector);\n\n // Create a range and select the text\n var range = document.createRange();\n range.selectNode(pastedContent);\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(range);\n\n // Copy the selected text\n if (navigator.clipboard) {\n navigator.clipboard.writeText(pastedContent.innerText).then(function() {\n event.dataset.tooltip = 'Copied!';\n event.innerText = 'Copied!';\n setTimeout(function() {\n event.innerText = event.dataset.copyLabel;\n event.dataset.tooltip = 'Click to copy';\n event.blur();\n }, 1000);\n });\n }\n }\n </script>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}