blob: 4fbcf23c1207f8a3985f2371a8f1921795e3bc90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 = `${submission.code_length} bytes`;
document.getElementById("submission-details").innerHTML = submission.details;
document.getElementById("submission-code").innerHTML = submission.code;
hljs.highlightAll();
}
|