-
Notifications
You must be signed in to change notification settings - Fork 0
/
album.js
23 lines (23 loc) · 1.05 KB
/
album.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function commenter(eventId) {
if (!connecte) return connexion();
var commentaire = createElement("input", {type:"text", placeholder:"Commentaire"});
var formError = createElement("span", {className:"form-error"});
popup([
commentaire, formError,
createElement("button", {}, "Commenter", {click: function(e) {
if (commentaire.value == "")
return formError.innerText = "Le commentaire ne peut être vide";
sendRequest("POST", "commenter.php", "event="+encodeURIComponent(eventId)+"&commentaire="+encodeURIComponent(commentaire.value)).then(function(reponse) {
if (reponse == "success")
window.location.reload();
else if (reponse == "notlogged")
connexion();
else
formError.innerText = "Une erreur interne est survenue";
}).catch(function(error) {
formError.innerText = "Une erreur ("+error+") est survenue";
})
}})
]);
commentaire.focus();
}