diff --git a/dashboard/src/lib/list/CardsList.svelte b/dashboard/src/lib/list/CardsList.svelte index 58b5464f..4b51732f 100644 --- a/dashboard/src/lib/list/CardsList.svelte +++ b/dashboard/src/lib/list/CardsList.svelte @@ -67,6 +67,38 @@ cardIndexArray[index].classList.remove("collapsed"); } } + + function getShortLink(id: string) { + let url = "https://pk.mt" + + if (itemType === "member") url += "/m/" + else if (itemType === "group") url += "/g/" + + url += id; + + return url; + } + + let copiedArray = []; + + async function copyShortLink(index: number, id: string, event?) { + if (event) { + if (event.key !== "Tab") event.preventDefault(); + event.stopPropagation(); + + let ctrlDown = event.ctrlKey||event.metaKey; // mac support + if (!(ctrlDown && event.key === "c") && event.key !== "Enter") return; + } + try { + await navigator.clipboard.writeText(getShortLink(id)); + + copiedArray[index] = true; + await new Promise(resolve => setTimeout(resolve, 2000)); + copiedArray[index] = false; + } catch (error) { + console.log(error); + } + } {#if settings && settings.accessibility ? (!settings.accessibility.expandedcards && !settings.accessibility.pagelinks) : true} @@ -76,7 +108,7 @@