mirror of
https://github.com/ParkerTenBroeck/automata.git
synced 2026-06-07 05:28:45 -04:00
Merge branch 'main' into gh-pages
This commit is contained in:
commit
2f36e9f85b
1 changed files with 3 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ const btn = document.getElementById("shareBtn")!;
|
||||||
const toast = document.getElementById("shareToast")!;
|
const toast = document.getElementById("shareToast")!;
|
||||||
|
|
||||||
function generateShareLink() {
|
function generateShareLink() {
|
||||||
return `${globalThis.window.location.href}?share=${encodeURIComponent(getText())}`;
|
return `${globalThis.window.location.href}?share=${encodeURIComponent(btoa(getText()))}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copy(text: string) {
|
async function copy(text: string) {
|
||||||
|
|
@ -22,8 +22,9 @@ btn.addEventListener("click", async () => {
|
||||||
|
|
||||||
export function sharedText(): string|null {
|
export function sharedText(): string|null {
|
||||||
const url = new URL(globalThis.window.location.href);
|
const url = new URL(globalThis.window.location.href);
|
||||||
const text: string | null = url.searchParams.get("share");
|
let text: string | null = url.searchParams.get("share");
|
||||||
if (text !== null) {
|
if (text !== null) {
|
||||||
|
text = atob(text);
|
||||||
url.searchParams.delete("share");
|
url.searchParams.delete("share");
|
||||||
globalThis.window.history.replaceState(
|
globalThis.window.history.replaceState(
|
||||||
{},
|
{},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue