-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhomepage.html
151 lines (137 loc) · 5.89 KB
/
homepage.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
<!DOCTYPE html>
<html>
<head>
<title>Rail Mitra Homepage</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Pacifico|Paytone+One" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="GDC-HomeCSSnew.css">
<link rel="stylesheet" href="HomepageStyle.css">
</head>
<body>
<div class="HomeContainer">
<!--Heading/Moto-->
<div class="container">
<div class="row">
<div class="col-lg-12">
<div id="content">
<h1 style="color: rgba(255, 255, 255, 1); font-weight: 900;">Your Experience Starts Here!</h1>
</div>
</div>
</div>
</div>
<!--Heading/Moto End-->
<!--Tabs-->
<div class="container" id="second">
<!--Tabs Headings-->
<ul class="nav nav-tabs">
<li class="active"><a class="tabshead" data-toggle="tab" href="#home" ><i class="fas fa-plane" ></i> Trains</a></li>
</ul>
<!--Tabs Headings End-->
<!--Tabs Content-->
<div class="tab-content">
<!--Tab Content Trains-->
<div id="home" class="tab-pane fade in active">
<h3 class="lab" style="color: rgba(255, 255, 255, 1); font-weight: 900;">Trains</h3>
<form >
<select name="origin" class="drop" id="ori" >
<option value="Origin">Origin</option>
<option value="Mumbai">MUMBAI</option>
<option value="Delhi">DELHI</option>
<option value="Bangalore">BANGALORE</option>
<option value="Kolkata">KOLKATA</option>
</select>
<i class="fas fa-exchange-alt"></i>
<select name="destination" class="drop" id="dest">
<option value="Destination">Destination</option>
<option value="Mumbai">MUMBAI</option>
<option value="Delhi">DELHI</option>
<option value="Bangalore">BANGALORE</option>
<option value="Kolkata">KOLKATA</option>
</select>
<span class="lab" style="color: rgba(255, 255, 255, 1); font-weight: 900;">Departure:</span>
<input type="date" name="depart" class="drop" id="depart">
<span class="lab" style="color: rgba(255, 255, 255, 1); font-weight: 900;">Return:</span>
<input type="date" name="return" class="drop" id="return">
<input type="submit" name="submit" id="flightsButton" style="background-color: #007BFF; color: #fff; border: none; padding: 10px 20px; font-weight: 900; cursor: pointer; border-radius: 10px;">
</form>
</div>
<!--Tab Content End-->
<hr>
</div>
<!--Tab Contents End-->
</div>
<!--Tabs End-->
<div class="container" id="flightResult">
<h3 style="color: rgba(255, 255, 255, 1); font-weight: 900;">Trains Search Result</h3>
<div id="resultContainer"></div>
</div>
</div>
<script>
document.getElementById("flightsButton").addEventListener("click", function (event) {
event.preventDefault();
const form = document.querySelector("form");
fetch("http://localhost:3000/search", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
origin: form.origin.value,
destination: form.destination.value,
departure: form.depart.value,
returnDate: form.return.value,
}),
})
.then((response) => response.json())
.then((data) => {
const resultContainer = document.getElementById("resultContainer");
resultContainer.innerHTML = "";
if (data.length > 0) {
data.forEach((flight, index) => {
const flightInfo = document.createElement("div");
flightInfo.innerHTML = `
<hr>
<div class="col-lg-8">
<p>Train Name: ${flight.railName}</p>
<p>Origin: ${flight.origin}</p>
<p>Destination: ${flight.destination}</p>
<p>Departure: ${flight.departure}</p>
<p>Return: ${flight.return}</p>
<button class="btn btn-success book-now-button" data-index="${index}">Book Now</button>
<br><br><hr><br><br>
</div>
<div class="col-lg-4">
<img src="images/ticket.jpg" alt="train Image" height="150px" style="border-radius:10%">
<br><br>
</div>
`;
resultContainer.appendChild(flightInfo);
});
const bookNowButtons = document.querySelectorAll(".book-now-button");
bookNowButtons.forEach((button) => {
button.addEventListener("click", function (event) {
event.preventDefault();
const flightIndex = this.getAttribute("data-index");
const selectedFlight = data[flightIndex];
localStorage.setItem("selectedFlight", JSON.stringify(selectedFlight));
window.location.href = "Payment.html";
});
});
} else {
const noResult = document.createElement("p");
noResult.textContent = "No Trains found for the given criteria.";
resultContainer.appendChild(noResult);
}
})
.catch((error) => {
console.error("Error:", error);
alert("No such flights available.");
});
});
</script>
</body>
</html>