From b4d1dc95acc53e0f44a106ec2064287274489721 Mon Sep 17 00:00:00 2001 From: joaovictor3g Date: Thu, 18 Apr 2024 17:08:19 -0300 Subject: [PATCH] fixes share button --- web/assets/js/main.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/web/assets/js/main.js b/web/assets/js/main.js index 99c8d55..257878a 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -73,7 +73,10 @@ function run() { function share() { const values = getRunValues(); - const str = JSON.stringify(values); + const str = JSON.stringify({ + ...values, + mode: localStorage.getItem(localStorageModeKey) ?? "cel", + }); var compressed_uint8array = pako.gzip(str); var b64encoded_string = btoa( String.fromCharCode.apply(null, compressed_uint8array) @@ -104,8 +107,14 @@ if (urlParams.has("content")) { throw new Error("Invalid content parameter"); } const obj = JSON.parse(decompressedData); - celEditor.setValue(obj.expression, -1); - dataEditor.setValue(obj.data, -1); + localStorage.setItem(localStorageModeKey, obj.mode); + new AceEditor(obj.mode).setValue(obj.expression, -1); + document + .querySelectorAll(".editor__input.data__input") + .forEach((editor) => { + const containerId = editor.id; + new AceEditor(containerId).setValue(obj[containerId], -1); + }); } catch (error) { console.error(error); }