var requestsDiv = document.getElementById("requests"); function getRequests(count,allRequests) { var reqUrl; if (allRequests) { reqUrl = "/api/getAllRequests"; } else { reqUrl = "/api/getRequests"; } reqUrl += `?count=${count}`; fetch(reqUrl) .then(response => response.json()) .then(requests => buildTable(requests,allRequests)); } function buildTable(requests,allRequests) { var requestsDivHTML = ''; if (allRequests) requestsDivHTML += ``; requestsDivHTML += ""; for (request of requests) { requestsDivHTML += `\ \ `; if (allRequests) requestsDivHTML += ``; requestsDivHTML += ""; } requestsDivHTML += "
URLRequesterScoreState
${request.url}${request.requester}${request.score}${request.state}
"; requestsDiv.innerHTML = requestsDivHTML; } function updateTable() { var count = document.getElementById("count").value; var allRequests = document.getElementById("allRequests").checked; getRequests(count,allRequests); } function openAddRequestModal() { document.getElementById("addRequestModalBackground").style.display = "flex"; } function closeAddRequestModal() { document.getElementById("addRequestModalBackground").style.display = "none"; } updateTable();