-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboardG.html
415 lines (396 loc) · 14.5 KB
/
dashboardG.html
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>RailMitra.com</title>
<link rel="stylesheet" href="css/dstyle.css">
<script src="https://www.gstatic.com/firebasejs/4.13.0/firebase.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/dindex.js"></script>
</head>
<body>
<span class="bckg"></span>
<header>
<h1>RailMitra.com</h1>
<nav>
<ul>
<li>
<a href="javascript:void(0);" onclick="myFunction('maindiv');" data-title="Overview">Overview</a>
</li>
<li>
<a onclick="myFunction('planjourney');" data-title="Plan Journey">Plan journey</a>
</li>
<li>
<a href="javascript:void(0);" onclick="logout();" data-title="Logout">Logout</a>
</li>
</ul>
</nav>
</header>
<main>
<div class="title">
<h2>Dashboard</h2>
<a href="javascript:void(0);">Hello! Guest <span id="displayUser"></span></a>
</div>
<article class="larg">
<div id="maindiv">
<h3>Daily TODO area <span class="entypo-down-open"></span></h3>
<p>Write down your plan details which you wish to complete.<br>
<textarea rows="20" cols="100" name="comment" form="usrform">
Enter text here...</textarea>
</p>
</div>
<p>
<div id="updatediv" style="display: none;">
<h3>Profile Update <span class="entypo-down-open"></span></h3>
<label for="full name">Full name:</label>
<input type="text" id="fname"><br><br>
<label for="Year">Address</label>
<input type="text" id="address"><br><br>
<label for="phone">Phone number:</label>
<input type="text" id="phone"><br><br>
<label for="class10">Aadhar Id</label>
<input type="text" id="aadhar"><br><br>
<label for="class12">Password</label>
<input type="text" id="password" placeholder="Enter the password to update details"><br><br>
<br>
<input type="button" id="updated">Update</button>
</p>
</div>
<div id="planjourney" style="display: none;">
<h3>Journey Details<span class="entypo-down-open"></span></h3>
<p><label><strong>Enter the source and destination station code:</strong></label><br><br>
<label>Source Station :</label><input type="text" name="srcstn" id="srcstn" pattern="[A-Za-z\s]+" required><br><br>
<label>Destination Station :</label><input type="text" name="desstn" id="desstn" pattern="[A-Za-z\s]+" required><br><br>
<label>Date of Journey :</label><input type="text" placeholder="DD-MM-YYYY" id="doj" maxlength="10" minlength="10" pattern="[A-Za-z\s]+" required><br><br>
<label>Class :</label>
<select id="class" name="class" style="width:200px;">
<option value="EC"> EXECUTIVE CLASS</option>
<option value="EA">EXECUTIVE ANUBHUTI</option>
<option value="1A"> FIRST AC</option>
<option value="2A"> SECOND AC</option>
<option value="3A"> THIRD AC</option>
<option value="3E">3 AC Economy</option>
<option value="CC"> AC CHAIR CAR</option>
<option value="FC"> FIRST CLASS</option>
<option selected="selected" value="SL"> SLEEPER CLASS</option>
<option value="2S"> SECOND SEATING</option>
</select> <br><br>
<label>Quota :</label>
<select id="quota" name="quota" style="width:200px;">
<option value="TQ"> Tatkal Quota</option>
<option value="LD"> Ladies Quota</option>
<option value="DF"> Defence Quota</option>
<option value="FT"> Foreign Tourist Quota</option>
<option value="SS"> Lower Berth Quota</option>
<option value="PT"> Premium Tatkal Quota</option>
<option value="YU"> Yuva Quota</option>
<option value="DP"> Duty Pass Quota</option>
<option value="HP"> Handicaped Quota</option>
<option value="PH"> Parliament House</option>
<option selected="selected" value="GN"> General Quota</option>
</select><br>
<input type="submit" name="search" id="search" value="Search trains"/>
<table id="traindetails">
<tr>
<th>Train Number</th>
<th>Train Name</th>
</tr>
</table>
<br><br><br><br>
<label>Enter the train number to check the seat availability:</label>
<input type="text" name="tno" id="tno">
<input type="submit" name="seats" id="seatsrch"><br><br>
<table id="seatdetails">
<tr>
<th>Date</th>
<th>Status</th>
</tr>
</table><br><br>
<label>Railmitra has few suggestion for the current select train: Click the button</label>
<input type="submit" value="Check" name="sug" id="sug"><br>
<label>The suggested station:</label><br>
<span class="srccc">Source: <span id="srcn"></span></span><label>Station Code: <span id="srcc"></span></label><br>
<span class="srccc">Destination: <span id="destn"></span></span><label>Station Code: <span id="destc"></span></label><br><br><br>
<label><strong>Split The Journey:</strong></label>
<br>
<label><strong>In this RailMitra will suggest you a new destination and source station, as the journey will be splitted in two.</strong></label><br>
<input type="submit" name="split" value="Split" id="split"><br>
<br>
<label>New Destination from: <strong><span id="osrc"></span></strong> will be to : <strong><span id="ndest"></span>(<span id="ndestc"></span>)</strong></label><br>
<label>Next the Source will be from : <strong><span id="nsrc"></span> (<span id="nsrcc"></span>)</strong> to the original destination : <strong><span id="odest"></span></strong></label>
<br><br><br>
</div>
</p>
</article>
</main>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCYxMazGHf5ABlNvGXF7LVBia0mKsgX51c",
authDomain: "railmitra56.firebaseapp.com",
databaseURL: "https://railmitra56.firebaseio.com",
projectId: "railmitra56",
storageBucket: "railmitra56.appspot.com",
messagingSenderId: "1056408353044"
};
firebase.initializeApp(config);
var src;
var dest;
var date;
var auth= firebase.auth();
var a;
var b;
var c;
var d;
var key="**********";
var sref= firebase.storage().ref();
function logout()
{
firebase.auth().signOut().then(function() {
window.alert("logout successfull.");
window.location = "index.html";
}, function(error) {
console.log(error);
// An error happened.
});
}
function initApp(){
var name,uid;
var user = auth.currentUser;
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log("Authenticated user with uid:", user.uid);
firebase.database().ref().child('users').orderByChild('id').equalTo(user.uid).once('value').then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key;
var childData = childSnapshot.val();
console.log(childData);
});
});
}
else {
}
});
}
$("innput").on("change", function() {
this.setAttribute(
"data-date",
moment(this.value, "YYYY-MM-DD")
.format( this.getAttribute("data-date-format") )
)
}).trigger("change")
function myFunction(elementId) {
document.getElementById('maindiv').style.display = "none";
document.getElementById('planjourney').style.display = "none";
document.getElementById(elementId).style.display = "block";
}
function maindiv()
{
}
function refreshh()
{firebase.auth().onAuthStateChanged(function(user) {
if (user) {
var uuid=user.uid;
firebase.database().ref().child('bookinghistory').once('value').then(function(snapshot) {
snapshot.forEach(function(userSnapshot) {
var d1=userSnapshot.val().Source;
var d2=userSnapshot.val().SplitNewDestination;
var d3=userSnapshot.val().destination;
var d4=userSnapshot.val().dateoftravel;
var d5=userSnapshot.val().quota;
var d6=userSnapshot.val().trainnumber;
var d7=userSnapshot.val().classs;
var d8=userSnapshot.val().SugSrc;
var d9=userSnapshot.val().SugDest;
var d10=userSnapshot.val().SplitNewSource;
console.log(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10);
document.getElementById('s1').value=d1;
document.getElementById('s2').value=d3;
document.getElementById('s3').value=d4;
document.getElementById('s4').value=d5;
document.getElementById('s5').value=d6;
document.getElementById('s6').value=d7;
document.getElementById('s7').value=d8;
document.getElementById('s8').value=d9;
document.getElementById('s9').value=d10;
document.getElementById('s10').value=d2;
});
});
}else{
alert("No user signed in.");
}
});
}
function update()
{
}
function trainlist()
{var src1;
var ff;
var osrc=document.getElementById('srcstn').value;
var odest=document.getElementById('desstn').value;
var dest1;
var src1c=document.getElementById('srcstn').value;
var ccg=src1c.toUpperCase();
var rkg=document.getElementById('desstn').value;
var rrkg=rkg.toUpperCase();
var dest1c;
var rr;
var cc;
var ii;
var tno=document.getElementById('tno').value;
var url="https://api.railwayapi.com/v2/route/train/"+tno+"/apikey/"+key+"/";
var options = "";
$.getJSON(url,function(data){
console.log(data);
data.route.forEach(function(route){
cc=route.station.code;
if(cc==ccg){
var s=route.no;
ff=s+1
console.log(s);
}
if(rrkg==cc)
{
ii=route.no;
rr=ii-1;
console.log(rr)
}
});
data.route.forEach(function(route){
if(route.no == rr){
document.getElementById("destn").innerHTML=route.station.name;
document.getElementById("destc").innerHTML=route.station.code;
b=route.station.code;
}
if(route.no == ff)
{
document.getElementById("srcn").innerHTML=route.station.name;
document.getElementById("srcc").innerHTML=route.station.code;
a=route.station.code;
}
});
});
document.getElementById('osrc').innerHTML=osrc;
document.getElementById('odest').innerHTML=odest;
}
function planj()
{
src=document.getElementById('srcstn').value;
dest=document.getElementById('desstn').value;
date=document.getElementById('doj').value;
var url="https://api.railwayapi.com/v2/between/source/"+src+"/dest/"+dest+"/date/"+date+"/apikey/"+key+"/"
console.log(date,src,dest,url);
var options = "";
if(src == 0|| dest == 0 || date==0)
{
alert("Please fill the input fields");
}
$.getJSON(url,function(data){
console.log(data);
console.log(data.response_code)
if(data.response_code >=200 && data.response_code < 400){
data.trains.forEach(function(trains){
console.log(data.trains)
options = "<tr><td>"+trains.number+"</td><td>" + trains.name+"</td></tr>";
// $('#train-block').append(options + "<br>");
$('#traindetails tbody').append(options);
});
}
else
{
alert("server error please try after sometime.")
}
});
}
function seatsfunction()
{
var tno=document.getElementById('tno').value;
var date=document.getElementById('doj').value;
var src=document.getElementById('srcstn').value;
var dest=document.getElementById('desstn').value;
var cls=document.getElementById('class').value;
var qto=document.getElementById('quota').value;
var url="https://api.railwayapi.com/v2/check-seat/train/"+tno+"/source/"+src+"/dest/"+dest+"/date/"+date+"/pref/"+cls+"/quota/"+qto+"/apikey/"+key+"/";
var options = "";
if(tno == 0)
{
alert("Please fill the input fields");
}
$.getJSON(url,function(data){
console.log(data);
if(data.response_code >=200 && data.response_code < 400){
data.availability.forEach(function(availability){
options = "<tr><td>"+availability.date+"</td><td>" + availability.status+"</td></tr>";
// $('#train-block').append(options + "<br>");
$('#seatdetails tbody').append(options);
});
}
else{
alert("server error please try after sometime.")
}
});
}
function splitj(){
var tno=document.getElementById('tno').value;
var x;
var cc;
var s;
var src1c=document.getElementById('srcstn').value;
var ccg=src1c.toUpperCase();
var rkg=document.getElementById('desstn').value;
var rrkg=rkg.toUpperCase();
var o;
var gg;
var m;
var k;
var url="https://api.railwayapi.com/v2/route/train/"+tno+"/apikey/"+key+"/";
var options = "";
$.getJSON(url,function(data){
console.log(data);
data.route.forEach(function(route){
cc=route.station.code;
if(cc==ccg){
s=route.no-1;
console.log(s);
}
if(cc==rrkg){
k=route.no;
console.log(k);
}
x=k-s;
gg=Math.round(x/2);
o=s+gg;
m=o+1;
console.log(gg,o,m)
});
data.route.forEach(function(route){
if(o == route.no){
console.log(route.station.name);
document.getElementById("ndest").innerHTML=route.station.name;
document.getElementById("ndestc").innerHTML=route.station.code;
c=route.station.code
}
if (route.no==m) {
document.getElementById("nsrc").innerHTML=route.station.name;
document.getElementById("nsrcc").innerHTML=route.station.code;
d=route.station.code;
}
});
});
}
window.onload = function() {
initApp();
event.preventDefault();
document.getElementById('search').addEventListener('click', planj);
document.getElementById('updated').addEventListener('click', update);
document.getElementById('seatsrch').addEventListener('click',seatsfunction);
document.getElementById('sug').addEventListener('click',trainlist);
document.getElementById('split').addEventListener('click',splitj);
$('input[type="date"]').change(function(){
alert(this.value.split("-").reverse().join("-"));
});
};
</script>
</body>
</html>