summaryrefslogtreecommitdiff
path: root/kvmd/web/js/tools.js
blob: c8d492e2d3b76f74df63b7f81f1b4c9dea90f1ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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); };