-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
51 lines (47 loc) · 1.44 KB
/
main.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
const hour = new Date().getHours();
const x = 13;
let greeting;
if (0 < hour && hour < 12) {
greeting = "Good Morning";
} else if (12 <= hour && hour <= 17) {
greeting = "Good Afternooon!";
} else {
greeting = "Good Evening!";
}
document.getElementById("greeting").innerHTML = greeting;
/*
const alert_div = document.createElement("div");
alert_div.setAttribute("class", "alert");
const alert_container = document.getElementById("alerts");
alert_container.appendChild(alert_div);
*/
async function getData() {
const url = "http://localhost:1337/data.json";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
console.log(json);
} catch (error) {
console.error(error.message);
}
}
/*
async function getXArtical(x) {
const url = "http://localhost:1337/data.json";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
const parsed = JSON.parse(json)
return parsed[x];
} catch (error) {
console.error(error.message);
}
}
*/
document.getElementById("alert_description").innerHTML = "THE AWESOME DESCRIPTIVE TEXT THAT NEEDS TO BE LONG ENOUGH TO WRAP AND IS ALSO UPDATED FROM JS";