function httpGetAsync(url, callback) { const xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState === 4) { try { callback(JSON.parse(xmlHttp.responseText), xmlHttp.status); } catch( e ) { callback({}, 500); } } } xmlHttp.open("GET", url, true); // true for asynchronous xmlHttp.send(null); } function httpPostAsync(url, data, callback) { const xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState === 4) try { callback(JSON.parse(xmlHttp.responseText), xmlHttp.status); } catch( e ) { callback({}, 500); } } xmlHttp.open("POST", url, true); // true for asynchronous xmlHttp.setRequestHeader("Content-Type", "application/json"); xmlHttp.send(JSON.stringify(data)); } const modal = document.getElementById("myModal"); const modal_title = document.getElementById("modal-title"); const modal_text = document.getElementById("modal-text"); let last_add = 0; // Get the element that closes the modal const modal_span = document.getElementsByClassName("close")[0]; // When the user clicks on (x), close the modal modal_span.onclick = function() { modal.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target === modal) { modal.style.display = "none"; } } function openModal(title,text) { modal_title.innerText = title; modal_text.innerHTML = text; modal.style.display = "block" }