diff options
| author | Daniel Hader <[email protected]> | 2026-06-02 20:16:04 -0500 |
|---|---|---|
| committer | Daniel Hader <[email protected]> | 2026-06-02 20:16:04 -0500 |
| commit | 14a4d586b7c7abc86674724153757f15faf7262c (patch) | |
| tree | cc7f1743964d7a32f5299cee239d8126b59544e1 /static | |
| parent | fc82931fab3ee1203ebb894840f9eede0dee2a08 (diff) | |
submission logic progress and submission page redirects
Diffstat (limited to 'static')
| -rw-r--r-- | static/main.js | 2 | ||||
| -rw-r--r-- | static/submit.html | 2 | ||||
| -rw-r--r-- | static/submit.js | 28 |
3 files changed, 24 insertions, 8 deletions
diff --git a/static/main.js b/static/main.js index ae997f3..73a4c60 100644 --- a/static/main.js +++ b/static/main.js @@ -37,7 +37,7 @@ function create_problem_element(problem, submissions) { problem_div.appendChild(sub_title); const submission_link = document.createElement("a"); - submission_link.href = "submit.html?problem=10"; + submission_link.href = `submit.html?problem_id=${problem.id}`; submission_link.innerHTML = "submit solution" problem_div.appendChild(submission_link); diff --git a/static/submit.html b/static/submit.html index 79c4f82..393b2e2 100644 --- a/static/submit.html +++ b/static/submit.html @@ -43,7 +43,7 @@ <label for="submission-code">Code</label><br> <textarea id="submission-code" rows="16" cols="87"></textarea> <br><br> - <button id="submission-button">Submit</button> + <button id="submission-button" onclick="submit()">Submit</button> <br><br> </div> diff --git a/static/submit.js b/static/submit.js index 81e3aa6..03dfd69 100644 --- a/static/submit.js +++ b/static/submit.js @@ -1,12 +1,28 @@ -function submit() { +async function submit() { + const language = document.getElementById("submission-language").value; + const details = document.getElementById("submission-details").value; + const code = document.getElementById("submission-code").value; + const submission = { - user_id: 1, - problem_id: 2, - language: "c++", - details: "blah blah", - code: "blah blah", + problem_id: 2, // TODO validate language and problem id in server + language: language, + details: details, + code: code, }; + + const response = await fetch("/submission", { + method: "post", + headers: { "Content-Type": "application/json" }, + credentials: "include", + body: JSON.stringify(submission) + }); + + console.log(response); + + const result = await response.json(); + + console.log(result); } function init() { |
