mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 18:41:54 +08:00
big js refactoring
This commit is contained in:
27
kvmd/web/js/tools.js
Normal file
27
kvmd/web/js/tools.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var tools = new function() {
|
||||
this.makeRequest = function(method, url, callback) {
|
||||
var http = new XMLHttpRequest();
|
||||
http.open(method, url, true)
|
||||
http.onreadystatechange = callback;
|
||||
http.send();
|
||||
return http;
|
||||
};
|
||||
|
||||
this.setButtonBusy = function(el_button, busy) {
|
||||
el_button.disabled = busy;
|
||||
el_button.style.cursor = (busy ? "wait" : "default");
|
||||
};
|
||||
|
||||
var __debug = (new URL(window.location.href)).searchParams.get("debug");
|
||||
|
||||
this.debug = function(...args) {
|
||||
if (__debug) {
|
||||
console.log(...args);
|
||||
}
|
||||
};
|
||||
|
||||
this.info = console.log;
|
||||
this.error = console.error;
|
||||
};
|
||||
|
||||
var $ = function(id) { return document.getElementById(id); };
|
||||
Reference in New Issue
Block a user