This repository was archived by the owner on May 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbus_timings.html
More file actions
391 lines (322 loc) · 12.8 KB
/
bus_timings.html
File metadata and controls
391 lines (322 loc) · 12.8 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="">
<title>Destination - Bus Timings</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS -->
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Lemonada&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="animate.css">
<link rel="stylesheet" type="text/css" href="hover.css">
<link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<!-- JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<!-- Map JS -->
<script type="text/javascript" src="https://gothere.sg/jsapi?sensor=false"> </script>
<script type="text/javascript" src="mapScript.js"> </script>
<style type="text/css">
body, p, h1, h2, h3, h4, h5 ,button, input, a, label, select, .but{
font-family: 'Lemonada', cursive;
}
#_gdir{font-size:14px;}
#_gdir > div{font-weight:bold;text-align:center;}
#_gdir p._sum{text-align:center;font-weight:bold;color:#3a741f;}
#_gdir ol{padding:10px 30px 10px 40px;}
#_gdir ol li{border-bottom:1px solid #ccc;}
#_gdir ol li div p.r{font-size:11px;color:#3a741f;text-align:right;}
#_gdir div._copy{font-size:12px;font-weight:normal;}
.banner {display:none}
.w3-left, .w3-right, .w3-badge {cursor:pointer}
.w3-badge {height:13px;width:13px;padding:0}
.head {
max-width: 100%;
max-height: 100%;
margin: auto;
display: block;
height: auto;
}
.shadowfilter {
-webkit-filter: drop-shadow(0px 0px 8px rgba(194, 249, 255, 0.8));
-webkit-transition: all 0.5s linear;
-o-transition: all 0.5s linear;
transition: all 0.5s linear;
}
.shadowfilter:hover {
-webkit-filter: drop-shadow(0px 0px 12px rgba(0, 231, 255, 0.8));
}
.bgshadow{
-webkit-filter: drop-shadow(0px 12px 0px rgba(65, 65, 65, 0.8));
}
.nav-link{
border-color: rgb(81, 148, 175)!important;
border-width: 5px!important;
border-left-style: solid;
margin: 20px!important;
color: rgb(241, 243, 243)!important;
}
.nav-link:hover{
border-color: rgb(196, 230, 243)!important;
color: rgb(188, 223, 214)!important;
}
.nav-link:active{
border-color: rgb(237, 255, 137)!important;
color: rgb(209, 223, 228)!important;
}
.active{
border-color: rgb(237, 255, 137)!important;
color: rgb(239, 252, 191)!important;
}
.arr{
color: rgb(225, 239, 245);
font-size: 20px;
border-style: solid;
border-color: transparent;
border-width: 30px;
border-radius: 20px;
}
.arr:hover{
color: skyblue;
font-size: 20px;
border-style: solid;
border-color: transparent;
border-width: 30px;
border-radius: 20px;
background-color: rgba(70, 131, 180, 0.301);
}
.toSection{
color: rgb(72, 109, 131);
font-size: 20px;
border-style: solid;
border-color: transparent;
border-width: 20px;
border-radius: 20px;
}
.toSection:hover{
color: rgb(239, 250, 255);
font-size: 20px;
border-style: solid;
border-color: transparent;
border-width: 20px;
border-radius: 20px;
background-color: rgba(104, 159, 204, 0.301);
}
.text-focus-in {
-webkit-animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
}
.card-body{
color: rgb(227, 236, 243);
background-color: rgba(57, 97, 116, 0.349);
}
.card-body h4 ,.card-body p{
padding: 30px;
text-align: center;
vertical-align: middle;
}
a:hover{
text-decoration: none;
}
.but {
box-shadow:inset 0px 1px 0px 0px #ffffff;
background:linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%);
background-color:#f9f9f9;
border-radius:6px;
border:1px solid #dcdcdc;
display:inline-block;
cursor:pointer;
color:#666666;
font-family:Arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #ffffff;
}
.but:hover {
background:linear-gradient(to bottom, #e9e9e9 5%, #f9f9f9 100%);
background-color:#e9e9e9;
}
.but:active {
position:relative;
top:1px;
}
.text-flicker-in-glow {
-webkit-animation: text-flicker-in-glow 4s linear both;
animation: text-flicker-in-glow 4s linear both;
}
</style>
</head>
<body style="background-color: rgb(125, 171, 255);background-image: url(images/map.gif) ;background-position: center; background-size: cover;">
<header style="width:100%;">
<nav class="nav navbar navbar-expand-md navbar-dark" style="background-color: rgba(14, 37, 46, 0.418)!important; height: 60px; z-index: 30;">
<a class="nav-pop navbar-brand" style="color: white; font-size: x-large; padding: 0 30px 0 10px; width: 200px;" href="index.html"><img src="images/destination-logo.png" style="width: 10%;">Destination</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item" style="background-color: rgba(14, 37, 46, 0.24)!important;">
<a class="nav-link active text-flicker-in-glow" href="bus_timings.html">Bus is coming!<span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
</header>
<section class="container-fluid" style="width: 100%;background-color: rgba(146, 192, 223, 0.267); padding: 20px;">
<table id="trainState" class="container" style="color: #ffffff;"></table>
<hr>
<div class="container-fluid">
<form class="container" onsubmit="busSearch()">
<input type="text" class="form-control" name="" id="buscode" aria-describedby="helpId" placeholder="Bus Stop Code eg. 22591">
<hr>
<button id="submit" class="but" onclick="busSearch()" class="btn btn-primary">Submit</button>
<button class="but" onclick="clearLS()">Clear</button>
</form>
<hr>
<table id="busNo" class="container" style="padding: 100px; background-color: rgba(27, 27, 27, 0.26);text-align: center;color: rgb(250, 250, 250) ;width:30%;"></table>
</div>
</section>
<script>
//Clear Local Storage
function clearLS(){
localStorage.clear();
history.go(0);
}
//Bus Arrival Searches
function busSearch(){
//@paramssettings
event.preventDefault();
var params = {
// //YYYY-MM-DD[T]HH:mm:ss(SGT)
"BusStopCode": "",
};
//API Call
$.ajax({
type: "GET",
crossDomain: true,
dataType: 'json',
contentType: "text/plain",
url: "https://cors-anywhere.herokuapp.com/http://datamall2.mytransport.sg/ltaodataservice/BusArrivalv2?",
headers: { 'AccountKey' : 'jYPJun3ORe2iZ18XLuN2zw==',
'accept' : 'application/json'},
data: { "BusStopCode": document.getElementById("buscode").value},
// crossDomain: true,
//@data returning JSON data
success: function(data) {
var busNo = [];
for (var i=0; i < data.Services.length; i++){
busNo = data.Services[i].ServiceNo;
busNext = data.Services[i].NextBus.EstimatedArrival;
busNextNext = data.Services[i].NextBus2.EstimatedArrival;
busNextNextNext = data.Services[i].NextBus3.EstimatedArrival;
busNextOccp = data.Services[i].NextBus.Load;
busNextNextOccp = data.Services[i].NextBus2.Load;
busNextNextNextOccp = data.Services[i].NextBus3.Load;
busNextFeat = data.Services[i].NextBus.Feature;
busNextNextFeat = data.Services[i].NextBus2.Feature;
busNextNextNextFeat = data.Services[i].NextBus3.Feature;
busNextType = data.Services[i].NextBus.Type;
busNextNextType = data.Services[i].NextBus2.Type;
busNextNextNextType = data.Services[i].NextBus3.Type;
//Convert to Time
function addZero(x, n) {
while (x.toString().length < n) {
x = "0" + x;
}
return x;
}
var busN = new Date(busNext);
var hDN = addZero(busN.getHours(), 2);
var mDN = addZero(busN.getMinutes(), 2);
var sDN = addZero(busN.getSeconds(), 2);
busNext = hDN + ":" + mDN + ":" + sDN;
var busNN = new Date(busNextNext);
var hDNN = addZero(busNN.getHours(), 2);
var mDNN = addZero(busNN.getMinutes(), 2);
var sDNN = addZero(busNN.getSeconds(), 2);
busNextNext = hDNN + ":" + mDNN + ":" + sDNN;
var busNNN = new Date(busNextNextNext);
var hDNNN = addZero(busNNN.getHours(), 2);
var mDNNN = addZero(busNNN.getMinutes(), 2);
var sDNNN = addZero(busNNN.getSeconds(), 2);
busNextNextNext = hDNNN + ":" + mDNNN + ":" + sDNNN;
// Printing Format
var eachNo = "<tr>" + "<th>" + "Bus No: " + busNo + "</th>" + "</tr>" +
"<tr>" + "<td>" + "Next Bus: " + busNext + "</td>" + "<td>" + busNextOccp + "</td>"
+ "<td>" + busNextFeat + "</td>"
+ "<td>" + busNextType + "</td>" + "</tr>" +
"<tr>" + "<td>" + "Next Bus2: " + busNextNext + "</td>" + "<td>" + busNextNextOccp + "</td>"
+ "<td>" + busNextNextFeat + "</td>"
+ "<td>" + busNextNextType + "</td>" + "</tr>" +
"<tr>" + "<td>" + "Next Bus3: " + busNextNextNext + "</td>" + "<td>" + busNextNextNextOccp + "</td>"
+ "<td>" + busNextNextNextFeat + "</td>"
+ "<td>" + busNextNextNextType + "</td>" + "</tr>"
//Prints out
document.getElementById("busNo").innerHTML += eachNo;
console.log("Bus No: " + busNo);
//Set to Local Storage
localStorage.setItem("buses", document.getElementById("busNo").innerHTML);
}
},
error: function(error){
console.log(error);
}
});
}
//When document is ready
$(document).ready(function(){
document.getElementById("busNo").innerHTML = localStorage.getItem("buses");;
//API Calls
$.ajax({
type: "GET",
crossDomain: true,
dataType: 'json',
contentType: "text/plain",
url: "https://cors-anywhere.herokuapp.com/http://datamall2.mytransport.sg/ltaodataservice/TrainServiceAlerts",
headers: { 'AccountKey' : 'jYPJun3ORe2iZ18XLuN2zw==',
'accept' : 'application/json'},
// crossDomain: true,
//@data returning JSON data
data: {},
success: function(data) {
console.log(data.value.Status);
var state;
var trainStatus;
//If train is avaliable
if (data.value.Status == "1"){
state = "Normal";
trainStatus = "<tr>" + "<th>" + "MRT Train Status: " + state + "</th>" + "</tr>"
document.getElementById("trainState").innerHTML += trainStatus;
}else if (data.value.Status == "2"){ //If train is not avaliable
state = "Disrupted";
//Prinint Format
trainStatus = "<tr>" + "<th>" + "MRT Train Status: " + state + "</th>" + "</tr>" +
"<tr>" + "<td>" + "Affected Segments: " + data.value.Line + "</td>"
+ "<td>" + "Direction: " + data.value.Direction + "</td>"
+ "<td>" + "Stations: " + data.value.Stations + "</td>" + "</tr>"
+ "<tr>" + "<td>" + "Free Public Bus: " + data.value.FreePublicBus + "</td>"
+ "<td>" + "Free MRT Shuttle: " + data.value.FreeMRTShuttle + data.value.MRTShuttleDirection + "</td>"
+ "<td>" + "Message: " + data.value.Message + "</td>"
+ "</tr>"
// Prints
document.getElementById("trainState").innerHTML += trainStatus;
}
},
error: function(error){
console.log(error);
}
});
})
</script>
</body>
</html>