mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
js logs refactoring
This commit is contained in:
parent
9f2c0dd14e
commit
43bbf725b8
@ -66,7 +66,7 @@ function Hid() {
|
|||||||
|
|
||||||
var __emitShortcut = function(codes) {
|
var __emitShortcut = function(codes) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
tools.debug("Emitting keys:", codes);
|
tools.debug("HID: emitting keys:", codes);
|
||||||
|
|
||||||
var raw_events = [];
|
var raw_events = [];
|
||||||
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
|
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
|
||||||
@ -156,7 +156,7 @@ function Hid() {
|
|||||||
$("hid-pak-led").className = "led-yellow-rotating-fast";
|
$("hid-pak-led").className = "led-yellow-rotating-fast";
|
||||||
$("hid-pak-led").title = "Autotyping...";
|
$("hid-pak-led").title = "Autotyping...";
|
||||||
|
|
||||||
tools.debug("Paste-as-keys:", text);
|
tools.debug("HID: paste-as-keys:", text);
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
var iterate = function() {
|
var iterate = function() {
|
||||||
|
|||||||
@ -173,7 +173,7 @@ function Keyboard() {
|
|||||||
|
|
||||||
var __sendKey = function(el_key, state) {
|
var __sendKey = function(el_key, state) {
|
||||||
var code = el_key.getAttribute("data-key");
|
var code = el_key.getAttribute("data-key");
|
||||||
tools.debug("Key", (state ? "pressed:" : "released:"), code);
|
tools.debug("Keyboard: key", (state ? "pressed:" : "released:"), code);
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.send(JSON.stringify({
|
__ws.send(JSON.stringify({
|
||||||
event_type: "key",
|
event_type: "key",
|
||||||
|
|||||||
@ -96,7 +96,7 @@ function Mouse() {
|
|||||||
|
|
||||||
|
|
||||||
var __sendButton = function(button, state) {
|
var __sendButton = function(button, state) {
|
||||||
tools.debug("Mouse button", (state ? "pressed:" : "released:"), button);
|
tools.debug("Mouse: button", (state ? "pressed:" : "released:"), button);
|
||||||
__sendMove();
|
__sendMove();
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.send(JSON.stringify({
|
__ws.send(JSON.stringify({
|
||||||
@ -115,7 +115,7 @@ function Mouse() {
|
|||||||
x: __translate(pos.x, 0, el_stream_image.clientWidth, -32768, 32767),
|
x: __translate(pos.x, 0, el_stream_image.clientWidth, -32768, 32767),
|
||||||
y: __translate(pos.y, 0, el_stream_image.clientHeight, -32768, 32767),
|
y: __translate(pos.y, 0, el_stream_image.clientHeight, -32768, 32767),
|
||||||
};
|
};
|
||||||
tools.debug("Mouse move:", to);
|
tools.debug("Mouse: moved:", to);
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.send(JSON.stringify({
|
__ws.send(JSON.stringify({
|
||||||
event_type: "mouse_move",
|
event_type: "mouse_move",
|
||||||
@ -145,7 +145,7 @@ function Mouse() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delta.y) {
|
if (delta.y) {
|
||||||
tools.debug("Mouse wheel:", delta);
|
tools.debug("Mouse: scrolled:", delta);
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.send(JSON.stringify({
|
__ws.send(JSON.stringify({
|
||||||
event_type: "mouse_wheel",
|
event_type: "mouse_wheel",
|
||||||
|
|||||||
@ -52,7 +52,7 @@ function Session(atx, hid, msd) {
|
|||||||
var __wsOpenHandler = function(event) {
|
var __wsOpenHandler = function(event) {
|
||||||
$("link-led").className = "led-green";
|
$("link-led").className = "led-green";
|
||||||
$("link-led").title = "Connected";
|
$("link-led").title = "Connected";
|
||||||
tools.debug("WebSocket opened:", event);
|
tools.debug("Session: socket opened:", event);
|
||||||
atx.loadInitialState();
|
atx.loadInitialState();
|
||||||
msd.loadInitialState();
|
msd.loadInitialState();
|
||||||
hid.setSocket(__ws);
|
hid.setSocket(__ws);
|
||||||
@ -61,7 +61,7 @@ function Session(atx, hid, msd) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __wsMessageHandler = function(event) {
|
var __wsMessageHandler = function(event) {
|
||||||
// tools.debug("WebSocket: received data:", event.data);
|
// tools.debug("Session: received socket data:", event.data);
|
||||||
event = JSON.parse(event.data);
|
event = JSON.parse(event.data);
|
||||||
if (event.msg_type === "pong") {
|
if (event.msg_type === "pong") {
|
||||||
__missed_heartbeats = 0;
|
__missed_heartbeats = 0;
|
||||||
@ -75,7 +75,7 @@ function Session(atx, hid, msd) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __wsErrorHandler = function(event) {
|
var __wsErrorHandler = function(event) {
|
||||||
tools.error("WebSocket error:", event);
|
tools.error("Session: socket error:", event);
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.onclose = null;
|
__ws.onclose = null;
|
||||||
__ws.close();
|
__ws.close();
|
||||||
@ -85,7 +85,7 @@ function Session(atx, hid, msd) {
|
|||||||
|
|
||||||
var __wsCloseHandler = function(event) {
|
var __wsCloseHandler = function(event) {
|
||||||
$("link-led").className = "led-gray";
|
$("link-led").className = "led-gray";
|
||||||
tools.debug("WebSocket closed:", event);
|
tools.debug("Session: socket closed:", event);
|
||||||
if (__ping_timer) {
|
if (__ping_timer) {
|
||||||
clearInterval(__ping_timer);
|
clearInterval(__ping_timer);
|
||||||
__ping_timer = null;
|
__ping_timer = null;
|
||||||
@ -107,7 +107,7 @@ function Session(atx, hid, msd) {
|
|||||||
}
|
}
|
||||||
__ws.send(JSON.stringify({"event_type": "ping"}));
|
__ws.send(JSON.stringify({"event_type": "ping"}));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
tools.error("Ping error:", err.message);
|
tools.error("Session: ping error:", err.message);
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
__ws.onclose = null;
|
__ws.onclose = null;
|
||||||
__ws.close();
|
__ws.close();
|
||||||
|
|||||||
@ -51,7 +51,7 @@ function Stream() {
|
|||||||
var response = (http.status === 200 ? JSON.parse(http.responseText) : null);
|
var response = (http.status === 200 ? JSON.parse(http.responseText) : null);
|
||||||
|
|
||||||
if (http.status !== 200) {
|
if (http.status !== 200) {
|
||||||
tools.info("Refreshing stream ...");
|
tools.info("Stream: refreshing ...");
|
||||||
$("stream-image").className = "stream-image-inactive";
|
$("stream-image").className = "stream-image-inactive";
|
||||||
$("stream-box").classList.add("stream-box-inactive");
|
$("stream-box").classList.add("stream-box-inactive");
|
||||||
$("stream-led").className = "led-gray";
|
$("stream-led").className = "led-gray";
|
||||||
@ -101,11 +101,11 @@ function Stream() {
|
|||||||
var path = "/streamer/stream?t=" + new Date().getTime();
|
var path = "/streamer/stream?t=" + new Date().getTime();
|
||||||
if (tools.browser.is_chrome || tools.browser.is_blink) {
|
if (tools.browser.is_chrome || tools.browser.is_blink) {
|
||||||
// uStreamer fix for Blink https://bugs.chromium.org/p/chromium/issues/detail?id=527446
|
// uStreamer fix for Blink https://bugs.chromium.org/p/chromium/issues/detail?id=527446
|
||||||
tools.info("Stream: using advance_headers=1");
|
tools.info("Stream: using advance_headers=1 to fix Blink MJPG bugs");
|
||||||
path += "&advance_headers=1";
|
path += "&advance_headers=1";
|
||||||
} else if (tools.browser.is_safari || tools.browser.is_ios) {
|
} else if (tools.browser.is_safari || tools.browser.is_ios) {
|
||||||
// uStreamer fix for WebKit
|
// uStreamer fix for WebKit
|
||||||
tools.info("Stream: using dual_final_frames=1");
|
tools.info("Stream: using dual_final_frames=1 to fix WebKit MJPG bugs");
|
||||||
path += "&dual_final_frames=1";
|
path += "&dual_final_frames=1";
|
||||||
}
|
}
|
||||||
$("stream-image").src = path;
|
$("stream-image").src = path;
|
||||||
@ -118,7 +118,7 @@ function Stream() {
|
|||||||
$("stream-soft-fps-slider").disabled = false;
|
$("stream-soft-fps-slider").disabled = false;
|
||||||
$("stream-reset-button").disabled = false;
|
$("stream-reset-button").disabled = false;
|
||||||
__prev_state = true;
|
__prev_state = true;
|
||||||
tools.info("Stream acquired");
|
tools.info("Stream: acquired");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ function Stream() {
|
|||||||
var view = ui.getViewGeometry();
|
var view = ui.getViewGeometry();
|
||||||
|
|
||||||
for (var size = 100; size >= el_slider.min; size -= el_slider.step) {
|
for (var size = 100; size >= el_slider.min; size -= el_slider.step) {
|
||||||
tools.info("Adjusting size:", size);
|
tools.info("Stream: adjusting size:", size);
|
||||||
$("stream-size-slider").value = size;
|
$("stream-size-slider").value = size;
|
||||||
__resize(true);
|
__resize(true);
|
||||||
|
|
||||||
|
|||||||
@ -306,12 +306,12 @@ function Ui() {
|
|||||||
var el_to_focus = (el_window.className === "modal" ? el_window.querySelector(".modal-window") : el_window);
|
var el_to_focus = (el_window.className === "modal" ? el_window.querySelector(".modal-window") : el_window);
|
||||||
if (document.activeElement !== el_to_focus) {
|
if (document.activeElement !== el_to_focus) {
|
||||||
el_to_focus.focus();
|
el_to_focus.focus();
|
||||||
tools.debug("Focused window:", el_window);
|
tools.debug("UI: focused window:", el_window);
|
||||||
if (el_window.className !== "modal" && parseInt(el_window.style.zIndex) !== __top_z_index) {
|
if (el_window.className !== "modal" && parseInt(el_window.style.zIndex) !== __top_z_index) {
|
||||||
var z_index = __top_z_index + 1;
|
var z_index = __top_z_index + 1;
|
||||||
el_window.style.zIndex = z_index;
|
el_window.style.zIndex = z_index;
|
||||||
__top_z_index = z_index;
|
__top_z_index = z_index;
|
||||||
tools.debug("Raised window:", el_window);
|
tools.debug("UI: raised window:", el_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user