-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
103 lines (80 loc) · 2.96 KB
/
index.js
File metadata and controls
103 lines (80 loc) · 2.96 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
102
103
// Import stylesheets
// import './style.css';
const url = "https://m.fiu.edu/feeds//transit/v1/json.php?section=parking";
const url2 = "https://patcount.fiu.edu/garagecount.xml";
// Write Javascript code!
const appDiv = document.getElementById('app');
fetch
(url)
.then
(
function(data)
{
console.log(data);
return data.json();
}
)
.then
(
function jsonObject(json)
{
console.log(json);
for(let i = 0; i < json.length; i++)
{
if(json[i].StudentSpaces < 0)
{
json[i].StudentSpaces = 0;
}
if(json[i].OtherSpaces < 0)
{
json[i].OtherSpaces = 0;
}
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<h1>Garage : '+json[i].GarageName+'<h1>'
console.log("Garage : " + json[i].GarageName);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Student Parking Spots Taken : '+json[i].StudentSpaces+'<b>';
console.log("Student Parking Spots Taken : " + json[i].StudentSpaces);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Total Student Parking Spots : '+json[i].StudentMax+'<b>';
console.log("Total Student Parking Spots : " + json[i].StudentMax);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<h3 style="color:red"><b>Student Parking Spots left: '+(json[i].StudentMax - json[i].StudentSpaces)+'<b></h3>';
console.log("Total Student Parking Spots : " + json[i].StudentMax);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Employee Parking Spots Taken : '+json[i].OtherSpaces+'<b>';
console.log("Employee Parking Spots Taken : " + json[i].OtherSpaces);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Total Employee Parking Spots : '+json[i].OtherMax+'<b>';
console.log("Total Employee Parking Spots : " + json[i].OtherMax);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<h3 style="color:red"><b>Faculty Parking Spots left: '+(json[i].OtherMax - json[i].OtherSpaces)+'<b></h3>';
console.log("Total Student Parking Spots : " + json[i].StudentMax);
appDiv.innerHTML += "<br>";
//appDiv.innerHTML += '<b>'+json[i].asofstamp+'<b>';
//appDiv.innerHTML += "<br>";
console.log("Epoch timestamp not displayed: " + json[i].asofstamp);
appDiv.innerHTML += '<b>Checked on '+json[i].asof+'<b>';
console.log("Checked on : " + json[i].asof);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Student Parking : '+json[i].StudentFull+' Full<b>';
console.log("Student Parking % Full : " + json[i].StudentFull);
appDiv.innerHTML += "<br>";
appDiv.innerHTML += '<b>Employee Parking : '+json[i].OtherFull+' Full<b>';
console.log("Employee Parking % Full : " + json[i].OtherFull);
console.log("-----------------------------------------------------");
}
}
)
.catch
(
function()
{
// This is where you run code if the server returns any errors
console.log("ERROR!")
}
);
/*
Pg1 : -18 parking spots
Pg2 : -8
*/