Update web/templates/entry_view.html
This commit is contained in:
parent
1777fbc704
commit
5caa0646c3
@ -40,6 +40,7 @@
|
||||
</button>
|
||||
|
||||
{% if user.is_authenticated and user.is_staff %}
|
||||
<!-- Just the label changed to 'Edit'; link unchanged -->
|
||||
<a class="btn btn-outline" href="{% url 'entry_edit' entry.id %}">Edit</a>
|
||||
<a class="btn btn-danger" href="{% url 'entry_delete' entry.id %}">Delete</a>
|
||||
{% endif %}
|
||||
@ -174,20 +175,49 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Copy Illustration + two spaces + Application
|
||||
// Robust copy to clipboard that works on HTTP and HTTPS
|
||||
(function () {
|
||||
const btn = document.getElementById('share-btn');
|
||||
if (!btn) return;
|
||||
btn.addEventListener('click', function () {
|
||||
const ill = (document.getElementById('illustration-text')?.innerText || '').trim();
|
||||
const app = (document.getElementById('application-text')?.innerText || '').trim();
|
||||
const text = ill + ' ' + app; // two spaces between
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
const toast = document.getElementById('copy-toast');
|
||||
function copyText(text) {
|
||||
// Try modern API first
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
return navigator.clipboard.writeText(text);
|
||||
}
|
||||
// Fallback: temporary textarea
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
// Avoid scrolling to bottom
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.top = '-1000px';
|
||||
ta.style.left = '-1000px';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
var ok = document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
ok ? resolve() : reject(new Error('execCommand failed'));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showToast() {
|
||||
var toast = document.getElementById('copy-toast');
|
||||
if (!toast) return;
|
||||
toast.style.display = 'block';
|
||||
setTimeout(() => { toast.style.display = 'none'; }, 5000);
|
||||
}).catch(err => {
|
||||
clearTimeout(showToast._t);
|
||||
showToast._t = setTimeout(function(){ toast.style.display = 'none'; }, 5000);
|
||||
}
|
||||
|
||||
var btn = document.getElementById('share-btn');
|
||||
if (!btn) return;
|
||||
btn.addEventListener('click', function () {
|
||||
var ill = (document.getElementById('illustration-text')?.innerText || '').trim();
|
||||
var app = (document.getElementById('application-text')?.innerText || '').trim();
|
||||
var text = ill + ' ' + app; // two spaces
|
||||
copyText(text).then(showToast).catch(function (err) {
|
||||
alert('Failed to copy: ' + err);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user