django_coreprotect/static/coreprotect/js/main.js

31 lines
840 B
JavaScript
Raw Normal View History

(function() {
flatpickr('[type="date"]', {
altInput: true,
altFormat: "F j, Y at H:i",
dateFormat: "U",
enableTime: true,
});
})();
function ajax(method, url, callback) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState === XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
callback(xmlhttp.status, xmlhttp.responseText);
}
};
xmlhttp.open(method, url, true);
xmlhttp.send();
}
function formURI(formData) {
let pairs = [];
for (let data of formData.entries()) {
pairs.push(encodeURIComponent(data[0]) + '=' + encodeURIComponent(data[1]))
}
return pairs.join("&").replace(/%20/g, '+');
}
function elementHTML(id, html) {
document.getElementById(id).innerHTML = html
}