2020-10-13 20:58:20 +00:00
|
|
|
const ratings = document.querySelectorAll('.rating')
|
|
|
|
const ratingsContainer = document.querySelector('.ratings-container')
|
|
|
|
const sendBtn = document.querySelector('#send')
|
|
|
|
const panel = document.querySelector('#panel')
|
|
|
|
let selectedRating = 'Satisfied'
|
|
|
|
|
|
|
|
ratingsContainer.addEventListener('click', (e) => {
|
2022-02-02 08:56:20 +00:00
|
|
|
if(e.target.parentNode.classList.contains('rating') && e.target.nextElementSibling) {
|
2020-10-13 20:58:20 +00:00
|
|
|
removeActive()
|
|
|
|
e.target.parentNode.classList.add('active')
|
|
|
|
selectedRating = e.target.nextElementSibling.innerHTML
|
2022-02-02 08:56:20 +00:00
|
|
|
} else if(
|
|
|
|
e.target.parentNode.classList.contains('rating') &&
|
|
|
|
e.target.previousSibling &&
|
|
|
|
e.target.previousElementSibling.nodeName === 'IMG'
|
|
|
|
) {
|
2021-08-03 19:13:11 +00:00
|
|
|
removeActive()
|
2022-02-02 08:56:20 +00:00
|
|
|
e.target.parentNode.classList.add('active')
|
|
|
|
selectedRating = e.target.innerHTML
|
2021-08-03 19:13:11 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:58:20 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
sendBtn.addEventListener('click', (e) => {
|
|
|
|
panel.innerHTML = `
|
|
|
|
<i class="fas fa-heart"></i>
|
|
|
|
<strong>Thank You!</strong>
|
|
|
|
<br>
|
|
|
|
<strong>Feedback: ${selectedRating}</strong>
|
|
|
|
<p>We'll use your feedback to improve our customer support</p>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
function removeActive() {
|
|
|
|
for(let i = 0; i < ratings.length; i++) {
|
|
|
|
ratings[i].classList.remove('active')
|
|
|
|
}
|
2022-02-02 08:56:20 +00:00
|
|
|
}
|