web: forced quote-props

This commit is contained in:
Maxim Devaev 2022-11-18 02:58:55 +03:00
parent 2b8cc93362
commit 0f4e736185
6 changed files with 65 additions and 62 deletions

View File

@ -22,6 +22,9 @@ rules:
quotes:
- error
- double
quote-props:
- error
- always
semi:
- error
- always

View File

@ -219,7 +219,7 @@ export function Hid(__getGeometry, __recorder) {
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
let [op_codes, state] = op;
for (let code of op_codes) {
raw_events.push({code: code, state: state});
raw_events.push({"code": code, "state": state});
}
});

View File

@ -39,12 +39,12 @@ export function Mouse(__getGeometry, __recordWsEvent) {
var __keypad = null;
var __timer = null;
var __planned_pos = {x: 0, y: 0};
var __sent_pos = {x: 0, y: 0};
var __planned_pos = {"x": 0, "y": 0};
var __sent_pos = {"x": 0, "y": 0};
var __relative_deltas = [];
var __relative_touch_pos = null;
var __relative_sens = 1.0;
var __wheel_delta = {x: 0, y: 0};
var __wheel_delta = {"x": 0, "y": 0};
var __stream_hovered = false;
@ -205,8 +205,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
} else {
let pos = __getTouchPosition(event, 0);
__sendOrPlanRelativeMove({
x: (pos.x - __relative_touch_pos.x),
y: (pos.y - __relative_touch_pos.y),
"x": (pos.x - __relative_touch_pos.x),
"y": (pos.y - __relative_touch_pos.y),
});
__relative_touch_pos = pos;
}
@ -222,8 +222,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
if (event.touches[index].target && event.touches[index].target.getBoundingClientRect) {
let rect = event.touches[index].target.getBoundingClientRect();
return {
x: Math.round(event.touches[index].clientX - rect.left),
y: Math.round(event.touches[index].clientY - rect.top),
"x": Math.round(event.touches[index].clientX - rect.left),
"y": Math.round(event.touches[index].clientY - rect.top),
};
}
return null;
@ -233,13 +233,13 @@ export function Mouse(__getGeometry, __recordWsEvent) {
if (__absolute) {
let rect = event.target.getBoundingClientRect();
__planned_pos = {
x: Math.max(Math.round(event.clientX - rect.left), 0),
y: Math.max(Math.round(event.clientY - rect.top), 0),
"x": Math.max(Math.round(event.clientX - rect.left), 0),
"y": Math.max(Math.round(event.clientY - rect.top), 0),
};
} else if (__isRelativeCaptured()) {
__sendOrPlanRelativeMove({
x: event.movementX,
y: event.movementY,
"x": event.movementX,
"y": event.movementY,
});
}
};
@ -254,7 +254,7 @@ export function Mouse(__getGeometry, __recordWsEvent) {
return;
}
let delta = {x: 0, y: 0};
let delta = {"x": 0, "y": 0};
if (tools.browser.is_firefox && !tools.browser.is_mac) {
if (event.deltaX !== 0) {
delta.x = event.deltaX / Math.abs(event.deltaX) * (-5);
@ -283,8 +283,8 @@ export function Mouse(__getGeometry, __recordWsEvent) {
var __sendOrPlanRelativeMove = function(delta) {
delta = {
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),
"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),
};
if (delta.x || delta.y) {
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) {
let geo = __getGeometry();
let to = {
x: tools.remap(pos.x, geo.x, geo.width, -32768, 32767),
y: tools.remap(pos.y, geo.y, geo.height, -32768, 32767),
"x": tools.remap(pos.x, geo.x, geo.width, -32768, 32767),
"y": tools.remap(pos.y, geo.y, geo.height, -32768, 32767),
};
tools.debug("Mouse: moved:", to);
__sendEvent("mouse_move", {"to": to});

View File

@ -123,10 +123,10 @@ export function Ocr(__getGeometry) {
let rel_bottom = Math.max(__start_pos.y, __end_pos.y) - rect.top + offset;
let geo = __getGeometry();
__selection = {
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),
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),
"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),
"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),
};
} else {
__selection = null;
@ -140,8 +140,8 @@ export function Ocr(__getGeometry) {
let geo = __getGeometry();
let offset = __getNavbarOffset();
return {
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),
"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),
};
};

View File

@ -53,10 +53,10 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
let el = $("stream-video");
return {
// Разрешение видео или элемента
real_width: (el.videoWidth || el.offsetWidth),
real_height: (el.videoHeight || el.offsetHeight),
view_width: el.offsetWidth,
view_height: el.offsetHeight,
"real_width": (el.videoWidth || el.offsetWidth),
"real_height": (el.videoHeight || el.offsetHeight),
"view_width": el.offsetWidth,
"view_height": el.offsetHeight,
};
};
@ -78,11 +78,11 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
__ensuring = true;
__logInfo("Starting Janus ...");
__janus = new _Janus({
server: `${tools.is_https ? "wss" : "ws"}://${location.host}/janus/ws`,
ipv6: true,
destroyOnUnload: false,
success: __attachJanus,
error: function(error) {
"server": `${tools.is_https ? "wss" : "ws"}://${location.host}/janus/ws`,
"ipv6": true,
"destroyOnUnload": false,
"success": __attachJanus,
"error": function(error) {
__logError(error);
__setInfo(false, false, error);
__finishJanus();
@ -137,22 +137,22 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
return;
}
__janus.attach({
plugin: "janus.plugin.ustreamer",
opaqueId: "oid-" + _Janus.randomString(12),
"plugin": "janus.plugin.ustreamer",
"opaqueId": "oid-" + _Janus.randomString(12),
success: function(handle) {
"success": function(handle) {
__handle = handle;
__logInfo("uStreamer attached:", handle.getPlugin(), handle.getId());
__sendWatch();
},
error: function(error) {
"error": function(error) {
__logError("Can't attach uStreamer: ", error);
__setInfo(false, false, error);
__destroyJanus();
},
iceState: function(state) {
"iceState": function(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");
if (up) {
__sendKeyRequired();
}
},
onmessage: function(msg, jsep) {
"onmessage": function(msg, jsep) {
__stopRetryEmsgInterval();
if (msg.result) {
@ -200,15 +200,15 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
if (jsep) {
__logInfo("Handling SDP:", jsep);
__handle.createAnswer({
jsep: jsep,
media: {audioSend: false, videoSend: false, data: false},
"jsep": jsep,
"media": {"audioSend": false, "videoSend": false, "data": false},
success: function(jsep) {
"success": function(jsep) {
__logInfo("Got SDP:", jsep);
__sendStart(jsep);
},
error: function(error) {
"error": function(error) {
__logInfo("Error on SDP handling:", error);
__setInfo(false, false, error);
//__destroyJanus();
@ -217,7 +217,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
}
},
onremotestream: function(stream) {
"onremotestream": function(stream) {
__logInfo("Got a remote stream:", stream);
__setAudioEnabled(!!stream.getAudioTracks().length);
_Janus.attachMediaStream($("stream-video"), stream);
@ -234,7 +234,7 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
}*/
},
oncleanup: function() {
"oncleanup": function() {
__logInfo("Got a cleanup notification");
__stopInfoInterval();
},
@ -293,14 +293,14 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) {
var __sendWatch = function() {
if (__handle) {
__logInfo("Sending WATCH ...");
__handle.send({message: {request: "watch"}});
__handle.send({"message": {"request": "watch"}});
}
};
var __sendStart = function(jsep) {
if (__handle) {
__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();
if (__handle) {
__logInfo("Sending STOP ...");
__handle.send({message: {request: "stop"}});
__handle.send({"message": {"request": "stop"}});
__handle.hangup();
}
};
@ -346,10 +346,10 @@ function _MjpegStreamer(__setActive, __setInactive, __setInfo) {
self.getResolution = function() {
let el = $("stream-image");
return {
real_width: el.naturalWidth,
real_height: el.naturalHeight,
view_width: el.offsetWidth,
view_height: el.offsetHeight,
"real_width": el.naturalWidth,
"real_height": el.naturalHeight,
"view_width": el.offsetWidth,
"view_height": el.offsetHeight,
};
};
@ -465,7 +465,7 @@ export function Streamer() {
var __streamer = null;
var __state = null;
var __resolution = {width: 640, height: 480};
var __resolution = {"width": 640, "height": 480};
var __init__ = function() {
__streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo);
@ -555,8 +555,8 @@ export function Streamer() {
if (_Janus === null) {
import("./janus.js").then((module) => {
module.Janus.init({
debug: "all",
callback: function() {
"debug": "all",
"callback": function() {
_Janus = module.Janus;
set_enabled();
},

View File

@ -260,10 +260,10 @@ function __WindowManager() {
self.getViewGeometry = function() {
let el_navbar = $("navbar");
return {
top: (el_navbar ? el_navbar.clientHeight : 0), // Navbar height
bottom: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
left: 0,
right: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
"top": (el_navbar ? el_navbar.clientHeight : 0), // Navbar height
"bottom": Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
"left": 0,
"right": Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
};
};
@ -482,7 +482,7 @@ function __WindowManager() {
return;
}
let prev_pos = {x: 0, y: 0};
let prev_pos = {"x": 0, "y": 0};
function startMoving(event) {
// При перетаскивании resizable-окна за правый кран экрана оно ужимается.
@ -535,9 +535,9 @@ function __WindowManager() {
function getEventPosition(event) {
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 {
return {x: event.clientX, y: event.clientY};
return {"x": event.clientX, "y": event.clientY};
}
}