Skip to content

Commit f34812b

Browse files
Fix the messages and change the link to the form
modified: _resourcepdf/overrides/partials/rating.html
1 parent 88a2e7e commit f34812b

File tree

3 files changed

+169
-171
lines changed

3 files changed

+169
-171
lines changed

_resourcepdf/overrides/partials/rating.html

Lines changed: 0 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -189,174 +189,3 @@
189189
}
190190
}
191191
</style>
192-
193-
<script>
194-
function initFeedbackWidget() {
195-
const stars = document.querySelectorAll(".rating-stars .star");
196-
const feedbackForm = document.getElementById("feedback-form");
197-
const feedbackTextarea = document.getElementById("feedback-text");
198-
const emailInput = document.getElementById("feedback-email");
199-
const submitButton = document.getElementById("submit-feedback");
200-
const statusDiv = document.getElementById("feedback-status");
201-
const closeButton = document.getElementById("close-feedback");
202-
const notification = document.getElementById("feedback-notification");
203-
const submitNotification = document.getElementById("feedback-submit-notification");
204-
205-
if (!stars.length || !feedbackForm) return;
206-
207-
const formURL = "https://docs.google.com/forms/d/e/1FAIpQLSfhscELpzoXB4uyh9pXNmXSeqKc10IH_DxmAoaVGID85sO0Aw/formResponse";
208-
const fieldIds = {
209-
rating: "entry.303027158",
210-
pageUrl: "entry.295622433",
211-
feedback: "entry.2131350495",
212-
email: "entry.1689727303"
213-
};
214-
215-
let selectedRating = 0;
216-
let notificationTimeout;
217-
218-
function showNotification(msg) {
219-
notification.textContent = msg;
220-
notification.style.display = "block";
221-
clearTimeout(notificationTimeout);
222-
notificationTimeout = setTimeout(() => {
223-
notification.style.display = "none";
224-
}, 3000);
225-
}
226-
227-
function sendRatingOnly(rating) {
228-
const formData = new FormData();
229-
formData.append(fieldIds.rating, rating);
230-
formData.append(fieldIds.pageUrl, window.location.href);
231-
232-
fetch(formURL, {
233-
method: "POST",
234-
mode: "no-cors",
235-
body: formData
236-
}).catch(() => {
237-
console.warn("Rating failed to submit silently.");
238-
});
239-
}
240-
241-
function submitFeedback(rating, feedbackText = "", email = "") {
242-
const formData = new FormData();
243-
formData.append(fieldIds.rating, rating);
244-
formData.append(fieldIds.pageUrl, window.location.href);
245-
formData.append(fieldIds.feedback, feedbackText);
246-
if (email) formData.append(fieldIds.email, email);
247-
248-
fetch(formURL, {
249-
method: "POST",
250-
mode: "no-cors",
251-
body: formData
252-
}).then(() => {
253-
statusDiv.style.color = "";
254-
feedbackTextarea.value = "";
255-
emailInput.value = "";
256-
feedbackForm.style.display = "none";
257-
selectedRating = 0;
258-
259-
stars.forEach((s) => {
260-
s.textContent = "☆";
261-
s.classList.remove("active");
262-
s.classList.remove("hovered");
263-
});
264-
265-
// ✅ Show post-submit thank-you notification
266-
submitNotification.style.display = "block";
267-
clearTimeout(notificationTimeout);
268-
notificationTimeout = setTimeout(() => {
269-
submitNotification.style.display = "none";
270-
}, 4000);
271-
}).catch(() => {
272-
statusDiv.style.color = "";
273-
statusDiv.textContent = "Error sending feedback.";
274-
});
275-
}
276-
277-
stars.forEach((star) => {
278-
const rating = parseInt(star.dataset.rating, 10);
279-
280-
star.addEventListener("mouseover", () => {
281-
stars.forEach((s, index) => {
282-
s.textContent = index < rating ? "★" : "☆";
283-
if(index < rating) {
284-
s.classList.add("hovered");
285-
s.classList.remove("active");
286-
} else {
287-
s.classList.remove("hovered");
288-
s.classList.remove("active");
289-
}
290-
});
291-
});
292-
293-
star.addEventListener("mouseleave", () => {
294-
stars.forEach((s, index) => {
295-
s.textContent = index < selectedRating ? "★" : "☆";
296-
if(index < selectedRating) {
297-
s.classList.add("active");
298-
} else {
299-
s.classList.remove("active");
300-
}
301-
s.classList.remove("hovered");
302-
});
303-
});
304-
305-
star.addEventListener("click", () => {
306-
selectedRating = rating;
307-
308-
stars.forEach((s, index) => {
309-
s.textContent = index < rating ? "★" : "☆";
310-
if(index < rating) {
311-
s.classList.add("active");
312-
} else {
313-
s.classList.remove("active");
314-
}
315-
s.classList.remove("hovered");
316-
});
317-
318-
sendRatingOnly(rating);
319-
feedbackForm.style.display = "block";
320-
statusDiv.textContent = "";
321-
});
322-
});
323-
324-
submitButton.addEventListener("click", () => {
325-
if (!selectedRating) return;
326-
const feedbackText = feedbackTextarea.value.trim();
327-
const email = emailInput.value.trim();
328-
329-
if (selectedRating < 5 && !feedbackText) {
330-
statusDiv.style.color = "";
331-
statusDiv.textContent = "Write feedback before sending.";
332-
return;
333-
}
334-
335-
submitFeedback(selectedRating, feedbackText, email);
336-
});
337-
338-
closeButton.addEventListener("click", () => {
339-
feedbackForm.style.display = "none";
340-
feedbackTextarea.value = "";
341-
emailInput.value = "";
342-
statusDiv.textContent = "";
343-
selectedRating = 0;
344-
345-
stars.forEach((s) => {
346-
s.textContent = "☆";
347-
s.classList.remove("active");
348-
s.classList.remove("hovered");
349-
});
350-
});
351-
}
352-
353-
// Init on load
354-
document.addEventListener("DOMContentLoaded", initFeedbackWidget);
355-
356-
// Re-init on page change (MkDocs Material support)
357-
if (typeof document$ !== 'undefined') {
358-
document$.subscribe(() => {
359-
initFeedbackWidget();
360-
});
361-
}
362-
</script>

