fix: use execCommand clipboard fallback for Android/HTTP

This commit is contained in:
williams
2026-06-12 16:58:33 +02:00
parent 66571ba49e
commit 90cc6764dc
+3 -1
View File
@@ -269,6 +269,8 @@ UI_HTML = r"""<!DOCTYPE html>
.toolbar a:hover:not(.active) { background: #555; }
}
</style>
<script>function copyText(t){var ta=document.createElement("textarea");ta.value=t;ta.style.position="fixed";ta.style.opacity="0";document.body.appendChild(ta);ta.select();try{document.execCommand("copy")}catch(e){prompt("Copy:",t)}document.body.removeChild(ta)}
</script>
</head>
<body>
<h1>nash memory <span class="count">$COUNT entries</span></h1>
@@ -309,7 +311,7 @@ def ui_index():
short_id = e["id"][:8]
card = (
f'<div class="entry-header"><span class="entry-id">{_html.escape(short_id)}</span>'
'<button class="copy-btn" type="button" onclick="navigator.clipboard.writeText(\'{_html.escape(e["id"])}\')">copy id</button>'
'<button class="copy-btn" type="button" onclick="return copyText(\'{_html.escape(e["id"])}\')">copy id</button>'
f'<form method="post" action="/-/delete/{_html.escape(e["id"])}" style="margin:0" onsubmit="return confirm(\'Delete this entry?\')">'
'<button class="del-btn" type="submit">delete</button></form></div>'
f'<div class="entry-text">{rendered}</div>'