aboutsummaryrefslogtreecommitdiffstats
path: root/claude-julia/client.ts
diff options
context:
space:
mode:
authorScott Lawrence <scott+git@ineffectivetheory.com>2025-03-19 21:23:32 -0600
committerScott Lawrence <scott+git@ineffectivetheory.com>2025-03-19 21:23:32 -0600
commitbab7929215b3d5a1d66b43ee5b03ad767aa32374 (patch)
tree0d945d2ffb6ed49ad8e6992d6ea8a0402bb47782 /claude-julia/client.ts
downloadmini-bab7929215b3d5a1d66b43ee5b03ad767aa32374.tar.gz
mini-bab7929215b3d5a1d66b43ee5b03ad767aa32374.tar.bz2
mini-bab7929215b3d5a1d66b43ee5b03ad767aa32374.zip
Initial commit
Diffstat (limited to 'claude-julia/client.ts')
-rw-r--r--claude-julia/client.ts28
1 files changed, 28 insertions, 0 deletions
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 += '<div class="code"><pre class="orig">'+orig_code+'</pre>';
+ html += '<pre class="impr">'+impr_code+'</pre></div>';
+ html += '<div class="expl">'+expl+'</div><hr/>';
+ }
+
+ el_response.innerHTML = html;
+}