-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathind.js
More file actions
37 lines (36 loc) · 945 Bytes
/
Copy pathind.js
File metadata and controls
37 lines (36 loc) · 945 Bytes
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
36
37
var hand;
var rate=0;
function submitted()
{
hand = document.getElementById("handle-name").value;
const api_url=' https://codeforces.com/api/user.rating?handle='+hand;
var ok;
async function getHandle()
{
const reponse=await fetch(api_url);
const data=await reponse.json();
ok=data.status;
if(ok==="OK")
{
var res=data.result;
var len=res.length;
if(len===0)
{
localStorage.setItem("rating", 0);
}
else
{
var res1=res[len-1];
rate=res1.newRating;
localStorage.setItem("rating", rate);
}
window.location="main.html";
}
else
{
var inv=document.getElementById("invalid");
inv.innerHTML="Invalid Codeforces Handle! Please try again."
}
}
getHandle();
}