From 162edf5857b01091a9b97dd228a2749f3e6beef5 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 9 Nov 2023 21:17:45 +0100 Subject: [PATCH] add last id --- web/js/lists.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/web/js/lists.js b/web/js/lists.js index 48081e1..0773f35 100644 --- a/web/js/lists.js +++ b/web/js/lists.js @@ -152,9 +152,19 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo td = trAll[i].querySelectorAll("td"); td[0].querySelector("input").setAttribute("userid", listData[i].id) td[1].textContent = listData[i].id; - td[2].textContent = listData[i].username; - td[3].textContent = listData[i].email; - td[4].textContent = listData[i].roles; + if(pathURL == "users"){ + td[2].textContent = listData[i].username; + td[3].textContent = listData[i].email; + td[4].textContent = listData[i].roles; + last_id = 5; + } + if(pathURL == "events"){ + td[2].textContent = listData[i].name; + td[3].textContent = listData[i].place; + td[4].textContent = listData[i].start_date; + td[5].textContent = listData[i].start_date; + last_id = 6; + } var classTd = ""; switch(listData[i].status){ case 1: @@ -173,12 +183,12 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo classTd = ".unknownStatus" break; } - td[5].querySelector(".activeStatus").classList.add("hidden"); - td[5].querySelector(classTd).classList.remove("hidden"); + td[last_id].querySelector(".activeStatus").classList.add("hidden"); + td[last_id].querySelector(classTd).classList.remove("hidden"); - td[6].querySelector("button").setAttribute("userid", listData[i].id) + td[last_id + 1].querySelector("button").setAttribute("userid", listData[i].id) - td[6].querySelector("button").addEventListener("click", function(e){ + td[last_id + 1].querySelector("button").addEventListener("click", function(e){ var id = e.currentTarget.getAttribute("userid"); location.href="/html/"+pathURL.slice(0, -1)+".html?id="+id; });