-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
27 lines (25 loc) · 1.05 KB
/
script.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
function addRecommendation() {
// Get the message of the new recommendation
let recommendation = document.getElementById("new_recommendation");
// If the user has left a recommendation, display a pop-up
if (recommendation.value != null && recommendation.value.trim() != "") {
console.log("New recommendation added");
//Call showPopup here
showPopup(true);
// Create a new 'recommendation' element and set it's value to the user's message
var element = document.createElement("div");
element.setAttribute("class","recommendation");
element.innerHTML = "\<span\>“\</span\>" + recommendation.value + "\<span\>”\</span\>";
// Add this element to the end of the list of recommendations
document.getElementById("all_recommendations").appendChild(element);
// Reset the value of the textarea
recommendation.value = "";
}
}
function showPopup(bool) {
if (bool) {
document.getElementById('popup').style.visibility = 'visible'
} else {
document.getElementById('popup').style.visibility = 'hidden'
}
}