mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
refactoring
This commit is contained in:
parent
1d48ba0a5a
commit
71e5e4d138
@ -51,8 +51,7 @@ function __setAppText() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __loadKvmdInfo() {
|
function __loadKvmdInfo() {
|
||||||
let http = tools.makeRequest("GET", "/api/info?fields=auth,meta,extras", function() {
|
tools.httpGet("/api/info?fields=auth,meta,extras", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
let info = JSON.parse(http.responseText).result;
|
let info = JSON.parse(http.responseText).result;
|
||||||
|
|
||||||
@ -105,7 +104,6 @@ function __loadKvmdInfo() {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(__loadKvmdInfo, 1000);
|
setTimeout(__loadKvmdInfo, 1000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,13 +121,11 @@ function __makeApp(id, path, icon, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __logout() {
|
function __logout() {
|
||||||
let http = tools.makeRequest("POST", "/api/auth/logout", function() {
|
tools.httpPost("/api/auth/logout", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200 || http.status === 401 || http.status === 403) {
|
if (http.status === 200 || http.status === 401 || http.status === 403) {
|
||||||
document.location.href = "/login";
|
document.location.href = "/login";
|
||||||
} else {
|
} else {
|
||||||
wm.error("Logout error:<br>", http.responseText);
|
wm.error("Logout error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,7 @@ export function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __loadKvmdInfo() {
|
function __loadKvmdInfo() {
|
||||||
let http = tools.makeRequest("GET", "/api/info", function() {
|
tools.httpGet("/api/info", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
let ipmi_port = JSON.parse(http.responseText).result.extras.ipmi.port;
|
let ipmi_port = JSON.parse(http.responseText).result.extras.ipmi.port;
|
||||||
let make_item = (comment, ipmi, api) => `
|
let make_item = (comment, ipmi, api) => `
|
||||||
@ -57,6 +56,5 @@ function __loadKvmdInfo() {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(__loadKvmdInfo, 1000);
|
setTimeout(__loadKvmdInfo, 1000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,14 +73,12 @@ export function Atx(__recorder) {
|
|||||||
|
|
||||||
var __clickButton = function(button, confirm_msg) {
|
var __clickButton = function(button, confirm_msg) {
|
||||||
let click_button = function() {
|
let click_button = function() {
|
||||||
let http = tools.makeRequest("POST", `/api/atx/click?button=${button}`, function() {
|
tools.httpPost(`/api/atx/click?button=${button}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 409) {
|
if (http.status === 409) {
|
||||||
wm.error("Performing another ATX operation for other client.<br>Please try again later");
|
wm.error("Performing another ATX operation for other client.<br>Please try again later");
|
||||||
} else if (http.status !== 200) {
|
} else if (http.status !== 200) {
|
||||||
wm.error("Click error:<br>", http.responseText);
|
wm.error("Click error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
__recorder.recordAtxButtonEvent(button);
|
__recorder.recordAtxButtonEvent(button);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -209,14 +209,12 @@ export function Gpio(__recorder) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __sendPost = function(url) {
|
var __sendPost = function(url) {
|
||||||
let http = tools.makeRequest("POST", url, function() {
|
tools.httpPost(url, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 409) {
|
if (http.status === 409) {
|
||||||
wm.error("Performing another operation for this GPIO channel.<br>Please try again later");
|
wm.error("Performing another operation for this GPIO channel.<br>Please try again later");
|
||||||
} else if (http.status !== 200) {
|
} else if (http.status !== 200) {
|
||||||
wm.error("GPIO error:<br>", http.responseText);
|
wm.error("GPIO error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,8 +253,7 @@ export function Hid(__getGeometry, __recorder) {
|
|||||||
|
|
||||||
tools.debug(`HID: paste-as-keys ${keymap}: ${text}`);
|
tools.debug(`HID: paste-as-keys ${keymap}: ${text}`);
|
||||||
|
|
||||||
let http = tools.makeRequest("POST", `/api/hid/print?limit=0&keymap=${keymap}`, function() {
|
tools.httpPost(`/api/hid/print?limit=0&keymap=${keymap}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
tools.el.setEnabled($("hid-pak-text"), true);
|
tools.el.setEnabled($("hid-pak-text"), true);
|
||||||
tools.el.setEnabled($("hid-pak-button"), true);
|
tools.el.setEnabled($("hid-pak-button"), true);
|
||||||
tools.el.setEnabled($("hid-pak-keymap-selector"), true);
|
tools.el.setEnabled($("hid-pak-keymap-selector"), true);
|
||||||
@ -266,7 +265,6 @@ export function Hid(__getGeometry, __recorder) {
|
|||||||
} else if (http.status === 200) {
|
} else if (http.status === 200) {
|
||||||
__recorder.recordPrintEvent(text);
|
__recorder.recordPrintEvent(text);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, text, "text/plain");
|
}, text, "text/plain");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -288,46 +286,38 @@ export function Hid(__getGeometry, __recorder) {
|
|||||||
|
|
||||||
var __clickOutputsRadio = function(hid) {
|
var __clickOutputsRadio = function(hid) {
|
||||||
let output = tools.radio.getValue(`hid-outputs-${hid}-radio`);
|
let output = tools.radio.getValue(`hid-outputs-${hid}-radio`);
|
||||||
let http = tools.makeRequest("POST", `/api/hid/set_params?${hid}_output=${output}`, function() {
|
tools.httpPost(`/api/hid/set_params?${hid}_output=${output}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Can't configure HID:<br>", http.responseText);
|
wm.error("Can't configure HID:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __clickJigglerSwitch = function() {
|
var __clickJigglerSwitch = function() {
|
||||||
let enabled = $("hid-jiggler-switch").checked;
|
let enabled = $("hid-jiggler-switch").checked;
|
||||||
let http = tools.makeRequest("POST", `/api/hid/set_params?jiggler=${enabled}`, function() {
|
tools.httpPost(`/api/hid/set_params?jiggler=${enabled}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error(`Can't ${enabled ? "enabled" : "disable"} mouse juggler:<br>`, http.responseText);
|
wm.error(`Can't ${enabled ? "enabled" : "disable"} mouse juggler:<br>`, http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __clickConnectSwitch = function() {
|
var __clickConnectSwitch = function() {
|
||||||
let connected = $("hid-connect-switch").checked;
|
let connected = $("hid-connect-switch").checked;
|
||||||
let http = tools.makeRequest("POST", `/api/hid/set_connected?connected=${connected}`, function() {
|
tools.httpPost(`/api/hid/set_connected?connected=${connected}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error(`Can't ${connected ? "connect" : "disconnect"} HID:<br>`, http.responseText);
|
wm.error(`Can't ${connected ? "connect" : "disconnect"} HID:<br>`, http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __clickResetButton = function() {
|
var __clickResetButton = function() {
|
||||||
wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) {
|
wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
let http = tools.makeRequest("POST", "/api/hid/reset", function() {
|
tools.httpPost("/api/hid/reset", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("HID reset error:<br>", http.responseText);
|
wm.error("HID reset error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -88,24 +88,20 @@ export function Msd() {
|
|||||||
let name = $("msd-image-selector").value;
|
let name = $("msd-image-selector").value;
|
||||||
wm.confirm(`Are you sure you want to remove the image<br><b>${name}</b> from PiKVM?`).then(function(ok) {
|
wm.confirm(`Are you sure you want to remove the image<br><b>${name}</b> from PiKVM?`).then(function(ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
let http = tools.makeRequest("POST", `/api/msd/remove?image=${name}`, function() {
|
tools.httpPost(`/api/msd/remove?image=${name}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Can't remove image:<br>", http.responseText);
|
wm.error("Can't remove image:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __sendParam = function(name, value) {
|
var __sendParam = function(name, value) {
|
||||||
let http = tools.makeRequest("POST", `/api/msd/set_params?${name}=${encodeURIComponent(value)}`, function() {
|
tools.httpPost(`/api/msd/set_params?${name}=${encodeURIComponent(value)}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Can't configure MSD:<br>", http.responseText);
|
wm.error("Can't configure MSD:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,12 +164,10 @@ export function Msd() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __clickConnectButton = function(connected) {
|
var __clickConnectButton = function(connected) {
|
||||||
let http = tools.makeRequest("POST", `/api/msd/set_connected?connected=${connected}`, function() {
|
tools.httpPost(`/api/msd/set_connected?connected=${connected}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Switch error:<br>", http.responseText);
|
wm.error("Switch error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
__applyState();
|
__applyState();
|
||||||
});
|
});
|
||||||
__applyState();
|
__applyState();
|
||||||
@ -183,12 +177,10 @@ export function Msd() {
|
|||||||
var __clickResetButton = function() {
|
var __clickResetButton = function() {
|
||||||
wm.confirm("Are you sure you want to reset Mass Storage Drive?").then(function(ok) {
|
wm.confirm("Are you sure you want to reset Mass Storage Drive?").then(function(ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
let http = tools.makeRequest("POST", "/api/msd/reset", function() {
|
tools.httpPost("/api/msd/reset", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("MSD reset error:<br>", http.responseText);
|
wm.error("MSD reset error:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
__applyState();
|
__applyState();
|
||||||
});
|
});
|
||||||
__applyState();
|
__applyState();
|
||||||
|
|||||||
@ -167,8 +167,7 @@ export function Ocr(__getGeometry) {
|
|||||||
url += `&ocr_left=${__selection.left}&ocr_top=${__selection.top}`;
|
url += `&ocr_left=${__selection.left}&ocr_top=${__selection.top}`;
|
||||||
url += `&ocr_right=${__selection.right}&ocr_bottom=${__selection.bottom}`;
|
url += `&ocr_right=${__selection.right}&ocr_bottom=${__selection.bottom}`;
|
||||||
|
|
||||||
let http = tools.makeRequest("GET", url, function() {
|
tools.httpGet(url, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
wm.copyTextToClipboard(http.responseText);
|
wm.copyTextToClipboard(http.responseText);
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +176,6 @@ export function Ocr(__getGeometry) {
|
|||||||
tools.el.setEnabled($("stream-ocr-button"), true);
|
tools.el.setEnabled($("stream-ocr-button"), true);
|
||||||
tools.el.setEnabled($("stream-ocr-lang-selector"), true);
|
tools.el.setEnabled($("stream-ocr-lang-selector"), true);
|
||||||
$("stream-ocr-led").className = "led-gray";
|
$("stream-ocr-led").className = "led-gray";
|
||||||
}
|
|
||||||
}, null, null, 30000);
|
}, null, null, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -280,8 +280,7 @@ export function Recorder() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (event.event_type === "print") {
|
} else if (event.event_type === "print") {
|
||||||
let http = tools.makeRequest("POST", "/api/hid/print?limit=0", function() {
|
tools.httpPost("/api/hid/print?limit=0", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 413) {
|
if (http.status === 413) {
|
||||||
wm.error("Too many text for paste!");
|
wm.error("Too many text for paste!");
|
||||||
__stopProcess();
|
__stopProcess();
|
||||||
@ -291,20 +290,17 @@ export function Recorder() {
|
|||||||
} else if (http.status === 200) {
|
} else if (http.status === 200) {
|
||||||
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, event.event.text, "text/plain");
|
}, event.event.text, "text/plain");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (event.event_type === "atx_button") {
|
} else if (event.event_type === "atx_button") {
|
||||||
let http = tools.makeRequest("POST", `/api/atx/click?button=${event.event.button}`, function() {
|
tools.httpPost(`/api/atx/click?button=${event.event.button}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("ATX error:<br>", http.responseText);
|
wm.error("ATX error:<br>", http.responseText);
|
||||||
__stopProcess();
|
__stopProcess();
|
||||||
} else if (http.status === 200) {
|
} else if (http.status === 200) {
|
||||||
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -315,15 +311,13 @@ export function Recorder() {
|
|||||||
} else { // gpio_pulse
|
} else { // gpio_pulse
|
||||||
path += `/pulse?channel=${event.event.channel}`;
|
path += `/pulse?channel=${event.event.channel}`;
|
||||||
}
|
}
|
||||||
let http = tools.makeRequest("POST", path, function() {
|
tools.httpPost(path, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("GPIO error:<br>", http.responseText);
|
wm.error("GPIO error:<br>", http.responseText);
|
||||||
__stopProcess();
|
__stopProcess();
|
||||||
} else if (http.status === 200) {
|
} else if (http.status === 200) {
|
||||||
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
__play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -275,8 +275,7 @@ export function Session() {
|
|||||||
$("link-led").className = "led-yellow";
|
$("link-led").className = "led-yellow";
|
||||||
$("link-led").title = "Connecting...";
|
$("link-led").title = "Connecting...";
|
||||||
|
|
||||||
let http = tools.makeRequest("GET", "/api/auth/check", function() {
|
tools.httpGet("/api/auth/check", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
__ws = new WebSocket(`${tools.is_https ? "wss" : "ws"}://${location.host}/api/ws`);
|
__ws = new WebSocket(`${tools.is_https ? "wss" : "ws"}://${location.host}/api/ws`);
|
||||||
__ws.sendHidEvent = (event) => __sendHidEvent(__ws, event.event_type, event.event);
|
__ws.sendHidEvent = (event) => __sendHidEvent(__ws, event.event_type, event.event);
|
||||||
@ -292,7 +291,6 @@ export function Session() {
|
|||||||
} else {
|
} else {
|
||||||
__wsCloseHandler(null);
|
__wsCloseHandler(null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -295,24 +295,20 @@ export function Streamer() {
|
|||||||
wm.confirm("Are you sure you want to reset stream?").then(function (ok) {
|
wm.confirm("Are you sure you want to reset stream?").then(function (ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
__resetStream();
|
__resetStream();
|
||||||
let http = tools.makeRequest("POST", "/api/streamer/reset", function() {
|
tools.httpPost("/api/streamer/reset", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Can't reset stream:<br>", http.responseText);
|
wm.error("Can't reset stream:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var __sendParam = function(name, value) {
|
var __sendParam = function(name, value) {
|
||||||
let http = tools.makeRequest("POST", `/api/streamer/set_params?${name}=${value}`, function() {
|
tools.httpPost(`/api/streamer/set_params?${name}=${value}`, function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
wm.error("Can't configure stream:<br>", http.responseText);
|
wm.error("Can't configure stream:<br>", http.responseText);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,7 @@ function __login() {
|
|||||||
} else {
|
} else {
|
||||||
let passwd = $("passwd-input").value + $("code-input").value;
|
let passwd = $("passwd-input").value + $("code-input").value;
|
||||||
let body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
|
let body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
|
||||||
let http = tools.makeRequest("POST", "/api/auth/login", function() {
|
tools.httpPost("/api/auth/login", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
document.location.href = "/";
|
document.location.href = "/";
|
||||||
} else if (http.status === 403) {
|
} else if (http.status === 403) {
|
||||||
@ -68,7 +67,6 @@ function __login() {
|
|||||||
wm.error("Login error:<br>", http.responseText).then(__tryAgain);
|
wm.error("Login error:<br>", http.responseText).then(__tryAgain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, body, "application/x-www-form-urlencoded");
|
}, body, "application/x-www-form-urlencoded");
|
||||||
__setEnabled(false);
|
__setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,16 +39,27 @@ export var tools = new function() {
|
|||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
self.makeRequest = function(method, url, callback, body=null, content_type=null, timeout=15000) {
|
self.httpRequest = function(method, url, callback, body=null, content_type=null, timeout=15000) {
|
||||||
let http = new XMLHttpRequest();
|
let http = new XMLHttpRequest();
|
||||||
http.open(method, url, true);
|
http.open(method, url, true);
|
||||||
if (content_type) {
|
if (content_type) {
|
||||||
http.setRequestHeader("Content-Type", content_type);
|
http.setRequestHeader("Content-Type", content_type);
|
||||||
}
|
}
|
||||||
http.onreadystatechange = callback;
|
http.onreadystatechange = function() {
|
||||||
|
if (http.readyState === 4) {
|
||||||
|
callback(http);
|
||||||
|
}
|
||||||
|
};
|
||||||
http.timeout = timeout;
|
http.timeout = timeout;
|
||||||
http.send(body);
|
http.send(body);
|
||||||
return http;
|
};
|
||||||
|
|
||||||
|
self.httpGet = function(url, callback, body=null, content_type=null, timeout=15000) {
|
||||||
|
self.httpRequest("GET", url, callback, body, content_type, timeout);
|
||||||
|
};
|
||||||
|
|
||||||
|
self.httpPost = function(url, callback, body=null, content_type=null, timeout=15000) {
|
||||||
|
self.httpRequest("POST", url, callback, body, content_type, timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -31,8 +31,7 @@ export function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __loadKvmdInfo() {
|
function __loadKvmdInfo() {
|
||||||
let http = tools.makeRequest("GET", "/api/info", function() {
|
tools.httpGet("/api/info", function(http) {
|
||||||
if (http.readyState === 4) {
|
|
||||||
if (http.status === 200) {
|
if (http.status === 200) {
|
||||||
let vnc_port = JSON.parse(http.responseText).result.extras.vnc.port;
|
let vnc_port = JSON.parse(http.responseText).result.extras.vnc.port;
|
||||||
$("vnc-text").innerHTML = `
|
$("vnc-text").innerHTML = `
|
||||||
@ -44,6 +43,5 @@ function __loadKvmdInfo() {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(__loadKvmdInfo, 1000);
|
setTimeout(__loadKvmdInfo, 1000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user