Skip to content

Commit c4f41a1

Browse files
DOCS-217 Test and implement the feedback form
new file: docs/js/feedback.js modified: mkdocs-base.yml modified: mkdocs.yml
1 parent 8289ff9 commit c4f41a1

File tree

3 files changed

+108
-13
lines changed

3 files changed

+108
-13
lines changed

docs/js/feedback.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
// Check if widget was closed before
3+
const closedUntil = localStorage.getItem("feedbackWidgetClosedUntil");
4+
if (closedUntil && new Date().getTime() < parseInt(closedUntil, 10)) {
5+
return; // Don't show widget if closed and timer not expired
6+
}
7+
8+
const container = document.createElement("div");
9+
container.style.position = "fixed";
10+
container.style.bottom = "20px";
11+
container.style.right = "20px";
12+
container.style.background = "#fff";
13+
container.style.border = "1px solid #ddd";
14+
container.style.padding = "10px 15px";
15+
container.style.borderRadius = "8px";
16+
container.style.boxShadow = "0 2px 6px rgba(0,0,0,0.15)";
17+
container.style.zIndex = 9999;
18+
container.style.fontFamily = '"Poppins", "Roboto", Arial, Helvetica, sans-serif';
19+
container.style.textAlign = "center";
20+
container.style.width = "250px";
21+
22+
// Close button
23+
const closeBtn = document.createElement("button");
24+
closeBtn.innerText = "×";
25+
closeBtn.style.position = "absolute";
26+
closeBtn.style.top = "-2px"; // push close button slightly above the container edge
27+
closeBtn.style.right = "-2px"; // push close button slightly outside right edge
28+
closeBtn.style.border = "none";
29+
closeBtn.style.background = "transparent";
30+
closeBtn.style.fontSize = "24px";
31+
closeBtn.style.cursor = "pointer";
32+
closeBtn.style.color = "#999";
33+
closeBtn.style.fontWeight = "bold";
34+
closeBtn.style.lineHeight = "1";
35+
closeBtn.style.padding = "0";
36+
closeBtn.style.width = "30px";
37+
closeBtn.style.height = "30px";
38+
39+
closeBtn.addEventListener("click", () => {
40+
container.style.display = "none";
41+
// Hide for 4 hours
42+
const fourHoursFromNow = new Date().getTime() + 4 * 60 * 60 * 1000;
43+
localStorage.setItem("feedbackWidgetClosedUntil", fourHoursFromNow.toString());
44+
});
45+
46+
container.appendChild(closeBtn);
47+
48+
const title = document.createElement("div");
49+
title.innerText = "Do you like Percona docs?";
50+
title.style.marginBottom = "8px";
51+
title.style.fontSize = "14px";
52+
title.style.fontWeight = "bold";
53+
title.style.color = "#0E5FB5";
54+
title.style.fontFamily = '"Poppins", "Roboto", Arial, Helvetica, sans-serif';
55+
container.appendChild(title);
56+
57+
const stars = document.createElement("div");
58+
stars.style.position = "relative";
59+
60+
for (let i = 1; i <= 5; i++) {
61+
const star = document.createElement("span");
62+
star.innerHTML = "☆";
63+
star.style.fontSize = "24px";
64+
star.style.cursor = "pointer";
65+
star.style.margin = "0 3px";
66+
star.style.color = "#000";
67+
68+
star.addEventListener("mouseover", () => {
69+
[...stars.children].forEach((s, index) => {
70+
s.innerHTML = index < i ? "★" : "☆";
71+
s.style.color = index < i ? "#0E5FB5" : "#000";
72+
});
73+
});
74+
75+
star.addEventListener("mouseleave", () => {
76+
[...stars.children].forEach((s) => {
77+
s.innerHTML = "☆";
78+
s.style.color = "#000";
79+
});
80+
});
81+
82+
star.addEventListener("click", () => {
83+
const formURL = "https://docs.google.com/forms/d/e/1FAIpQLSfhscELpzoXB4uyh9pXNmXSeqKc10IH_DxmAoaVGID85sO0Aw/viewform";
84+
const ratingURL = `${formURL}?entry.303027158=${i}`;
85+
window.open(ratingURL, "_blank");
86+
});
87+
88+
stars.appendChild(star);
89+
}
90+
91+
container.appendChild(stars);
92+
document.body.appendChild(container);
93+
});
94+

mkdocs-base.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ extra_javascript:
7070
- js/version-select.js
7171
- js/promptremover.js
7272
- js/consent.js
73+
- js/feedback.js
7374

7475
markdown_extensions:
7576
attr_list: {}

mkdocs.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ extra:
1414
analytics:
1515
provider: google
1616
property: G-J4J70BNH0G
17-
feedback:
18-
title: Was this page helpful?
19-
ratings:
20-
- icon: material/emoticon-happy-outline
21-
name: This page was helpful
22-
data: 1
23-
note: >-
24-
Thank you for your feedback!
25-
- icon: material/emoticon-sad-outline
26-
name: This page could be improved
27-
data: 0
28-
note: >-
29-
Thanks for your feedback! Want to improve this page? Click <strong>Edit this page on GitHub</strong> above to submit a pull request.
17+
# feedback:
18+
# title: Was this page helpful?
19+
# ratings:
20+
# - icon: material/emoticon-happy-outline
21+
# name: This page was helpful
22+
# data: 1
23+
# note: >-
24+
# Thank you for your feedback!
25+
# - icon: material/emoticon-sad-outline
26+
# name: This page could be improved
27+
# data: 0
28+
# note: >-
29+
# Thanks for your feedback! Want to improve this page? Click <strong>Edit this page on GitHub</strong> above to submit a pull request.
3030

0 commit comments

Comments
 (0)