-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (53 loc) · 1.91 KB
/
script.js
File metadata and controls
65 lines (53 loc) · 1.91 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
const announcements = document.getElementById("ann-box")
const comic_card = document.getElementById("comic")
document.onreadystatechange = function() {
if (document.readyState !== "complete") {
document.querySelector(
"body").style.visibility = "hidden";
document.querySelector(
"#loader").style.visibility = "visible";
} else {
document.querySelector(
"#loader").style.display = "none";
document.querySelector(
"body").style.visibility = "visible";
}
};
async function getData() {
const url = "https://softcom-api-h7ra.onrender.com/announcements"
// const url = "http://localhost:5000/announcements"
const data = await fetch(url)
let response = await data.json()
return response
}
getData().then((res)=>{
for(var i = 1;i<res.length;i++){
pre = "0"
if(i>9){
pre = ""
}
gap=" "
opp = res.length-i
let announcement = document.createElement("div")
announcement.classList.add("ann-card")
announcement.innerHTML = `<div class="ann-heading">
<span id="number">${pre+i+gap}</span>
<b>${res[opp][0]}</b>
</div>
${res[opp][1]}
<p id="evt-location">Date : ${res[opp][2]} Venue : ${res[opp][3]}</p>`
announcements.appendChild(announcement)
}
})
async function getComic(){
// const url = "http://localhost:5000/comic"
const url = "https://softcom-api-h7ra.onrender.com/comic"
const response = await fetch(url)
const img_url = await response.json()
return img_url
}
getComic().then((res)=>{
let comic = document.createElement("div")
comic.classList.add("comic")
comic.innerHTML = `<img src=${res} alt="sorry could not find it ;C" id="comic_card">`
comic_card.appendChild(comic)})