From 57a4d439847bf3d63513b2443dfdf1eca5ecbb02 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 17 Nov 2023 12:12:57 -0700 Subject: [PATCH] add copy state button --- godel/index.html | 3 ++- godel/js/main.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/godel/index.html b/godel/index.html index f8e8dad..f74a48e 100644 --- a/godel/index.html +++ b/godel/index.html @@ -54,7 +54,8 @@ Y <- Y + 1 GOTO C1
- +
{ + const instructions = btoa(instructionsEditorEl.getValue()); + + navigator.clipboard + .writeText( + window.location.href.split("?")[0] + `?instructions=${instructions}` + ) + .then(() => alert("copied to clipboard")); +}); state.subscribe((msg) => { if (msg.type == MESSAGES.COMPILE_RESULT) { @@ -146,7 +158,7 @@ state.subscribe((msg) => { const urlParams = new URLSearchParams(window.location.search); if (urlParams.get("instructions")) { - editorEl.setValue(atob(urlParams.get("instructions"))); + instructionsEditorEl.setValue(atob(urlParams.get("instructions"))); } compileButton.addEventListener("click", () => {