-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
101 lines (92 loc) · 3.33 KB
/
Copy pathscript.js
File metadata and controls
101 lines (92 loc) · 3.33 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const forcesID = 'https://codeforces.com/api/user.info?handles=vduttrat'
const submissions = 'https://codeforces.com/api/user.status?handle=vduttrat&from=1&count=3'
const git = 'https://api.github.com/users/vduttrat'
const d1 = document.querySelector("#github")
const d2 = document.querySelector("#forces")
const d3 = document.querySelector("#subm")
const forcesReq = new XMLHttpRequest()
forcesReq.open('GET', forcesID)
forcesReq.send()
forcesReq.onreadystatechange = function(){
if(forcesReq.readyState===4){
const data = (JSON.parse(this.responseText)).result[0]
console.log(data)
d2.innerHTML = `
<div style="text-align:center; margin: 2rem 2rem 2rem">
<heading>Codeforces Stats</heading>
</div>
<div>
<content>
<img src="${data.avatar}" alt="Codeforces user avatar"/>
<ul>
<li><span class="stathead">Handle</span>: ${data.handle}</li>
<li><span class="stathead">Organization</span>: ${data.organization}</li>
<li><span class="stathead">Rating</span>: ${data.rating}</li>
<li>Friend of <span class="stathead">${data.friendOfCount}</span> users</li>
</ul>
</content>
</div>
`
}
}
const gitReq = new XMLHttpRequest()
gitReq.open('GET', git)
gitReq.send()
gitReq.onreadystatechange = function(){
if(gitReq.readyState===4){
const data = JSON.parse(this.responseText)
console.log(data)
d1.innerHTML = `
<div style="text-align:center; margin: 2rem 2rem 2rem">
<heading>Github Stats</heading>
</div>
<div>
<content>
<img src="${data.avatar_url}" alt="Github user avatar"/>
<ul>
<li><span class="stathead">Username</span>: ${data.login}</li>
<li><span class="stathead">Repositories</span>: ${data.public_repos}</li>
</ul>
</content>
</div>
`
}
}
const subReq = new XMLHttpRequest()
subReq.open('GET', submissions)
subReq.send()
subReq.onreadystatechange = function(){
if(subReq.readyState===4){
const data = (JSON.parse(this.responseText)).result
console.log(data)
d3.innerHTML = `
<div style="text-align:center; margin: 2rem 2rem 0.5rem">
<heading>Latest submissions [CF]</heading>
</div>
<div>
<content>
<ul>
<li>${data[0].problem.contestId} ${data[0].problem.index}. ${data[0].problem.name}<br> Verdict: ${data[0].verdict==="OK" ? "AC" : "WA"}</li><br>
<li>${data[1].problem.contestId} ${data[1].problem.index}. ${data[1].problem.name}<br> Verdict: ${data[1].verdict==="OK" ? "AC" : "WA"}</li><br>
<li>${data[2].problem.contestId} ${data[2].problem.index}. ${data[2].problem.name}<br> Verdict: ${data[2].verdict==="OK" ? "AC" : "WA"}</li><br>
</ul>
</content>
</div>
`
}
}
const button1 = document.querySelectorAll('.gotoAbout')
const hero = document.querySelector('.page2')
const button2 = document.querySelectorAll('.gotoIntro')
const arr = Array.from(button1);
const arr2 = Array.from(button2);
arr.forEach((val)=>{
val.addEventListener('click', ()=>{
hero.className = "page2 second"
})
})
arr2.forEach((val)=>{
val.addEventListener('click',()=>{
hero.className = "page2 first"
})
})