-
Notifications
You must be signed in to change notification settings - Fork 0
/
s.js
60 lines (48 loc) · 1.94 KB
/
s.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
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
//It uses the fetchStudents function to fetch the data from the google sheet and then displays it on the page. It also adds a class of student to the div element.
const loader = document.querySelector("#loading");
function displayLoading() {
loader.classList.add("display");
// to stop loading after some time
setTimeout(() => {
loader.classList.remove("display");
}, 5000);
}
function hideLoading() {
loader.classList.remove("display");
}
displayLoading();
const fetchStudents = async () => {
fetch('https://script.google.com/macros/s/AKfycbyGrtQOUbZJpfJYws3G40Awek7Kz-OZ7ahLM2VioTJ5aaoHmvKL8E9X0-0Ng4-QGgPQ/exec')
.then(response => response.json())
.then(characters => showCharacters(characters.data));
showCharacters = characters => {
characters.forEach(student => {
if(student.Name!="Name"){
const StudentDiv = document.createElement('div');
StudentDiv.classList.add('student');
if(student.USN=="4MT19CS174"){
const StudentInnerHTML = `
<div class="info" onclick="window.location.href = 'https://github.com/Varshithvhegde';">
<span class="number">${student.USN}</span>
<h3 class="name" style="color:red;">${student.Name}</h3>
</div>
`;
StudentDiv.innerHTML = StudentDiv.innerHTML + StudentInnerHTML;
student_container.appendChild(StudentDiv);
}
else{
const StudentInnerHTML = `
<div class="info">
<span class="number">${student.USN}</span>
<h3 class="name">${student.Name}</h3>
</div>
`;
StudentDiv.innerHTML = StudentDiv.innerHTML + StudentInnerHTML;
student_container.appendChild(StudentDiv);
}
}
});
hideLoading();
}
}
fetchStudents();