-
Notifications
You must be signed in to change notification settings - Fork 202
/
rate.html
296 lines (260 loc) · 9.55 KB
/
rate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rate Our Space Rocket Game</title>
<!-- Font Awesome for Stars -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" />
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<style>
/* Reset & Base Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
font-family: 'Roboto', sans-serif;
color: #fff;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.rating-container {
background: rgba(255, 255, 255, 0.1);
padding: 30px 40px;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0,0,0,0.3);
text-align: center;
width: 90%;
max-width: 600px;
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
h2 {
font-family: 'Orbitron', sans-serif;
margin-bottom: 20px;
font-size: 2em;
color: #00aaff;
}
.stars {
display: flex;
justify-content: center;
margin-bottom: 15px;
}
.stars i {
font-size: 2.5em;
color: #00aaff;
margin: 0 5px;
cursor: pointer;
transition: transform 0.2s, color 0.2s;
}
.stars i:hover {
transform: scale(1.2);
color: #ffd700;
}
.stars .fas {
color: #ffd700;
}
#ratingMessage {
margin-top: 15px;
font-size: 1.1em;
min-height: 1.2em;
}
textarea {
width: 100%;
height: 120px;
margin-top: 20px;
padding: 15px;
border: none;
border-radius: 10px;
resize: none;
font-size: 1em;
font-family: 'Roboto', sans-serif;
background: rgba(255, 255, 255, 0.2);
color: #fff;
}
textarea::placeholder {
color: #ddd;
}
textarea:focus {
outline: none;
box-shadow: 0 0 10px #00aaff;
}
#submitRating {
margin-top: 20px;
padding: 12px 25px;
background-color: #00aaff;
color: #fff;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s;
}
#submitRating:hover {
background-color: #0088cc;
}
/* Additional Feature: Average Rating Display */
.average-rating {
margin-top: 30px;
font-size: 1.2em;
display: flex;
align-items: center;
justify-content: center;
}
.average-rating .fas {
color: #ffd700;
margin-right: 8px;
}
/* Rocket Image */
.rocket {
position: absolute;
top: 10px;
right: 10px;
width: 60px;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0% { transform: translateY(0); }
50% { transform: translateY(-15px); }
100% { transform: translateY(0); }
}
/* Redirect Button */
#redirectButton {
margin-top: 20px;
padding: 12px 25px;
background-color: #ff5722;
color: #fff;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s;
display: none; /* Hidden by default */
}
#redirectButton:hover {
background-color: #e64a19;
}
/* Responsive Design */
@media (max-width: 600px) {
.rating-container {
padding: 20px 25px;
}
h2 {
font-size: 1.5em;
}
.stars i {
font-size: 2em;
}
#submitRating, #redirectButton {
width: 100%;
}
}
</style>
</head>
<body>
<!-- Rocket Image -->
<img src="https://i.imgur.com/4AI6ZgK.png" alt="Rocket" class="rocket">
<div class="rating-container">
<h2>Rate Our Space Rocket Game</h2>
<div id="ratingStars" class="stars">
<i class="far fa-star" data-rating="1"></i>
<i class="far fa-star" data-rating="2"></i>
<i class="far fa-star" data-rating="3"></i>
<i class="far fa-star" data-rating="4"></i>
<i class="far fa-star" data-rating="5"></i>
</div>
<p id="ratingMessage"></p>
<textarea id="experienceInput" placeholder="Please share your experience" style="display: none;"></textarea>
<button id="submitRating" style="display: none;">Submit Rating</button>
<!-- Average Rating Display -->
<div class="average-rating" id="averageRating" style="display: none;">
<i class="fas fa-star"></i>
<span id="averageScore">4.5</span>
</div>
<!-- Redirect Button -->
<button id="redirectButton">Return to Main Page</button>
</div>
<script>
const ratingStars = document.querySelectorAll('#ratingStars i');
const ratingMessage = document.getElementById('ratingMessage');
const experienceInput = document.getElementById('experienceInput');
const submitRating = document.getElementById('submitRating');
const averageRating = document.getElementById('averageRating');
const averageScore = document.getElementById('averageScore');
const redirectButton = document.getElementById('redirectButton');
let currentRating = 0;
let totalRatings = 0;
let sumRatings = 0;
ratingStars.forEach(star => {
star.addEventListener('click', () => {
currentRating = parseInt(star.getAttribute('data-rating'));
updateStars(currentRating);
ratingMessage.textContent = `You've selected ${currentRating} star${currentRating > 1 ? 's' : ''}. Please share your experience!`;
experienceInput.style.display = 'block';
submitRating.style.display = 'inline-block';
redirectButton.style.display = 'none'; // Hide redirect button if visible
});
star.addEventListener('mouseover', () => {
const hoverRating = parseInt(star.getAttribute('data-rating'));
updateStars(hoverRating);
});
star.addEventListener('mouseout', () => {
updateStars(currentRating);
});
});
submitRating.addEventListener('click', () => {
const experience = experienceInput.value.trim();
if (currentRating === 0) {
ratingMessage.textContent = "Please select a rating before submitting.";
return;
}
if (experience) {
// Simulate sending data to server
console.log(`Rating: ${currentRating}, Experience: ${experience}`);
// Update average rating (simulated)
sumRatings += currentRating;
totalRatings += 1;
const avg = (sumRatings / totalRatings).toFixed(1);
averageScore.textContent = avg;
averageRating.style.display = 'flex';
ratingMessage.textContent = "Thank you for your feedback!";
experienceInput.value = '';
experienceInput.style.display = 'none';
submitRating.style.display = 'none';
updateStars(0);
currentRating = 0;
// Show the redirect button
redirectButton.style.display = 'inline-block';
} else {
ratingMessage.textContent = "Please share your experience before submitting.";
}
});
redirectButton.addEventListener('click', () => {
// Redirect to the main page of the game
window.location.href = 'index.html'; // Replace 'index.html' with your main page URL if different
});
function updateStars(rating) {
ratingStars.forEach(star => {
const starRating = parseInt(star.getAttribute('data-rating'));
if (starRating <= rating) {
star.classList.remove('far');
star.classList.add('fas');
} else {
star.classList.remove('fas');
star.classList.add('far');
}
});
}
</script>
</body>
</html>