-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (52 loc) · 1.93 KB
/
index.js
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
const iconbtn = document.querySelectorAll(".icon");
const btn = document.getElementById("btn");
const container = document.getElementById("container");
document.getElementById("btn").disabled = true;
let selectedRating = "";
iconbtn.forEach((icon) => {
icon.addEventListener("click", (e) => {
// console.log(e.target);
id = e.target.attributes.id.nodeValue;
if (!id.split("_")[1]) id += "_icon";
// console.log(id);
document.getElementById(id).classList.remove(id + "_anime");
document.getElementById(id).offsetWidth;
document.getElementById(id).classList.add(id + "_anime");
removeActive();
e.target.classList.add("active");
e.target.parentNode.classList.add("active");
// console.log(e.target.innerText || e.target.parentNode.innerText);
selectedRating = e.target.parentNode.innerText.split("\n")[0];
document.getElementById("btn_back").style.display = "block";
document.getElementById("btn").disabled = false;
});
});
function feedback() {
if (selectedRating == "") {
document.querySelector(".error").style.display = "block";
setTimeout(() => {
document.querySelector(".error").style.display = "none";
}, 2000);
return;
}
var flag = true;
document.querySelectorAll(".text").forEach((field) => {
if (field.value.length === 0) flag = false;
});
console.log(flag);
if (flag == false) return;
setTimeout(() => {
container.innerHTML = `<strong>Thank You !</strong>
<strong>Feedback: ${selectedRating}</strong>
<p>We'll use your feedback to improve our customer support.</p>.
<div class="button" onclick="location.reload()"><p>Home</p></div>
`;
container.style.cssText =
" border :2px solid rgb(44, 143, 236); box-shadow: 0px 0px 12px 2px rgba(44, 143, 236,0.5);";
}, 1000);
}
function removeActive() {
iconbtn.forEach((icon) => {
icon.classList.remove("active");
});
}