Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Add feedback form modal button
Browse files
chat_application/templates/room.html
CHANGED
|
@@ -30,6 +30,7 @@
|
|
| 30 |
<h2 id="room-code-display">Topic: <span class="topic-title">{{ topic_info.title }}</span></h2>
|
| 31 |
</div>
|
| 32 |
<div class="topic-header-buttons">
|
|
|
|
| 33 |
<button id="end-exp-btn">End Chat Session</button>
|
| 34 |
<button id="abort-exp-btn">Abort Experiment</button>
|
| 35 |
</div>
|
|
@@ -67,6 +68,22 @@
|
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
<div id="chat-room-widget">
|
| 72 |
<div id="msgs-container">
|
|
@@ -251,6 +268,30 @@
|
|
| 251 |
document.getElementById("abortNoBtn").onclick = function () {
|
| 252 |
abortModalConfirm.style.display = "none";
|
| 253 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
// add auto scroll
|
| 256 |
function isNearBottom(container, threshold = 120) {
|
|
|
|
| 30 |
<h2 id="room-code-display">Topic: <span class="topic-title">{{ topic_info.title }}</span></h2>
|
| 31 |
</div>
|
| 32 |
<div class="topic-header-buttons">
|
| 33 |
+
<button id="feedback-btn">Provide Feedback</button>
|
| 34 |
<button id="end-exp-btn">End Chat Session</button>
|
| 35 |
<button id="abort-exp-btn">Abort Experiment</button>
|
| 36 |
</div>
|
|
|
|
| 68 |
</div>
|
| 69 |
</div>
|
| 70 |
</div>
|
| 71 |
+
<div id="feedback-modal" class="modal">
|
| 72 |
+
<div class="modal-content">
|
| 73 |
+
<h3>Feedback</h3>
|
| 74 |
+
<form id="feedback-form">
|
| 75 |
+
<div class="feedback-col">
|
| 76 |
+
<label for="enter-feedback">Enter Feedback</label>
|
| 77 |
+
<textarea id="enter-feedback" name="feedback"></textarea>
|
| 78 |
+
</div>
|
| 79 |
+
<br>
|
| 80 |
+
<div class="modal-buttons">
|
| 81 |
+
<button class="modal-btn" id="submitFeedbackBtn" type="submit">Submit</button>
|
| 82 |
+
<button type="button" class="modal-btn" id="cancelFeedbackBtn">Cancel</button>
|
| 83 |
+
</div>
|
| 84 |
+
</form>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
</div>
|
| 88 |
<div id="chat-room-widget">
|
| 89 |
<div id="msgs-container">
|
|
|
|
| 268 |
document.getElementById("abortNoBtn").onclick = function () {
|
| 269 |
abortModalConfirm.style.display = "none";
|
| 270 |
};
|
| 271 |
+
|
| 272 |
+
//handler for feedback modal popup
|
| 273 |
+
let feedbackModal = document.getElementById("feedback-modal");
|
| 274 |
+
let form = document.getElementById("feedback-form");
|
| 275 |
+
document.getElementById("feedback-btn").onclick = function () {
|
| 276 |
+
feedbackModal.style.display = "block";
|
| 277 |
+
};
|
| 278 |
+
document.getElementById("cancelFeedbackBtn").onclick = function () {
|
| 279 |
+
feedbackModal.style.display = "none";
|
| 280 |
+
};
|
| 281 |
+
|
| 282 |
+
//override form function to instead emit save feedback event
|
| 283 |
+
form.addEventListener("submit", function (e) {
|
| 284 |
+
e.preventDefault();
|
| 285 |
+
|
| 286 |
+
const data = new FormData(form);
|
| 287 |
+
const feedback = data.get("feedback")?.trim();
|
| 288 |
+
|
| 289 |
+
if (!feedback) return;
|
| 290 |
+
socketio.emit("feedback_given", { feedback });
|
| 291 |
+
|
| 292 |
+
form.reset();
|
| 293 |
+
document.getElementById("feedback-modal").style.display = "none";
|
| 294 |
+
});
|
| 295 |
|
| 296 |
// add auto scroll
|
| 297 |
function isNearBottom(container, threshold = 120) {
|