-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestimonials.html
241 lines (207 loc) · 7.72 KB
/
testimonials.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="Team Kil-A-Bytes">
<meta name="description" content="INFO 1601 Project for team Kil-A-Bytes 'The Food Vault'">
<link rel="stylesheet" href="style.css">
<title>Testimonials</title>
<style>
.horizontal-card {
background: linear-gradient(to bottom, #dec9c9, #f1b8b8);
}
.user-name-comment {
margin-left: 30px;
margin-right: 30px;
margin-bottom: 15px;
}
fieldset {
width: 90%;
border-radius: 10px;
margin: 0;
margin-top: 10px;
border: 1px solid #ccc;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
background: linear-gradient(to bottom, #dec9c9, #f1b8b8);
}
@media screen and (max-width: 600px) {
#review {
width: 95%;
margin: 0 auto;
}
.data-entry-area {
width: 200px;
}
textarea {
height: 100px;
}
@media screen and (max-width: 600px) {
#review-form-outline {
width: 80%;
margin: 0 auto;
}
}
}
</style>
</head>
<body>
<!-- Main View -->
<main id="app">
<!-- Side Nav Chat-area -->
<div id="chatbot-area" class="side-nav collapsed">
<a href="javascript:void(0)" class="closebutton" onclick="closeChatArea()">×</a>
<iframe id="annabot-iframe" src="https://tfv-annabot.herokuapp.com/s/chat" frameborder="1" width="90%" height="90%"></iframe>
</div>
<!-- Main page content goes here -->
<div id="page-content" style="margin: 0;">
<!-- Main Navigation bar for top of page -->
<div style="justify-content: center; margin: 0 auto;">
<nav id="main-nav-bar" class="nav-bar">
<ul class="links-container">
<a href="index.html"><button >Home</button></a>
<a href="testimonials.html"><button class="selected">Testimonials</button></a>
<a href="catalogue.html"><button>Catalogue</button></a>
</ul>
</nav>
</div>
<br><br>
<!-- Testimonials section -->
<section id="testimonials">
<br>
<h2><b>See What Our Users Have To Say About Us!</b></h2>
<hr>
<div id="testimonials-container" class="horizontal-container"></div>
<br>
</section>
<br><br><br>
<!-- User review section -->
<section id="add-review">
<br>
<h2><b>Have Something To Say About Our Service?</b></h2>
<hr><br>
<fieldset id="review-form-outline" style="margin: 0 auto; justify-content: center;">
<form id="review" method="post">
<br><br>
<legend>
<h3><b>Let Us Know Your Thoughts!</b></h3>
</legend>
<br>
<!-- Name Data field -->
<label class="label">What's Your Name?</label>
<br><br>
<input name="Name" class="data-entry-area">
<br><br><br>
<!-- Comment Data field -->
<label class="label">What Do You Have To Say About Us?</label>
<br><br>
<textarea name="comment" class="data-entry-area" style="height: 120px;"></textarea>
<br><br><br>
<!-- Rating field -->
<label class="label">How Would You Rate Your Experience With<br><b>The Food Vault</b>?</label>
<br><br>
<select name="rating" class="data-entry-area">
<option value="5">5 - Excellent</option>
<option value="4">4 - Satisfactory</option>
<option value="3">3 - Average</option>
<option value="2">2 - Barely Good</option>
<option value="1">1 - Unsatisfactory</option>
</select>
<br><br><br>
</form>
<!-- Submit button -->
<button type="submit" class="data-entry-area" style="font-size: 12px;" form="review">Submit Review</button>
<p style="padding-top: 12px;"><b>TIP</b> - Leave the "Name" field blank if you wish to be anonymous.</p>
<p style="font-size: 10px;">(Once you submit, you will not be able to delete your review)</p>
</fieldset>
<br>
</section>
<br>
</div>
</main>
<!-- Button to Expand Chat-area -->
<button id="fixed-button" onclick="openChatArea()">Expand<br>Chat</button>
<!-- Footer -->
<footer>
<div class="horizontal-container">
<p>Find Us @</p>
<div class="vertical-container">
<a href="https://www.instagram.com/thefoodvault" style="margin-right: 7px;">
<img src="images/instagram.png" alt="Instagram" width="30" height="30" >
</a>
<a href="https://www.twitter.com/thefoodvault" style="margin-left: 7px;">
<img src="images/twitter.png" alt="Twitter" width="30" height="30">
</a>
</div>
<div id="trademark">
<p>
© The Food Vault by Team Kil-A-Bytes
</p>
</div>
</div>
</footer>
<br>
<script src="index.js"></script>
<script>
let testimonials = document.getElementById("testimonials-container");
let form = document.getElementById("review");
// Populate the testimonials section with data from the Reviews table of the database
async function populateTestimonials() {
let reviews = await pullData("Reviews");
for (let review of reviews) {
if (review.rating > 0) {
let card = document.createElement("div");
card.classList.add("horizontal-card");
let container = document.createElement("div");
container.classList.add("user-name-comment");
let name = document.createElement("h4");
name.style.marginLeft = "0";
name.style.marginRight = "0";
name.innerHTML = review.user;
container.appendChild(name);
let comment = document.createElement("span");
comment.innerHTML = review.comment;
container.appendChild(comment);
let rating = document.createElement("span");
rating.style.fontSize = "14px";
rating.innerHTML = `<br><br><i>This user rated their experience ${review.rating}/5</i>`;
container.appendChild(rating);
card.appendChild(container);
testimonials.appendChild(card);
}
}
}
// Pass data to NocoDB via POST
async function addReview(name, comment, rating) {
let update = await fetch("http://the-food-vault.herokuapp.com/nc/the_food_vault_scbp/api/v1/Reviews", {
method: "POST",
headers: {
"Content-Type": "application/json",
"xc-auth" : auth
},
body: JSON.stringify({
"user": name,
"comment": comment,
"rating": rating
})
});
}
// Prevent reload on submit
function formProcessing(e) {
e.preventDefault();
var name = form.Name.value === "" ? "Anonymous" : form.Name.value;
var comment = form.comment.value;
var rating = form.rating.value;
if (comment == "") {
alert(`We at least need to know what you have to say!`);
} else {
alert(`Thank you for your review!`);
addReview(name, comment, rating);
}
}
// Event listeners
window.addEventListener("load", populateTestimonials);
form.addEventListener("submit", formProcessing);
</script>
</body>
</html>