docs/js/rating.js

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
function initFeedbackWidget() {
2+
const stars = document.querySelectorAll(".rating-stars .star");
3+
const feedbackForm = document.getElementById("feedback-form");
4+
const feedbackTextarea = document.getElementById("feedback-text");
5+
const emailInput = document.getElementById("feedback-email");
6+
const submitButton = document.getElementById("submit-feedback");
7+
const statusDiv = document.getElementById("feedback-status");
8+
const closeButton = document.getElementById("close-feedback");
9+
const notification = document.getElementById("feedback-notification");
10+
const submitNotification = document.getElementById("feedback-submit-notification");
11+
12+
if (!stars.length || !feedbackForm) return;
13+
14+
const formURL = "https://docs.google.com/forms/d/e/1FAIpQLSdXWLhl1oKQqq9AgG_Ugxs5EbF3NMAiddWswL4ITyaQZZr5BA/formResponse";
15+
const fieldIds = {
16+
rating: "entry.303027158",
17+
pageUrl: "entry.295622433",
18+
feedback: "entry.2131350495",
19+
email: "entry.1689727303"
20+
};
21+
22+
let selectedRating = 0;
23+
let notificationTimeout;
24+
25+
function showNotification(msg) {
26+
notification.textContent = msg;
27+
notification.style.display = "block";
28+
clearTimeout(notificationTimeout);
29+
notificationTimeout = setTimeout(() => {
30+
notification.style.display = "none";
31+
}, 3000);
32+
}
33+
34+
function sendRatingOnly(rating) {
35+
const formData = new FormData();
36+
formData.append(fieldIds.rating, rating);
37+
formData.append(fieldIds.pageUrl, window.location.href);
38+
39+
fetch(formURL, {
40+
method: "POST",
41+
mode: "no-cors",
42+
body: formData
43+
}).catch(() => {
44+
console.warn("Rating failed to submit silently.");
45+
});
46+
}
47+
48+
function submitFeedback(rating, feedbackText = "", email = "") {
49+
const formData = new FormData();
50+
formData.append(fieldIds.rating, rating);
51+
formData.append(fieldIds.pageUrl, window.location.href);
52+
formData.append(fieldIds.feedback, feedbackText);
53+
if (email) formData.append(fieldIds.email, email);
54+
55+
fetch(formURL, {
56+
method: "POST",
57+
mode: "no-cors",
58+
body: formData
59+
}).then(() => {
60+
statusDiv.style.color = "";
61+
feedbackTextarea.value = "";
62+
emailInput.value = "";
63+
feedbackForm.style.display = "none";
64+
selectedRating = 0;
65+
66+
stars.forEach((s) => {
67+
s.textContent = "☆";
68+
s.classList.remove("active");
69+
s.classList.remove("hovered");
70+
});
71+
72+
// ✅ Show post-submit thank-you notification
73+
submitNotification.style.display = "block";
74+
clearTimeout(notificationTimeout);
75+
notificationTimeout = setTimeout(() => {
76+
submitNotification.style.display = "none";
77+
}, 4000);
78+
}).catch(() => {
79+
statusDiv.style.color = "";
80+
statusDiv.textContent = "Error sending feedback.";
81+
});
82+
}
83+
84+
stars.forEach((star) => {
85+
const rating = parseInt(star.dataset.rating, 10);
86+
87+
star.addEventListener("mouseover", () => {
88+
stars.forEach((s, index) => {
89+
s.textContent = index < rating ? "★" : "☆";
90+
if(index < rating) {
91+
s.classList.add("hovered");
92+
s.classList.remove("active");
93+
} else {
94+
s.classList.remove("hovered");
95+
s.classList.remove("active");
96+
}
97+
});
98+
});
99+
100+
star.addEventListener("mouseleave", () => {
101+
stars.forEach((s, index) => {
102+
s.textContent = index < selectedRating ? "★" : "☆";
103+
if(index < selectedRating) {
104+
s.classList.add("active");
105+
} else {
106+
s.classList.remove("active");
107+
}
108+
s.classList.remove("hovered");
109+
});
110+
});
111+
112+
star.addEventListener("click", () => {
113+
selectedRating = rating;
114+
115+
stars.forEach((s, index) => {
116+
s.textContent = index < rating ? "★" : "☆";
117+
if(index < rating) {
118+
s.classList.add("active");
119+
} else {
120+
s.classList.remove("active");
121+
}
122+
s.classList.remove("hovered");
123+
});
124+
125+
sendRatingOnly(rating);
126+
feedbackForm.style.display = "block";
127+
statusDiv.textContent = "";
128+
});
129+
});
130+
131+
submitButton.addEventListener("click", () => {
132+
if (!selectedRating) return;
133+
const feedbackText = feedbackTextarea.value.trim();
134+
const email = emailInput.value.trim();
135+
136+
if (selectedRating < 5 && !feedbackText) {
137+
statusDiv.style.color = "";
138+
statusDiv.textContent = "Write feedback before sending.";
139+
return;
140+
}
141+
142+
submitFeedback(selectedRating, feedbackText, email);
143+
});
144+
145+
closeButton.addEventListener("click", () => {
146+
feedbackForm.style.display = "none";
147+
feedbackTextarea.value = "";
148+
emailInput.value = "";
149+
statusDiv.textContent = "";
150+
selectedRating = 0;
151+
152+
stars.forEach((s) => {
153+
s.textContent = "☆";
154+
s.classList.remove("active");
155+
s.classList.remove("hovered");
156+
});
157+
});
158+
}
159+
160+
// Init on load
161+
document.addEventListener("DOMContentLoaded", initFeedbackWidget);
162+
163+
// Re-init on page change (MkDocs Material support)
164+
if (typeof document$ !== 'undefined') {
165+
document$.subscribe(() => {
166+
initFeedbackWidget();
167+
});
168+
}

mkdocs-base.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extra_javascript:
7171
- js/version-select.js
7272
- js/promptremover.js
7373
- js/consent.js
74+
- js/rating.js
7475

7576
markdown_extensions:
7677
attr_list: {}

0 commit comments

Comments
 (0)