2021-05-31 07:17:07 +00:00
|
|
|
function httpGetAsync(url, data, callback) {
|
2021-05-23 07:54:48 +00:00
|
|
|
const xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.onreadystatechange = function () {
|
|
|
|
if (this.readyState === 4) {
|
|
|
|
callback(xmlHttp.responseText, xmlHttp.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlHttp.open("GET", url, true);
|
|
|
|
xmlHttp.setRequestHeader('Authorization', 'Basic ' + sessionStorage.getItem('authorization'));
|
|
|
|
xmlHttp.send(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
function httpPostAsync(url, data, callback) {
|
|
|
|
const xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.onreadystatechange = function () {
|
|
|
|
if (this.readyState === 4) {
|
|
|
|
callback(xmlHttp.responseText, xmlHttp.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlHttp.open("POST", url, true);
|
|
|
|
xmlHttp.setRequestHeader('Authorization', 'Basic ' + sessionStorage.getItem('authorization'));
|
2021-05-31 07:17:07 +00:00
|
|
|
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
2021-06-04 12:05:05 +00:00
|
|
|
xmlHttp.send(data);
|
2021-05-23 07:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function httpDeleteAsync(url, data, callback) {
|
|
|
|
const xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.onreadystatechange = function () {
|
|
|
|
if (this.readyState === 4) {
|
|
|
|
callback(xmlHttp.responseText, xmlHttp.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlHttp.open("DELETE", url, true);
|
|
|
|
xmlHttp.setRequestHeader('Authorization', 'Basic ' + sessionStorage.getItem('authorization'));
|
|
|
|
xmlHttp.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function findGetParameter(parameterName) {
|
|
|
|
let result = null,
|
|
|
|
tmp = [];
|
|
|
|
location.search
|
|
|
|
.substr(1)
|
|
|
|
.split("&")
|
|
|
|
.forEach(function (item) {
|
|
|
|
tmp = item.split("=");
|
|
|
|
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
|
|
|
|
});
|
|
|
|
return result;
|
2021-06-04 12:05:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_random_id() {
|
|
|
|
let s4 = function () {
|
|
|
|
return Math.floor((1 + Math.random()) * 0x10000)
|
|
|
|
.toString(16)
|
|
|
|
.substring(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
2021-05-23 07:54:48 +00:00
|
|
|
}
|