forked from ankit071105/Ticket-Booking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AI suggestions.html
190 lines (169 loc) · 4.94 KB
/
AI suggestions.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Travel Cost Suggestion</title>
<style>
/* Reset and Base Styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #74ebd5, #9face6);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
color: #444;
}
.container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
/* Card Style */
.card {
background-color: #ffffff;
padding: 2em;
width: 90%;
max-width: 450px;
border-radius: 12px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
transition: transform 0.2s;
}
.card:hover {
transform: translateY(-5px);
}
h1 {
text-align: center;
font-size: 1.8em;
color: #333;
margin-bottom: 1.5em;
}
/* Input Group */
.input-group {
margin-bottom: 1.5em;
}
.input-group label {
font-weight: bold;
margin-bottom: 0.5em;
display: block;
color: #555;
}
input[type="text"], input[type="date"], select {
width: 100%;
padding: 0.7em;
border: 1px solid #ccc;
border-radius: 8px;
transition: border 0.3s;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus {
border-color: #74ebd5;
outline: none;
}
/* Button */
button {
width: 100%;
padding: 0.9em;
border: none;
border-radius: 8px;
background: linear-gradient(135deg, #74ebd5, #9face6);
color: white;
font-weight: bold;
font-size: 1.1em;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: linear-gradient(135deg, #9face6, #74ebd5);
}
/* Suggestion Box */
.suggestion-box {
margin-top: 2em;
padding: 1.5em;
background-color: #f1f1f1;
border-radius: 8px;
display: none;
text-align: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.suggestion-box h2 {
font-size: 1.5em;
color: #333;
margin-bottom: 0.5em;
}
#costOutput {
font-size: 1.3em;
color: #2d8d2d;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<h1>Travel Cost Suggestion</h1>
<form id="travelForm">
<div class="input-group">
<label for="origin">Origin</label>
<input type="text" id="origin" placeholder="City of Origin" required>
</div>
<div class="input-group">
<label for="destination">Destination</label>
<input type="text" id="destination" placeholder="City of Destination" required>
</div>
<div class="input-group">
<label for="travelDate">Travel Date</label>
<input type="date" id="travelDate" required>
</div>
<div class="input-group">
<label for="travelType">Travel Type</label>
<select id="travelType">
<option value="economy">Economy</option>
<option value="business">Business</option>
</select>
</div>
<button type="button" onclick="suggestCost()">Get Suggestion</button>
</form>
<div id="suggestion" class="suggestion-box">
<h2>Suggested Travel Cost</h2>
<p id="costOutput"></p>
</div>
</div>
</div>
<script>
function suggestCost() {
// Capture user input values
const origin = document.getElementById("origin").value;
const destination = document.getElementById("destination").value;
const travelDate = document.getElementById("travelDate").value;
const travelType = document.getElementById("travelType").value;
// Simple validation
if (!origin || !destination || !travelDate || !travelType) {
alert("Please fill in all fields.");
return;
}
// Simulate AI-based travel cost suggestion (this can be replaced with an API call)
const cost = calculateCost(origin, destination, travelDate, travelType);
// Display the result with smooth reveal
const suggestionBox = document.getElementById("suggestion");
suggestionBox.style.display = "block";
suggestionBox.classList.add("show");
document.getElementById("costOutput").textContent = `Estimated Cost: $${cost.toFixed(2)}`;
}
// Simulated AI function for cost estimation
function calculateCost(origin, destination, date, type) {
let basePrice = 100;
const distanceFactor = Math.random() * 50 + 50; // Random multiplier
const typeFactor = type === "business" ? 2.0 : 1.0;
const randomAdjustment = Math.random() * 20;
return (basePrice + distanceFactor) * typeFactor + randomAdjustment;
}
</script>
</body>
</html>