diff --git a/web/html/addevent.html b/web/html/addevent.html index ca54227..e0178d0 100644 --- a/web/html/addevent.html +++ b/web/html/addevent.html @@ -130,12 +130,12 @@
diff --git a/web/js/addItem.js b/web/js/addItem.js index 859d852..cbbbcbd 100644 --- a/web/js/addItem.js +++ b/web/js/addItem.js @@ -62,7 +62,9 @@ document.getElementById("addUser").addEventListener("click", function(){ "place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value, "start_date": document.getElementById("start_dateUpdateInput").value, "end_date": document.getElementById("end_dateUpdateInput").value, - "organizers":organizers + "organizers":organizers, + "latitude": document.getElementById("placeUpdateInput").getAttribute("data-latitude"), + "longitude": document.getElementById("placeUpdateInput").getAttribute("data-longitude") }; break; default: @@ -80,7 +82,18 @@ document.getElementById("addUser").addEventListener("click", function(){ switch(response.status){ case 201: idAlert="createUser" - var user = document.getElementById("usernameUpdateInput").value; + switch (pathURL){ + case "user": + input = "username"; + break; + case "event": + input = "name"; + break; + default: + input = ""; + break; + } + var user = document.getElementById(input+"UpdateInput").value; if(user.length > 0){ document.getElementById("displayUser").textContent=user; } @@ -95,7 +108,7 @@ document.getElementById("addUser").addEventListener("click", function(){ document.getElementById(idAlert+"Alert").classList.remove("hidden"); }).catch(function(error){ console.log(error); - switch(error.response.status){ + switch(error.status){ case 401: listExist = [ "username", "email" ]; for(var i=0; i { + place.setAttribute("data-latitude", e.result.center[1]); + place.setAttribute("data-longitude", e.result.center[0]); + +}); + +geocoder.on("clear", () => { + place.setAttribute("data-latitude", ""); + place.setAttribute("data-longitude", ""); +}); \ No newline at end of file diff --git a/web/js/item.js b/web/js/item.js index 11d8566..b99bc5f 100644 --- a/web/js/item.js +++ b/web/js/item.js @@ -25,6 +25,8 @@ if(id.length > 0){ switch(listValue[i]){ case "place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value = response.data[listValue[i]]; + document.getElementById("placeUpdateInput").setAttribute("data-latitude", response.data["latitude"]); + document.getElementById("placeUpdateInput").setAttribute("data-longitude", response.data["longitude"]) break; case "organizers": if (response.data[listValue[i]].length > 0 ){ @@ -202,6 +204,8 @@ if(id.length > 0){ "id": document.getElementById("idUpdateInput").value, "name": document.getElementById("nameUpdateInput").value, "place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value, + "latitude": document.getElementById("placeUpdateInput").getAttribute("data-latitude"), + "longitude": document.getElementById("placeUpdateInput").getAttribute("data-longitude"), "start_date": document.getElementById("start_dateUpdateInput").value, "end_date": document.getElementById("end_dateUpdateInput").value, "status": selector["status"],