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 = `${submission.code_length} bytes`; document.getElementById("submission-details").innerHTML = submission.details; document.getElementById("submission-code").innerHTML = submission.code; hljs.highlightAll(); }