L-Program and Godel Numbers #3
@ -54,7 +54,8 @@
|
|||||||
Y <- Y + 1
|
Y <- Y + 1
|
||||||
GOTO C1</textarea>
|
GOTO C1</textarea>
|
||||||
<div>
|
<div>
|
||||||
<button id="compile">Compile</button>
|
<button id="compile">Compile</button> <button id=
|
||||||
|
"copy">Copy</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span style="margin-left: 0.5rem" id=
|
<span style="margin-left: 0.5rem" id=
|
||||||
|
@ -77,6 +77,18 @@ const compiledEditorEl = CodeMirror.fromTextArea(compiledEl, codeMirrorConfig);
|
|||||||
const godelSequenceEl = document.getElementById("godel_sequence");
|
const godelSequenceEl = document.getElementById("godel_sequence");
|
||||||
const godelNumberEl = document.getElementById("godel_number");
|
const godelNumberEl = document.getElementById("godel_number");
|
||||||
const godelNumberComputeBtn = document.getElementById("godel_number_comp");
|
const godelNumberComputeBtn = document.getElementById("godel_number_comp");
|
||||||
|
const copyStateButton = document.getElementById("copy");
|
||||||
|
|
||||||
|
// hackily copy the program state and put it in the clipboard
|
||||||
|
copyStateButton.addEventListener("click", () => {
|
||||||
|
const instructions = btoa(instructionsEditorEl.getValue());
|
||||||
|
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(
|
||||||
|
window.location.href.split("?")[0] + `?instructions=${instructions}`
|
||||||
|
)
|
||||||
|
.then(() => alert("copied to clipboard"));
|
||||||
|
});
|
||||||
|
|
||||||
state.subscribe((msg) => {
|
state.subscribe((msg) => {
|
||||||
if (msg.type == MESSAGES.COMPILE_RESULT) {
|
if (msg.type == MESSAGES.COMPILE_RESULT) {
|
||||||
@ -146,7 +158,7 @@ state.subscribe((msg) => {
|
|||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
if (urlParams.get("instructions")) {
|
if (urlParams.get("instructions")) {
|
||||||
editorEl.setValue(atob(urlParams.get("instructions")));
|
instructionsEditorEl.setValue(atob(urlParams.get("instructions")));
|
||||||
}
|
}
|
||||||
|
|
||||||
compileButton.addEventListener("click", () => {
|
compileButton.addEventListener("click", () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user