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