From bab7929215b3d5a1d66b43ee5b03ad767aa32374 Mon Sep 17 00:00:00 2001 From: Scott Lawrence Date: Wed, 19 Mar 2025 21:23:32 -0600 Subject: Initial commit --- claude-julia/client.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 claude-julia/client.ts (limited to 'claude-julia/client.ts') diff --git a/claude-julia/client.ts b/claude-julia/client.ts new file mode 100644 index 0000000..200a8e6 --- /dev/null +++ b/claude-julia/client.ts @@ -0,0 +1,28 @@ +const textDecoder = new TextDecoder(); + +async function request() { + let el_response = document.getElementById("response")!; + el_response.innerHTML = "Thinking..."; + + let code: string = (document.getElementById("code") as HTMLTextAreaElement).value + let req = { + method: 'POST', + body: code + }; + let res = await window.fetch("/query", req); + let body: string = textDecoder.decode(await res.bytes()); + + const parser = new DOMParser(); + const doc = parser.parseFromString(body, "text/html"); + let html = ''; + for (let imp of doc.querySelectorAll('improvement')) { + let orig_code = imp.querySelector('original_code')!.innerHTML; + let impr_code = imp.querySelector('improved_code')!.innerHTML; + let expl = imp.querySelector('explanation')!.innerHTML; + html += '
'+orig_code+'
'; + html += '
'+impr_code+'
'; + html += '
'+expl+'

'; + } + + el_response.innerHTML = html; +} -- cgit v1.2.3-54-g00ecf