Enforce curly braces for control statements

This commit is contained in:
Pierre Ossman 2018-09-06 17:22:40 +02:00
parent 4a16dc51a8
commit 426a8c927b
7 changed files with 32 additions and 16 deletions

View File

@ -31,6 +31,7 @@
"ignoreComments": true }], "ignoreComments": true }],
"comma-spacing": ["error"], "comma-spacing": ["error"],
"comma-style": ["error"], "comma-style": ["error"],
"curly": ["error", "multi-line"],
"func-call-spacing": ["error"], "func-call-spacing": ["error"],
"func-names": ["error"], "func-names": ["error"],
"func-style": ["error", "declaration", { "allowArrowFunctions": true }], "func-style": ["error", "declaration", { "allowArrowFunctions": true }],

View File

@ -53,10 +53,12 @@ export class Localizer {
.replace("_", "-") .replace("_", "-")
.split("-"); .split("-");
if (userLang[0] !== supLang[0]) if (userLang[0] !== supLang[0]) {
continue; continue;
if (userLang[1] !== supLang[1]) }
if (userLang[1] !== supLang[1]) {
continue; continue;
}
this.language = supportedLanguages[j]; this.language = supportedLanguages[j];
return; return;
@ -69,10 +71,12 @@ export class Localizer {
.replace("_", "-") .replace("_", "-")
.split("-"); .split("-");
if (userLang[0] !== supLang[0]) if (userLang[0] !== supLang[0]) {
continue; continue;
if (supLang[1] !== undefined) }
if (supLang[1] !== undefined) {
continue; continue;
}
this.language = supportedLanguages[j]; this.language = supportedLanguages[j];
return; return;

View File

@ -249,10 +249,11 @@ export default class Keyboard {
// Character (A-Z) // Character (A-Z)
let char = String.fromCharCode(e.keyCode); let char = String.fromCharCode(e.keyCode);
// A feeble attempt at the correct case // A feeble attempt at the correct case
if (e.shiftKey) if (e.shiftKey) {
char = char.toUpperCase(); char = char.toUpperCase();
else } else {
char = char.toLowerCase(); char = char.toLowerCase();
}
keysym = char.charCodeAt(); keysym = char.charCodeAt();
} else { } else {
// Unknown, give up // Unknown, give up

View File

@ -2348,8 +2348,10 @@ RFB.encodingHandlers = {
else if (ctl === 0x0A) cmode = "png"; else if (ctl === 0x0A) cmode = "png";
else if (ctl & 0x04) cmode = "filter"; else if (ctl & 0x04) cmode = "filter";
else if (ctl < 0x04) cmode = "copy"; else if (ctl < 0x04) cmode = "copy";
else return this._fail("Illegal tight compression received (ctl: " + else {
return this._fail("Illegal tight compression received (ctl: " +
ctl + ")"); ctl + ")");
}
if (isTightPNG && (ctl < 0x08)) { if (isTightPNG && (ctl < 0x08)) {
return this._fail("BasicCompression received in TightPNG rect"); return this._fail("BasicCompression received in TightPNG rect");

View File

@ -187,39 +187,45 @@ export default class Cursor {
} }
_showCursor() { _showCursor() {
if (this._canvas.style.visibility === 'hidden') if (this._canvas.style.visibility === 'hidden') {
this._canvas.style.visibility = ''; this._canvas.style.visibility = '';
} }
}
_hideCursor() { _hideCursor() {
if (this._canvas.style.visibility !== 'hidden') if (this._canvas.style.visibility !== 'hidden') {
this._canvas.style.visibility = 'hidden'; this._canvas.style.visibility = 'hidden';
} }
}
// Should we currently display the cursor? // Should we currently display the cursor?
// (i.e. are we over the target, or a child of the target without a // (i.e. are we over the target, or a child of the target without a
// different cursor set) // different cursor set)
_shouldShowCursor(target) { _shouldShowCursor(target) {
// Easy case // Easy case
if (target === this._target) if (target === this._target) {
return true; return true;
}
// Other part of the DOM? // Other part of the DOM?
if (!this._target.contains(target)) if (!this._target.contains(target)) {
return false; return false;
}
// Has the child its own cursor? // Has the child its own cursor?
// FIXME: How can we tell that a sub element has an // FIXME: How can we tell that a sub element has an
// explicit "cursor: none;"? // explicit "cursor: none;"?
if (window.getComputedStyle(target).cursor !== 'none') if (window.getComputedStyle(target).cursor !== 'none') {
return false; return false;
}
return true; return true;
} }
_updateVisibility(target) { _updateVisibility(target) {
if (this._shouldShowCursor(target)) if (this._shouldShowCursor(target)) {
this._showCursor(); this._showCursor();
else } else {
this._hideCursor(); this._hideCursor();
} }
}
_updatePosition() { _updatePosition() {
this._canvas.style.left = this._position.x + "px"; this._canvas.style.left = this._position.x + "px";

View File

@ -35,8 +35,9 @@ document.body.appendChild(script);
function fallback() { function fallback() {
if (!window._noVNC_has_module_support) { if (!window._noVNC_has_module_support) {
/* eslint-disable no-console */ /* eslint-disable no-console */
if (console) if (console) {
console.log("No module support detected. Loading fallback..."); console.log("No module support detected. Loading fallback...");
}
/* eslint-enable no-console */ /* eslint-enable no-console */
let loader = document.createElement("script"); let loader = document.createElement("script");
loader.src = "base/vendor/browser-es-module-loader/dist/browser-es-module-loader.js"; loader.src = "base/vendor/browser-es-module-loader/dist/browser-es-module-loader.js";

View File

@ -49,8 +49,9 @@ function enableUI() {
frames = VNC_frame_data; frames = VNC_frame_data;
// Only present in older recordings // Only present in older recordings
if (window.VNC_frame_encoding) if (window.VNC_frame_encoding) {
encoding = VNC_frame_encoding; encoding = VNC_frame_encoding;
}
} }
class IterationPlayer { class IterationPlayer {