#243: copy button should copy the link #244

Merged
fen merged 1 commits from fix-243 into dev 2026-09-16 20:44:56 +00:00
2 changed files with 20 additions and 10 deletions
+16 -7
View File
@@ -16,17 +16,24 @@ function toggleStats() {
pill.classList.toggle('open', open);
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
}
function copyContent(btn) {
navigator.clipboard.writeText(document.getElementById('raw-content').value);
// in-place success feedback (#53)
if (btn) {
function copyFeedback(btn) {
if (!btn) return;
btn.classList.add('ok');
btn.textContent = 'Success!';
clearTimeout(btn._okh);
btn._okh = setTimeout(() => { btn.classList.remove('ok'); btn.textContent = 'copy'; }, 2000);
} else {
toast('Link Copied', 'success');
}
}
function copyContent(btn) {
navigator.clipboard.writeText(document.getElementById('raw-content').value)
.then(() => copyFeedback(btn))
.catch(() => toast('Copy failed'));
}
// #243: copy the paste LINK (full URL), not the paste id or content
function copyLink(btn) {
const url = location.origin + location.pathname;
navigator.clipboard.writeText(url)
.then(() => copyFeedback(btn))
.catch(() => toast('Copy failed'));
}
function redeem() {
if (!confirm('Hard delete this paste immediately?')) return;
@@ -41,6 +48,8 @@ function redeem() {
var PASTE_ID = document.currentScript.getAttribute('data-paste-id');
var copyBtn = document.getElementById('copy-btn');
if (copyBtn) copyBtn.addEventListener('click', function (e) { e.preventDefault(); copyContent(copyBtn); });
var copyLinkBtn = document.getElementById('copy-link-btn');
if (copyLinkBtn) copyLinkBtn.addEventListener('click', function (e) { e.preventDefault(); copyLink(copyLinkBtn); });
var delBtn = document.getElementById('delete-btn');
// #168: show the compact paste-created pill in the bottom corner, then fade it out
+1
View File
@@ -8,6 +8,7 @@
<div class="spacer"></div>
<button type="button" class="iconbtn wrap-toggle" title="Toggle line wrap" aria-pressed="false">wrap</button>
<a class="iconbtn" href="/raw/{{.ID}}">raw</a>
<a class="iconbtn" href="#" id="copy-link-btn">link</a>
<a class="iconbtn" href="#" id="copy-btn">copy</a>
{{if .DeletionToken}}<a class="iconbtn danger" href="#" id="delete-btn">delete</a>{{end}}
</div>