-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (35 loc) · 1.25 KB
/
index.js
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
function getSubmissions(){
var username=document.getElementById("username").value;
var request=new XMLHttpRequest();
var requestURL="https://kenkoooo.com/atcoder/atcoder-api/results?user="+username;
request.open('GET',requestURL);
request.responseType='json';
request.send();
var form=document.getElementsByClassName("form")[0];
if(form.nextElementSibling){
form.nextElementSibling.parentNode.removeChild(form.nextElementSibling);
}
var loadingElement=document.createElement("div");
loadingElement.className="display";
form.parentNode.insertBefore(loadingElement,form.nextSibling);
form=form.nextElementSibling;
form.innerHTML="Loading...";
request.onload=(function(){
var cnt=0;
for(var submission of request.response){
cnt+=submission["length"];
}
var form=document.getElementsByClassName("form")[0];
if(form.nextElementSibling){
form.nextElementSibling.parentNode.removeChild(form.nextElementSibling);
}
form.insertAdjacentHTML("afterend",`
<div class="display">
`+username+`
has submitted
`+cnt+`
byte of codes to AtCoder!
</div>
`);
});
}