From 999d3f245710013425cc2413f81d900ec1fc2f24 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sun, 15 Jul 2018 11:21:44 +0300 Subject: big js refactoring --- kvmd/web/js/tools.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 kvmd/web/js/tools.js (limited to 'kvmd/web/js/tools.js') diff --git a/kvmd/web/js/tools.js b/kvmd/web/js/tools.js new file mode 100644 index 00000000..c8d492e2 --- /dev/null +++ b/kvmd/web/js/tools.js @@ -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); }; -- cgit v1.2.3