Compare commits
2
Commits
a9f94ce806
...
3c5ccfb787
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c5ccfb787 | ||
|
|
1f745b6e59 |
@@ -16,17 +16,24 @@ function toggleStats() {
|
|||||||
pill.classList.toggle('open', open);
|
pill.classList.toggle('open', open);
|
||||||
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
|
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
|
||||||
}
|
}
|
||||||
function copyContent(btn) {
|
function copyFeedback(btn) {
|
||||||
navigator.clipboard.writeText(document.getElementById('raw-content').value);
|
if (!btn) return;
|
||||||
// in-place success feedback (#53)
|
|
||||||
if (btn) {
|
|
||||||
btn.classList.add('ok');
|
btn.classList.add('ok');
|
||||||
btn.textContent = 'Success!';
|
btn.textContent = 'Success!';
|
||||||
clearTimeout(btn._okh);
|
clearTimeout(btn._okh);
|
||||||
btn._okh = setTimeout(() => { btn.classList.remove('ok'); btn.textContent = 'copy'; }, 2000);
|
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() {
|
function redeem() {
|
||||||
if (!confirm('Hard delete this paste immediately?')) return;
|
if (!confirm('Hard delete this paste immediately?')) return;
|
||||||
@@ -41,6 +48,8 @@ function redeem() {
|
|||||||
var PASTE_ID = document.currentScript.getAttribute('data-paste-id');
|
var PASTE_ID = document.currentScript.getAttribute('data-paste-id');
|
||||||
var copyBtn = document.getElementById('copy-btn');
|
var copyBtn = document.getElementById('copy-btn');
|
||||||
if (copyBtn) copyBtn.addEventListener('click', function (e) { e.preventDefault(); copyContent(copyBtn); });
|
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');
|
var delBtn = document.getElementById('delete-btn');
|
||||||
|
|
||||||
// #168: show the compact paste-created pill in the bottom corner, then fade it out
|
// #168: show the compact paste-created pill in the bottom corner, then fade it out
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<button type="button" class="iconbtn wrap-toggle" title="Toggle line wrap" aria-pressed="false">wrap</button>
|
<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="/raw/{{.ID}}">raw</a>
|
||||||
|
<a class="iconbtn" href="#" id="copy-link-btn">link</a>
|
||||||
<a class="iconbtn" href="#" id="copy-btn">copy</a>
|
<a class="iconbtn" href="#" id="copy-btn">copy</a>
|
||||||
{{if .DeletionToken}}<a class="iconbtn danger" href="#" id="delete-btn">delete</a>{{end}}
|
{{if .DeletionToken}}<a class="iconbtn danger" href="#" id="delete-btn">delete</a>{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user