-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.jag
119 lines (117 loc) · 3.64 KB
/
index.jag
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
<html>
<head>
<%
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
var stationList = get("http://m.icta.lk/services/railwayservicev2/station/getAll", { lang : "en"});
stationList = JSON.parse(stationList.data);
var stations = stationList.RESULTS.stationList;
%>
<meta charset="utf-8" />
<title>Train Times Sri Lanka</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#day" ).datepicker();
});
</script>
<script type="text/javascript">
function getSchedule(){
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("results").innerHTML=xmlhttp.responseText;
}
}
var at = document.getElementById("at").value;
var go = document.getElementById("goto").value;
var from = document.getElementById("from").value;
var to = document.getElementById("to").value;
var day = document.getElementById("day").value;
xmlhttp.open("GET","getSchedule.jag?at="+at+"&go="+go+"&from="+from+"&to="+to+"&day="+day,true);
xmlhttp.send();
}
</script>
</head>
<body style="text-align:center;" background="trainbg.gif">
<h1> Welcome to Traintimes Sri Lanka </h1>
<table align="center">
<td width="210px" valign="top" align="center" style="background-color:#b0c4de;">
<div id="main" style="text-align:left;width:190px;">
<br>
<h3>Select criteria</h3>
I'm at:
<br>
<select id="at" style="width:190px;">
<% for (var i=0; i < stations.length; i++){ %>
<option value="<%=stations[i].stationID%>"><%=toTitleCase(stations[i].stationName)%></option>
<%}%>
</select>
<br><br>
I want to goto:
<br>
<select id="goto" style="width:190px;">
<% for (var i=0; i < stations.length; i++){ %>
<option value="<%=stations[i].stationID%>"><%=toTitleCase(stations[i].stationName)%></option>
<%}%>
</select>
<br><br>
<%
var dTime = new Date();
var dd = dTime.getDate();
if (dd < 10) dd = "0" + dd;
var mm = dTime.getMonth() + 1;
if (mm < 10) mm = "0" + mm;
var yy = dTime.getYear() + 1900;
var h = dTime.getHours();
var today = mm + "/" + dd + "/" + yy;
%>
From:
<select id="from">
<%
for (var i=1; i < 24; i++){
var x = i.toString();
%>
<option value="<%=x%>" <%if (x == h) print("selected");%>><%=x%>:00</option>
<%}%>
</select> HRS
<br><br>
To:
<select id="to" >
<%
for (var i=1; i < 24; i++){
var x = i.toString();
%>
<option value="<%=x%>" <%if (x == "23") print("selected");%>><%=x%>:00</option>
<%}%>
</select> HRS
<br><br>
Date:
<input type="text" id="day" style="width:150px;" value="<%=today%>">
<br>
<br>
<div style="text-align:right;">
<input type="button" id="btn" value="Find Trains" onclick="getSchedule()">
</div>
</br>
</div>
</td>
<td width = "800px" valign="center" align="center" style="background-color:#99FF66;">
<div id= "results">
Select your criteria to find train
</div>
</td>
</table>
<h4 style="text-align:center;"> charithag@wso2.com </h4>
<h5 style="text-align:center;"> 1-June-2015 </h5>
</body>
</html>