Fix
Fixed it so it says copied to clipboard when you click a image/link Signed-off-by: AvaLilac <amyshimplays@gmail.com>
This commit is contained in:
parent
58088aa094
commit
5c3b0073e2
1 changed files with 26 additions and 4 deletions
|
|
@ -165,6 +165,18 @@ function toggleFavoritesPanel() {
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fallbackCopy(text) {
|
||||||
|
const textarea = document.createElement("textarea");
|
||||||
|
textarea.value = text;
|
||||||
|
textarea.style.position = "fixed";
|
||||||
|
textarea.style.opacity = "0";
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.focus();
|
||||||
|
textarea.select();
|
||||||
|
try { document.execCommand("copy"); } catch {}
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
|
|
||||||
grid.innerHTML = "";
|
grid.innerHTML = "";
|
||||||
|
|
@ -274,9 +286,19 @@ function toggleFavoritesPanel() {
|
||||||
card.appendChild(titleOverlay);
|
card.appendChild(titleOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
card.onclick = async () => {
|
card.onclick = () => {
|
||||||
await navigator.clipboard.writeText(item.url);
|
const doToast = () => showToast(card);
|
||||||
showToast(card);
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(item.url)
|
||||||
|
.then(doToast)
|
||||||
|
.catch(() => {
|
||||||
|
fallbackCopy(item.url);
|
||||||
|
doToast();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fallbackCopy(item.url);
|
||||||
|
doToast();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
grid.appendChild(card);
|
grid.appendChild(card);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue