summaryrefslogtreecommitdiff
path: root/static/submission.js
diff options
context:
space:
mode:
authorDaniel Hader <[email protected]>2026-06-04 18:29:34 -0500
committerDaniel Hader <[email protected]>2026-06-04 18:29:34 -0500
commit3ac68b8b59f150e08731a62026ce3ac825655614 (patch)
treeb493b1668721caf705aaeb7f700b14e21933ae25 /static/submission.js
parent9122911ca8a8be68d30194a3765a2d4cddaff1a1 (diff)
viewing submissions logic
Diffstat (limited to 'static/submission.js')
-rw-r--r--static/submission.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/static/submission.js b/static/submission.js
new file mode 100644
index 0000000..bbe4075
--- /dev/null
+++ b/static/submission.js
@@ -0,0 +1,35 @@
+async function get_problem() {
+ const url_params = new URLSearchParams(window.location.search);
+ const problem_id = parseInt(url_params.get("problem_id"));
+ const response = await fetch(`/problem/${problem_id}`)
+ return await response.json();
+}
+
+async function get_submission() {
+ const url_params = new URLSearchParams(window.location.search);
+ const submission_id = parseInt(url_params.get("submission_id"));
+ const response = await fetch(`/submission/${submission_id}`)
+ return await response.json();
+}
+
+async function init() {
+ const problem = await get_problem();
+ const submission = await get_submission();
+
+ const problem_div = document.getElementById("submission-problem");
+
+ const title = document.createElement("h2");
+ title.innerHTML = `Problem: ${problem.title}`;
+ problem_div.appendChild(title);
+
+ const description = document.createElement("p");
+ description.innerHTML = problem.description;
+ problem_div.appendChild(description);
+
+ document.getElementById("submission-author").innerHTML = `by ${submission.username}`;
+ document.getElementById("submission-size").innerHTML = `${new Blob([submission.code]).size} bytes`;
+ document.getElementById("submission-details").innerHTML = submission.details;
+ document.getElementById("submission-code").innerHTML = submission.code;
+
+ hljs.highlightAll();
+}