mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
web: forced quote-props
This commit is contained in:
parent
2b8cc93362
commit
0f4e736185
@ -22,6 +22,9 @@ rules:
|
|||||||
quotes:
|
quotes:
|
||||||
- error
|
- error
|
||||||
- double
|
- double
|
||||||
|
quote-props:
|
||||||
|
- error
|
||||||
|
- always
|
||||||
semi:
|
semi:
|
||||||
- error
|
- error
|
||||||
- always
|
- always
|
||||||
|
|||||||
@ -219,7 +219,7 @@ export function Hid(__getGeometry, __recorder) {
|
|||||||
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
|
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
|
||||||
let [op_codes, state] = op;
|
let [op_codes, state] = op;
|
||||||
for (let code of op_codes) {
|
for (let code of op_codes) {
|
||||||
raw_events.push({code: code, state: state});
|
raw_events.push({"code": code, "state": state});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -39,12 +39,12 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
var __keypad = null;
|
var __keypad = null;
|
||||||
|
|
||||||
var __timer = null;
|
var __timer = null;
|
||||||
var __planned_pos = {x: 0, y: 0};
|
var __planned_pos = {"x": 0, "y": 0};
|
||||||
var __sent_pos = {x: 0, y: 0};
|
var __sent_pos = {"x": 0, "y": 0};
|
||||||
var __relative_deltas = [];
|
var __relative_deltas = [];
|
||||||
var __relative_touch_pos = null;
|
var __relative_touch_pos = null;
|
||||||
var __relative_sens = 1.0;
|
var __relative_sens = 1.0;
|
||||||
var __wheel_delta = {x: 0, y: 0};
|
var __wheel_delta = {"x": 0, "y": 0};
|
||||||
|
|
||||||
var __stream_hovered = false;
|
var __stream_hovered = false;
|
||||||
|
|
||||||
@ -205,8 +205,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
} else {
|
} else {
|
||||||
let pos = __getTouchPosition(event, 0);
|
let pos = __getTouchPosition(event, 0);
|
||||||
__sendOrPlanRelativeMove({
|
__sendOrPlanRelativeMove({
|
||||||
x: (pos.x - __relative_touch_pos.x),
|
"x": (pos.x - __relative_touch_pos.x),
|
||||||
y: (pos.y - __relative_touch_pos.y),
|
"y": (pos.y - __relative_touch_pos.y),
|
||||||
});
|
});
|
||||||
__relative_touch_pos = pos;
|
__relative_touch_pos = pos;
|
||||||
}
|
}
|
||||||
@ -222,8 +222,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
if (event.touches[index].target && event.touches[index].target.getBoundingClientRect) {
|
if (event.touches[index].target && event.touches[index].target.getBoundingClientRect) {
|
||||||
let rect = event.touches[index].target.getBoundingClientRect();
|
let rect = event.touches[index].target.getBoundingClientRect();
|
||||||
return {
|
return {
|
||||||
x: Math.round(event.touches[index].clientX - rect.left),
|
"x": Math.round(event.touches[index].clientX - rect.left),
|
||||||
y: Math.round(event.touches[index].clientY - rect.top),
|
"y": Math.round(event.touches[index].clientY - rect.top),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -233,13 +233,13 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
if (__absolute) {
|
if (__absolute) {
|
||||||
let rect = event.target.getBoundingClientRect();
|
let rect = event.target.getBoundingClientRect();
|
||||||
__planned_pos = {
|
__planned_pos = {
|
||||||
x: Math.max(Math.round(event.clientX - rect.left), 0),
|
"x": Math.max(Math.round(event.clientX - rect.left), 0),
|
||||||
y: Math.max(Math.round(event.clientY - rect.top), 0),
|
"y": Math.max(Math.round(event.clientY - rect.top), 0),
|
||||||
};
|
};
|
||||||
} else if (__isRelativeCaptured()) {
|
} else if (__isRelativeCaptured()) {
|
||||||
__sendOrPlanRelativeMove({
|
__sendOrPlanRelativeMove({
|
||||||
x: event.movementX,
|
"x": event.movementX,
|
||||||
y: event.movementY,
|
"y": event.movementY,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -254,7 +254,7 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let delta = {x: 0, y: 0};
|
let delta = {"x": 0, "y": 0};
|
||||||
if (tools.browser.is_firefox && !tools.browser.is_mac) {
|
if (tools.browser.is_firefox && !tools.browser.is_mac) {
|
||||||
if (event.deltaX !== 0) {
|
if (event.deltaX !== 0) {
|
||||||
delta.x = event.deltaX / Math.abs(event.deltaX) * (-5);
|
delta.x = event.deltaX / Math.abs(event.deltaX) * (-5);
|
||||||
@ -283,8 +283,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
|
|
||||||
var __sendOrPlanRelativeMove = function(delta) {
|
var __sendOrPlanRelativeMove = function(delta) {
|
||||||
delta = {
|
delta = {
|
||||||
x: Math.min(Math.max(-127, Math.floor(delta.x * __relative_sens)), 127),
|
"x": Math.min(Math.max(-127, Math.floor(delta.x * __relative_sens)), 127),
|
||||||
y: Math.min(Math.max(-127, Math.floor(delta.y * __relative_sens)), 127),
|
"y": Math.min(Math.max(-127, Math.floor(delta.y * __relative_sens)), 127),
|
||||||
};
|
};
|
||||||
if (delta.x || delta.y) {
|
if (delta.x || delta.y) {
|
||||||
if ($("hid-mouse-squash-switch").checked) {
|
if ($("hid-mouse-squash-switch").checked) {
|
||||||
@ -313,8 +313,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
|
|||||||
if (pos.x !== __sent_pos.x || pos.y !== __sent_pos.y) {
|
if (pos.x !== __sent_pos.x || pos.y !== __sent_pos.y) {
|
||||||
let geo = __getGeometry();
|
let geo = __getGeometry();
|
||||||
let to = {
|
let to = {
|
||||||
x: tools.remap(pos.x, geo.x, geo.width, -32768, 32767),
|
"x": tools.remap(pos.x, geo.x, geo.width, -32768, 32767),
|
||||||
y: tools.remap(pos.y, geo.y, geo.height, -32768, 32767),
|
"y": tools.remap(pos.y, geo.y, geo.height, -32768, 32767),
|
||||||
};
|
};
|
||||||
tools.debug("Mouse: moved:", to);
|
tools.debug("Mouse: moved:", to);
|
||||||
__sendEvent("mouse_move", {"to": to});
|
__sendEvent("mouse_move", {"to": to});
|
||||||
|
|||||||
@ -123,10 +123,10 @@ export function Ocr(__getGeometry) {
|
|||||||
let rel_bottom = Math.max(__start_pos.y, __end_pos.y) - rect.top + offset;
|
let rel_bottom = Math.max(__start_pos.y, __end_pos.y) - rect.top + offset;
|
||||||
let geo = __getGeometry();
|
let geo = __getGeometry();
|
||||||
__selection = {
|
__selection = {
|
||||||
left: tools.remap(rel_left, geo.x, geo.width, 0, geo.real_width),
|
"left": tools.remap(rel_left, geo.x, geo.width, 0, geo.real_width),
|
||||||
right: tools.remap(rel_right, geo.x, geo.width, 0, geo.real_width),
|
"right": tools.remap(rel_right, geo.x, geo.width, 0, geo.real_width),
|
||||||
top: tools.remap(rel_top, geo.y, geo.height, 0, geo.real_height),
|
"top": tools.remap(rel_top, geo.y, geo.height, 0, geo.real_height),
|
||||||
bottom: tools.remap(rel_bottom, geo.y, geo.height, 0, geo.real_height),
|
"bottom": tools.remap(rel_bottom, geo.y, geo.height, 0, geo.real_height),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
__selection = null;
|
__selection = null;
|
||||||
@ -140,8 +140,8 @@ export function Ocr(__getGeometry) {
|
|||||||
let geo = __getGeometry();
|
let geo = __getGeometry();
|
||||||
let offset = __getNavbarOffset();
|
let offset = __getNavbarOffset();
|
||||||
return {
|
return {
|
||||||
x: Math.min(Math.max(event.clientX, rect.left + geo.x), rect.right - geo.x),
|
"x": Math.min(Math.max(event.clientX, rect.left + geo.x), rect.right - geo.x),
|
||||||
y: Math.min(Math.max(event.clientY - offset, rect.top + geo.y - offset), rect.bottom - geo.y - offset),
|
"y": Math.min(Math.max(event.clientY - offset, rect.top + geo.y - offset), rect.bottom - geo.y - offset),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -53,10 +53,10 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
let el = $("stream-video");
|
let el = $("stream-video");
|
||||||
return {
|
return {
|
||||||
// Разрешение видео или элемента
|
// Разрешение видео или элемента
|
||||||
real_width: (el.videoWidth || el.offsetWidth),
|
"real_width": (el.videoWidth || el.offsetWidth),
|
||||||
real_height: (el.videoHeight || el.offsetHeight),
|
"real_height": (el.videoHeight || el.offsetHeight),
|
||||||
view_width: el.offsetWidth,
|
"view_width": el.offsetWidth,
|
||||||
view_height: el.offsetHeight,
|
"view_height": el.offsetHeight,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,11 +78,11 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
__ensuring = true;
|
__ensuring = true;
|
||||||
__logInfo("Starting Janus ...");
|
__logInfo("Starting Janus ...");
|
||||||
__janus = new _Janus({
|
__janus = new _Janus({
|
||||||
server: `${tools.is_https ? "wss" : "ws"}://${location.host}/janus/ws`,
|
"server": `${tools.is_https ? "wss" : "ws"}://${location.host}/janus/ws`,
|
||||||
ipv6: true,
|
"ipv6": true,
|
||||||
destroyOnUnload: false,
|
"destroyOnUnload": false,
|
||||||
success: __attachJanus,
|
"success": __attachJanus,
|
||||||
error: function(error) {
|
"error": function(error) {
|
||||||
__logError(error);
|
__logError(error);
|
||||||
__setInfo(false, false, error);
|
__setInfo(false, false, error);
|
||||||
__finishJanus();
|
__finishJanus();
|
||||||
@ -137,22 +137,22 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__janus.attach({
|
__janus.attach({
|
||||||
plugin: "janus.plugin.ustreamer",
|
"plugin": "janus.plugin.ustreamer",
|
||||||
opaqueId: "oid-" + _Janus.randomString(12),
|
"opaqueId": "oid-" + _Janus.randomString(12),
|
||||||
|
|
||||||
success: function(handle) {
|
"success": function(handle) {
|
||||||
__handle = handle;
|
__handle = handle;
|
||||||
__logInfo("uStreamer attached:", handle.getPlugin(), handle.getId());
|
__logInfo("uStreamer attached:", handle.getPlugin(), handle.getId());
|
||||||
__sendWatch();
|
__sendWatch();
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function(error) {
|
"error": function(error) {
|
||||||
__logError("Can't attach uStreamer: ", error);
|
__logError("Can't attach uStreamer: ", error);
|
||||||
__setInfo(false, false, error);
|
__setInfo(false, false, error);
|
||||||
__destroyJanus();
|
__destroyJanus();
|
||||||
},
|
},
|
||||||
|
|
||||||
iceState: function(state) {
|
"iceState": function(state) {
|
||||||
__logInfo("ICE state changed to", state);
|
__logInfo("ICE state changed to", state);
|
||||||
// Если раскомментировать, то он начнет дрючить соединение,
|
// Если раскомментировать, то он начнет дрючить соединение,
|
||||||
// так как каллбек вызывает сильно после завершения работы
|
// так как каллбек вызывает сильно после завершения работы
|
||||||
@ -161,14 +161,14 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
|
|
||||||
webrtcState: function(up) {
|
"webrtcState": function(up) {
|
||||||
__logInfo("Janus says our WebRTC PeerConnection is", (up ? "up" : "down"), "now");
|
__logInfo("Janus says our WebRTC PeerConnection is", (up ? "up" : "down"), "now");
|
||||||
if (up) {
|
if (up) {
|
||||||
__sendKeyRequired();
|
__sendKeyRequired();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onmessage: function(msg, jsep) {
|
"onmessage": function(msg, jsep) {
|
||||||
__stopRetryEmsgInterval();
|
__stopRetryEmsgInterval();
|
||||||
|
|
||||||
if (msg.result) {
|
if (msg.result) {
|
||||||
@ -200,15 +200,15 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
if (jsep) {
|
if (jsep) {
|
||||||
__logInfo("Handling SDP:", jsep);
|
__logInfo("Handling SDP:", jsep);
|
||||||
__handle.createAnswer({
|
__handle.createAnswer({
|
||||||
jsep: jsep,
|
"jsep": jsep,
|
||||||
media: {audioSend: false, videoSend: false, data: false},
|
"media": {"audioSend": false, "videoSend": false, "data": false},
|
||||||
|
|
||||||
success: function(jsep) {
|
"success": function(jsep) {
|
||||||
__logInfo("Got SDP:", jsep);
|
__logInfo("Got SDP:", jsep);
|
||||||
__sendStart(jsep);
|
__sendStart(jsep);
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function(error) {
|
"error": function(error) {
|
||||||
__logInfo("Error on SDP handling:", error);
|
__logInfo("Error on SDP handling:", error);
|
||||||
__setInfo(false, false, error);
|
__setInfo(false, false, error);
|
||||||
//__destroyJanus();
|
//__destroyJanus();
|
||||||
@ -217,7 +217,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onremotestream: function(stream) {
|
"onremotestream": function(stream) {
|
||||||
__logInfo("Got a remote stream:", stream);
|
__logInfo("Got a remote stream:", stream);
|
||||||
__setAudioEnabled(!!stream.getAudioTracks().length);
|
__setAudioEnabled(!!stream.getAudioTracks().length);
|
||||||
_Janus.attachMediaStream($("stream-video"), stream);
|
_Janus.attachMediaStream($("stream-video"), stream);
|
||||||
@ -234,7 +234,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
|
|
||||||
oncleanup: function() {
|
"oncleanup": function() {
|
||||||
__logInfo("Got a cleanup notification");
|
__logInfo("Got a cleanup notification");
|
||||||
__stopInfoInterval();
|
__stopInfoInterval();
|
||||||
},
|
},
|
||||||
@ -293,14 +293,14 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
var __sendWatch = function() {
|
var __sendWatch = function() {
|
||||||
if (__handle) {
|
if (__handle) {
|
||||||
__logInfo("Sending WATCH ...");
|
__logInfo("Sending WATCH ...");
|
||||||
__handle.send({message: {request: "watch"}});
|
__handle.send({"message": {"request": "watch"}});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var __sendStart = function(jsep) {
|
var __sendStart = function(jsep) {
|
||||||
if (__handle) {
|
if (__handle) {
|
||||||
__logInfo("Sending START ...");
|
__logInfo("Sending START ...");
|
||||||
__handle.send({message: {request: "start"}, jsep: jsep});
|
__handle.send({"message": {"request": "start"}, "jsep": jsep});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
__stopInfoInterval();
|
__stopInfoInterval();
|
||||||
if (__handle) {
|
if (__handle) {
|
||||||
__logInfo("Sending STOP ...");
|
__logInfo("Sending STOP ...");
|
||||||
__handle.send({message: {request: "stop"}});
|
__handle.send({"message": {"request": "stop"}});
|
||||||
__handle.hangup();
|
__handle.hangup();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -346,10 +346,10 @@ function _MjpegStreamer(__setActive, __setInactive, __setInfo) {
|
|||||||
self.getResolution = function() {
|
self.getResolution = function() {
|
||||||
let el = $("stream-image");
|
let el = $("stream-image");
|
||||||
return {
|
return {
|
||||||
real_width: el.naturalWidth,
|
"real_width": el.naturalWidth,
|
||||||
real_height: el.naturalHeight,
|
"real_height": el.naturalHeight,
|
||||||
view_width: el.offsetWidth,
|
"view_width": el.offsetWidth,
|
||||||
view_height: el.offsetHeight,
|
"view_height": el.offsetHeight,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ export function Streamer() {
|
|||||||
var __streamer = null;
|
var __streamer = null;
|
||||||
|
|
||||||
var __state = null;
|
var __state = null;
|
||||||
var __resolution = {width: 640, height: 480};
|
var __resolution = {"width": 640, "height": 480};
|
||||||
|
|
||||||
var __init__ = function() {
|
var __init__ = function() {
|
||||||
__streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo);
|
__streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo);
|
||||||
@ -555,8 +555,8 @@ export function Streamer() {
|
|||||||
if (_Janus === null) {
|
if (_Janus === null) {
|
||||||
import("./janus.js").then((module) => {
|
import("./janus.js").then((module) => {
|
||||||
module.Janus.init({
|
module.Janus.init({
|
||||||
debug: "all",
|
"debug": "all",
|
||||||
callback: function() {
|
"callback": function() {
|
||||||
_Janus = module.Janus;
|
_Janus = module.Janus;
|
||||||
set_enabled();
|
set_enabled();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -260,10 +260,10 @@ function __WindowManager() {
|
|||||||
self.getViewGeometry = function() {
|
self.getViewGeometry = function() {
|
||||||
let el_navbar = $("navbar");
|
let el_navbar = $("navbar");
|
||||||
return {
|
return {
|
||||||
top: (el_navbar ? el_navbar.clientHeight : 0), // Navbar height
|
"top": (el_navbar ? el_navbar.clientHeight : 0), // Navbar height
|
||||||
bottom: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
"bottom": Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
|
||||||
left: 0,
|
"left": 0,
|
||||||
right: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
"right": Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ function __WindowManager() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let prev_pos = {x: 0, y: 0};
|
let prev_pos = {"x": 0, "y": 0};
|
||||||
|
|
||||||
function startMoving(event) {
|
function startMoving(event) {
|
||||||
// При перетаскивании resizable-окна за правый кран экрана оно ужимается.
|
// При перетаскивании resizable-окна за правый кран экрана оно ужимается.
|
||||||
@ -535,9 +535,9 @@ function __WindowManager() {
|
|||||||
|
|
||||||
function getEventPosition(event) {
|
function getEventPosition(event) {
|
||||||
if (event.touches) {
|
if (event.touches) {
|
||||||
return {x: event.touches[0].clientX, y: event.touches[0].clientY};
|
return {"x": event.touches[0].clientX, "y": event.touches[0].clientY};
|
||||||
} else {
|
} else {
|
||||||
return {x: event.clientX, y: event.clientY};
|
return {"x": event.clientX, "y": event.clientY};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user