forked from anuragverma108/WildGuard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
review.html
270 lines (220 loc) · 6.02 KB
/
review.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animal Organization Ratings</title>
<style>
body {
font-family: 'Montserrat', sans-serif;
background-image: url('image.avif'); /* Add background image */
background-size: cover; /* Cover entire page */
background-position: center; /* Center image */
background-attachment: fixed;
opacity: .9
/* Fix image position */
}
.rating-container {
display: flex;
flex-direction: column;
align-items: center;
padding: 40px;
background-color: #fff; /* White background for container */
border-radius: 15px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
opacity: .9;
}
.rating {
font-size: 36px;
font-weight: bold;
color: #2ecc71;
}
.rating-breakdown {
font-size: 22px;
color: #666;
margin-bottom: 20px;
}
.reviews-container {
margin-top: 60px;
opacity: .9
}
.review {
background-color: #f9f9f9;
padding: 30px;
border-bottom: 1px solid #ddd;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.review:nth-child(even) {
background-color: #e5e5e5;
}
/* .organization-info {
margin-top: 80px;
background-color: #fff;
padding: 40px;
border-radius: 15px;
box-shadow: 0 5px 20px rgba(239, 9, 9, 0.797);
} */
.rating-form {
max-width: 700px;
margin: 80px auto;
padding: 50px;
background-color: #fff;
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
opacity: .9
}
.rating-form h2 {
color: #333;
font-weight: bold;
font-size: 32px;
margin-bottom: 20px;
}
.rating-form label {
font-size: 18px;
color: #594c4c;
margin-bottom: 10px;
}
.rating-form select {
width: 100%;
padding: 15px;
font-size: 18px;
border: 1px solid #ccc;
border-radius: 10px;
margin-bottom: 20px;
}
.rating-form textarea {
width: 100%;
padding: 15px;
font-size: 18px;
border: 1px solid #ccc;
border-radius: 10px;
margin-bottom: 20px;
}
.rating-form button {
background-color: #2ecc71;
color: #fff;
padding: 15px 30px;
border: none;
border-radius: 10px;
font-size: 18px;
cursor: pointer;
}
.rating-form button:hover {
background-color: #34c759;
}
/* Responsive Design */
@media (max-width: 768px) {
.rating-container {
padding: 20px;
}
.rating-form {
padding: 30px;
}
}
@media (max-width: 480px) {
.rating-container {
padding: 10px;
}
.rating-form {
padding: 20px;
}
}
/* */
</style>
</head>
<body>
<div class="rating-form">
<h2>Rate this Organization</h2>
<form id="rating-form">
<label for="rating">Rating (1-5):</label>
<select id="rating" required>
<option value="1">1🌟</option>
<option value="2">2🌟🌟</option>
<option value="3">3🌟🌟🌟</option>
<option value="4">4🌟🌟🌟🌟</option>
<option value="5">5🌟🌟🌟🌟🌟</option>
</select>
<label for="review">Review:</label>
<textarea id="review" required></textarea>
<button id="submit-btn">Submit Review</button>
</form>
</div>
<!-- Organization Profile Page -->
<div class="organization-profile">
<h2 >Organization Profile</h2>
<div class="rating-container">
<div class="rating">Average Rating: <span id="average-rating"></span></div>
<div class="rating-breakdown">
<span id="rating-distribution"></span>
</div>
</div>
<div class="reviews-container">
<h3 style="color: #2ecc71;">Reviews:</h3>
<div id="reviews"></div>
</div>
</div>
<script>
let ratings = [];
// Get organization profile elements
const averageRatingElement = document.getElementById('average-rating');
const ratingDistributionElement = document.getElementById('rating-distribution');
const reviewsElement = document.getElementById('reviews');
const organizationNameElement = document.getElementById('organization-name');
const missionStatementElement = document.getElementById('mission-statement');
const contactInfoElement = document.getElementById('contact-info');
// Submit rating form event listener
document.getElementById('submit-btn').addEventListener('click', (e) => {
e.preventDefault();
// Get rating and review values
const ratingValue = document.getElementById('rating').value;
const reviewValue = document.getElementById('review').value;
const newRating = {
rating: ratingValue,
review: reviewValue
};
// Add new rating to ratings array
ratings.push(newRating);
// Update organization profile page
updateOrganizationProfile();
});
// Update organization profile page function
function updateOrganizationProfile() {
// Calculate average rating
const averageRating = calculateAverageRating();
// Update average rating element
averageRatingElement.textContent = `${averageRating}/5`;
// Update rating distribution element
ratingDistributionElement.textContent = `${getRatingDistribution()}% positive`;
reviewsElement.innerHTML = '';
ratings.forEach((rating, index) => {
const reviewHTML = `
<div class="review">
<p>Rating: ${rating.rating}/5</p>
<p>${rating.review}</p>
</div>
`;
reviewsElement.insertAdjacentHTML('beforeend', reviewHTML);
});
}
// Calculate average rating function
function calculateAverageRating() {
let sum = 0;
ratings.forEach((rating) => {
sum += parseInt(rating.rating);
});
return (sum / ratings.length).toFixed(2);
}
// Get rating distribution function
function getRatingDistribution() {
let positiveRatings = 0;
ratings.forEach((rating) => {
if (rating.rating >= 4) {
positiveRatings++;
}
});
return ((positiveRatings / ratings.length) * 100).toFixed(2);
}
</script>
</body>
</html>