Skip to content

Commit a3b3b23

Browse files
committed
proposals - rating-dialog.djhtml script rendering stars after each question
1 parent 2eeb570 commit a3b3b23

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

srv/templates/proposals/rating-dialog.djhtml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,36 @@
8686
dialog_rating.close()
8787
}
8888
})
89+
90+
proposals.rateRead({{pk}})
91+
92+
const ratings = []
93+
94+
const eDiv_dialogContainer = document.querySelector('.dialog-container')
95+
const eP_question = eDiv_dialogContainer.querySelectorAll('p')
96+
97+
for(let elm of eP_question) {
98+
const eDiv_ratingWrapper = document.createElement('div')
99+
eDiv_ratingWrapper.classList = 'rating-wrapper'
100+
const eDiv_rating = document.createElement('div')
101+
eDiv_rating.classList = 'rating'
102+
103+
eDiv_ratingWrapper.appendChild(eDiv_rating)
104+
105+
for(let i=1; i<=5; i++) {
106+
const eSpan = document.createElement('span')
107+
eSpan.id = `star-${i}`
108+
eSpan.setAttribute('data-value', i)
109+
eSpan.classList = 'rating__star'
110+
eSpan.innerText = '⭐'
111+
112+
eSpan.onclick = function(e) {
113+
changeStar(e, elm)
114+
}
115+
116+
eDiv_rating.appendChild(eSpan)
117+
}
118+
119+
eDiv_dialogContainer.insertBefore(eDiv_ratingWrapper, elm.nextSibling)
120+
}
89121
</script>

0 commit comments

Comments
 (0)