summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuanjo Diaz <juanjo.diazmo@gmail.com>2018-07-09 22:47:29 +0200
committerJuanjo Diaz <juanjo.diazmo@gmail.com>2018-07-12 19:06:57 +0200
commit651c23ece37c1749936d2eb97939d121887720b9 (patch)
tree109df665d15f8620504936f58b10b6f42b5405fb
parent0e4808bf6f3165f7daa1282af445f6ea7e60de55 (diff)
downloadnovnc-651c23ece37c1749936d2eb97939d121887720b9.tar.gz
Use fat arrow functions `const foo = () => { ... };` for callbacks
and any other function that is passed around and it's not a top level function
-rw-r--r--.eslintrc5
-rw-r--r--app/error-handler.js5
-rw-r--r--app/ui.js36
-rw-r--r--app/webutil.js14
-rw-r--r--core/input/keyboard.js11
-rw-r--r--core/rfb.js54
-rw-r--r--core/util/events.js2
-rw-r--r--core/util/eventtarget.js2
-rw-r--r--core/util/logging.js10
-rw-r--r--core/util/polyfill.js4
-rw-r--r--core/websock.js20
-rw-r--r--karma.conf.js2
-rwxr-xr-xpo/xgettext-html2
-rw-r--r--tests/.eslintrc3
-rw-r--r--tests/assertions.js2
-rw-r--r--tests/fake.websocket.js4
-rw-r--r--tests/playback-ui.js16
-rw-r--r--tests/playback.js32
-rw-r--r--tests/test.base64.js2
-rw-r--r--tests/test.display.js4
-rw-r--r--tests/test.keyboard.js36
-rw-r--r--tests/test.mouse.js18
-rw-r--r--tests/test.rfb.js25
-rw-r--r--tests/test.websock.js2
-rwxr-xr-xutils/genkeysymdef.js2
-rwxr-xr-xutils/use_require.js48
-rw-r--r--utils/use_require_helpers.js7
-rw-r--r--vnc_lite.html2
28 files changed, 178 insertions, 192 deletions
diff --git a/.eslintrc b/.eslintrc
index ea4d655..b85e51c 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -13,5 +13,10 @@
"no-var": "error",
"no-useless-constructor": "error",
"object-shorthand": ["error", "methods", { "avoidQuotes": true }],
+ "prefer-arrow-callback": "error",
+ "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": false } ],
+ "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
+ "arrow-spacing": ["error"],
+ "no-confusing-arrow": ["error", { "allowParens": true }],
}
}
diff --git a/app/error-handler.js b/app/error-handler.js
index d813349..96dc926 100644
--- a/app/error-handler.js
+++ b/app/error-handler.js
@@ -2,7 +2,10 @@
// native support in the browsers, so that our error handler
// can catch script-loading errors.
-(function(){
+// No ES6 can be used in this file since it's used for the translation
+/* eslint-disable prefer-arrow-callback */
+
+(function() {
"use strict";
// Fallback for all uncought errors
diff --git a/app/ui.js b/app/ui.js
index a8537fb..4fe2a3f 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -71,7 +71,7 @@ const UI = {
if (isTouchDevice) {
document.documentElement.classList.add("noVNC_touch");
// Remove the address bar
- setTimeout(function() { window.scrollTo(0, 1); }, 100);
+ setTimeout(() => window.scrollTo(0, 1), 100);
}
// Restore control bar position
@@ -230,13 +230,13 @@ const UI = {
addTouchSpecificHandlers() {
document.getElementById("noVNC_mouse_button0")
- .addEventListener('click', function () { UI.setMouseButton(1); });
+ .addEventListener('click', () => UI.setMouseButton(1));
document.getElementById("noVNC_mouse_button1")
- .addEventListener('click', function () { UI.setMouseButton(2); });
+ .addEventListener('click', () => UI.setMouseButton(2));
document.getElementById("noVNC_mouse_button2")
- .addEventListener('click', function () { UI.setMouseButton(4); });
+ .addEventListener('click', () => UI.setMouseButton(4));
document.getElementById("noVNC_mouse_button4")
- .addEventListener('click', function () { UI.setMouseButton(0); });
+ .addEventListener('click', () => UI.setMouseButton(0));
document.getElementById("noVNC_keyboard_button")
.addEventListener('click', UI.toggleVirtualKeyboard);
@@ -250,7 +250,7 @@ const UI = {
document.getElementById("noVNC_keyboardinput")
.addEventListener('blur', UI.onblurVirtualKeyboard);
document.getElementById("noVNC_keyboardinput")
- .addEventListener('submit', function () { return false; });
+ .addEventListener('submit', () => false);
document.documentElement
.addEventListener('mousedown', UI.keepVirtualKeyboard, true);
@@ -294,11 +294,11 @@ const UI = {
addMachineHandlers() {
document.getElementById("noVNC_shutdown_button")
- .addEventListener('click', function() { UI.rfb.machineShutdown(); });
+ .addEventListener('click', () => UI.rfb.machineShutdown());
document.getElementById("noVNC_reboot_button")
- .addEventListener('click', function() { UI.rfb.machineReboot(); });
+ .addEventListener('click', () => UI.rfb.machineReboot());
document.getElementById("noVNC_reset_button")
- .addEventListener('click', function() { UI.rfb.machineReset(); });
+ .addEventListener('click', () => UI.rfb.machineReset());
document.getElementById("noVNC_power_button")
.addEventListener('click', UI.togglePowerPanel);
},
@@ -329,7 +329,7 @@ const UI = {
addSettingChangeHandler(name, changeFunc) {
const settingElem = document.getElementById("noVNC_setting_" + name);
if (changeFunc === undefined) {
- changeFunc = function () { UI.saveSetting(name); };
+ changeFunc = () => UI.saveSetting(name);
}
settingElem.addEventListener('change', changeFunc);
},
@@ -552,8 +552,7 @@ const UI = {
const barDisplayStyle = window.getComputedStyle(bar).display;
if (barDisplayStyle !== 'none') {
bar.style.transitionDuration = '0s';
- bar.addEventListener('transitionend', function () {
- this.style.transitionDuration = ""; });
+ bar.addEventListener('transitionend', () => bar.style.transitionDuration = '');
}
const anchor = document.getElementById('noVNC_control_bar_anchor');
@@ -1029,7 +1028,7 @@ const UI = {
UI.rfb.addEventListener("disconnect", UI.disconnectFinished);
UI.rfb.addEventListener("credentialsrequired", UI.credentials);
UI.rfb.addEventListener("securityfailure", UI.securityFailed);
- UI.rfb.addEventListener("capabilities", function () { UI.updatePowerButton(); });
+ UI.rfb.addEventListener("capabilities", UI.updatePowerButton);
UI.rfb.addEventListener("clipboard", UI.clipboardReceive);
UI.rfb.addEventListener("bell", UI.bell);
UI.rfb.addEventListener("desktopname", UI.updateDesktopName);
@@ -1153,9 +1152,8 @@ const UI = {
document.getElementById('noVNC_password_dlg')
.classList.add('noVNC_open');
- setTimeout(function () {
- document.getElementById('noVNC_password_input').focus();
- }, 100);
+ setTimeout(() => document
+ .getElementById('noVNC_password_input').focus(), 100);
Log.Warn("Server asked for a password");
UI.showStatus(_("Password is required"), "warning");
@@ -1624,7 +1622,7 @@ const UI = {
const promise = document.getElementById('noVNC_bell').play();
// The standards disagree on the return value here
if (promise) {
- promise.catch(function(e) {
+ promise.catch((e) => {
if (e.name === "NotAllowedError") {
// Ignore when the browser doesn't let us play audio.
// It is common that the browsers require audio to be
@@ -1655,12 +1653,12 @@ const UI = {
const LINGUAS = ["de", "el", "es", "nl", "pl", "sv", "tr", "zh_CN", "zh_TW"];
l10n.setup(LINGUAS);
if (l10n.language !== "en" && l10n.dictionary === undefined) {
- WebUtil.fetchJSON('app/locale/' + l10n.language + '.json', function (translations) {
+ WebUtil.fetchJSON('app/locale/' + l10n.language + '.json', (translations) => {
l10n.dictionary = translations;
// wait for translations to load before loading the UI
UI.prime();
- }, function (err) {
+ }, (err) => {
Log.Error("Failed to load translations: " + err);
UI.prime();
});
diff --git a/app/webutil.js b/app/webutil.js
index 18816d1..33d9292 100644
--- a/app/webutil.js
+++ b/app/webutil.js
@@ -119,7 +119,7 @@ export function initSettings (callback /*, ...callbackArgs */) {
"use strict";
const callbackArgs = Array.prototype.slice.call(arguments, 1);
if (window.chrome && window.chrome.storage) {
- window.chrome.storage.sync.get(function (cfg) {
+ window.chrome.storage.sync.get((cfg) => {
settings = cfg;
if (callback) {
callback.apply(this, callbackArgs);
@@ -201,7 +201,7 @@ export function injectParamIfMissing (path, param, value) {
query = [];
}
- if (!query.some(function (v) { return v.startsWith(param_eq); })) {
+ if (!query.some(v => v.startsWith(param_eq))) {
query.push(param_eq + encodeURIComponent(value));
elem.search = "?" + query.join("&");
}
@@ -224,7 +224,7 @@ export function fetchJSON(path, resolve, reject) {
const req = new XMLHttpRequest();
req.open('GET', path);
- req.onload = function () {
+ req.onload = () => {
if (req.status === 200) {
let resObj;
try {
@@ -238,13 +238,9 @@ export function fetchJSON(path, resolve, reject) {
}
};
- req.onerror = function (evt) {
- reject(new Error("XHR encountered an error while trying to load '" + path + "': " + evt.message));
- };
+ req.onerror = evt => reject(new Error("XHR encountered an error while trying to load '" + path + "': " + evt.message));
- req.ontimeout = function (evt) {
- reject(new Error("XHR timed out while trying to load '" + path + "'"));
- };
+ req.ontimeout = evt => reject(new Error("XHR timed out while trying to load '" + path + "'"));
req.send();
}
diff --git a/core/input/keyboard.js b/core/input/keyboard.js
index 5b46748..2e7b90a 100644
--- a/core/input/keyboard.js
+++ b/core/input/keyboard.js
@@ -307,7 +307,7 @@ export default class Keyboard {
const target = this._target;
const downList = this._keyDownList;
- ['AltLeft', 'AltRight'].forEach(function (code) {
+ ['AltLeft', 'AltRight'].forEach((code) => {
if (!(code in downList)) {
return;
}
@@ -338,11 +338,10 @@ export default class Keyboard {
const handler = this._eventHandlers.checkalt;
['mousedown', 'mouseup', 'mousemove', 'wheel',
'touchstart', 'touchend', 'touchmove',
- 'keydown', 'keyup'].forEach(function (type) {
+ 'keydown', 'keyup'].forEach(type =>
document.addEventListener(type, handler,
{ capture: true,
- passive: true });
- });
+ passive: true }));
}
//Log.Debug("<< Keyboard.grab");
@@ -355,9 +354,7 @@ export default class Keyboard {
const handler = this._eventHandlers.checkalt;
['mousedown', 'mouseup', 'mousemove', 'wheel',
'touchstart', 'touchend', 'touchmove',
- 'keydown', 'keyup'].forEach(function (type) {
- document.removeEventListener(type, handler);
- });
+ 'keydown', 'keyup'].forEach(type => document.removeEventListener(type, handler));
}
this._target.removeEventListener('keydown', this._eventHandlers.keydown);
diff --git a/core/rfb.js b/core/rfb.js
index ed765e8..3433030 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -201,17 +201,17 @@ export default class RFB extends EventTargetMixin {
this._sock = new Websock();
this._sock.on('message', this._handle_message.bind(this));
- this._sock.on('open', function () {
+ this._sock.on('open', () => {
if ((this._rfb_connection_state === 'connecting') &&
(this._rfb_init_state === '')) {
this._rfb_init_state = 'ProtocolVersion';
Log.Debug("Starting VNC handshake");
} else {
this._fail("Unexpected server connection while " +
- this._rfb_connection_state);
+ this._rfb_connection_state);
}
- }.bind(this));
- this._sock.on('close', function (e) {
+ });
+ this._sock.on('close', (e) => {
Log.Debug("WebSocket on-close event");
let msg = "";
if (e.code) {
@@ -236,18 +236,16 @@ export default class RFB extends EventTargetMixin {
break;
case 'disconnected':
this._fail("Unexpected server disconnect " +
- "when already disconnected " + msg);
+ "when already disconnected " + msg);
break;
default:
this._fail("Unexpected server disconnect before connecting " +
- msg);
+ msg);
break;
}
this._sock.off('close');
- }.bind(this));
- this._sock.on('error', function (e) {
- Log.Warn("WebSocket on-error event");
});
+ this._sock.on('error', e => Log.Warn("WebSocket on-error event"));
// Slight delay of the actual connection so that the caller has
// time to set up callbacks
@@ -459,7 +457,7 @@ export default class RFB extends EventTargetMixin {
const stats = this._encStats;
Log.Info("Encoding stats for this connection:");
- Object.keys(stats).forEach(function (key) {
+ Object.keys(stats).forEach((key) => {
const s = stats[key];
if (s[0] + s[1] > 0) {
Log.Info(" " + encodingName(key) + ": " + s[0] + " rects");
@@ -467,10 +465,7 @@ export default class RFB extends EventTargetMixin {
});
Log.Info("Encoding stats since page load:");
- Object.keys(stats).forEach(function (key) {
- const s = stats[key];
- Log.Info(" " + encodingName(key) + ": " + s[1] + " rects");
- });
+ Object.keys(stats).forEach(key => Log.Info(" " + encodingName(key) + ": " + stats[key][1] + " rects"));
}
_focusCanvas(event) {
@@ -489,10 +484,10 @@ export default class RFB extends EventTargetMixin {
_windowResize(event) {
// If the window resized then our screen element might have
// as well. Update the viewport dimensions.
- window.requestAnimationFrame(function () {
+ window.requestAnimationFrame(() => {
this._updateClip();
this._updateScale();
- }.bind(this));
+ });
if (this._resizeSession) {
// Request changing the resolution of the remote display to
@@ -640,8 +635,7 @@ export default class RFB extends EventTargetMixin {
this._rfb_connection_state = state;
- const smsg = "New state '" + state + "', was '" + oldstate + "'.";
- Log.Debug(smsg);
+ Log.Debug("New state '" + state + "', was '" + oldstate + "'.");
if (this._disconnTimer && state !== 'disconnecting') {
Log.Debug("Clearing disconnect timer");
@@ -664,10 +658,10 @@ export default class RFB extends EventTargetMixin {
case 'disconnecting':
this._disconnect();
- this._disconnTimer = setTimeout(function () {
+ this._disconnTimer = setTimeout(() => {
Log.Error("Disconnection timed out.");
this._updateConnectionState('disconnected');
- }.bind(this), DISCONNECT_TIMEOUT * 1000);
+ }, DISCONNECT_TIMEOUT * 1000);
break;
case 'disconnected':
@@ -2143,7 +2137,7 @@ RFB.encodingHandlers = {
let resetStreams = 0;
let streamId = -1;
- const decompress = function (data, expected) {
+ const decompress = (data, expected) => {
for (let i = 0; i < 4; i++) {
if ((resetStreams >> i) & 1) {
this._FBU.zlibs[i].reset();
@@ -2159,9 +2153,9 @@ RFB.encodingHandlers = {
//return uncompressed.data;
return uncompressed;
- }.bind(this);
+ };
- const indexedToRGBX2Color = function (data, palette, width, height) {
+ const indexedToRGBX2Color = (data, palette, width, height) => {
// Convert indexed (palette based) image data to RGB
// TODO: reduce number of calculations inside loop
const dest = this._destBuff;
@@ -2220,9 +2214,9 @@ RFB.encodingHandlers = {
}
return dest;
- }.bind(this);
+ };
- const indexedToRGBX = function (data, palette, width, height) {
+ const indexedToRGBX = (data, palette, width, height) => {
// Convert indexed (palette based) image data to RGB
const dest = this._destBuff;
const total = width * height * 4;
@@ -2235,14 +2229,14 @@ RFB.encodingHandlers = {
}
return dest;
- }.bind(this);
+ };
const rQi = this._sock.get_rQi();
const rQ = this._sock.rQwhole();
let cmode, data;
let cl_header, cl_data;
- const handlePalette = function () {
+ const handlePalette = () => {
const numColors = rQ[rQi + 2] + 1;
const paletteSize = numColors * 3;
this._FBU.bytes += paletteSize;
@@ -2300,9 +2294,9 @@ RFB.encodingHandlers = {
return true;
- }.bind(this);
+ };
- const handleCopy = function () {
+ const handleCopy = () => {
let raw = false;
const uncompressedSize = this._FBU.width * this._FBU.height * 3;
if (uncompressedSize < 12) {
@@ -2340,7 +2334,7 @@ RFB.encodingHandlers = {
this._display.blitRgbImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, data, 0, false);
return true;
- }.bind(this);
+ };
let ctl = this._sock.rQpeek8();
diff --git a/core/util/events.js b/core/util/events.js
index 66527fa..a0eddc7 100644
--- a/core/util/events.js
+++ b/core/util/events.js
@@ -120,7 +120,7 @@ export function releaseCapture () {
// There might be events already queued, so we need to wait for
// them to flush. E.g. contextmenu in Microsoft Edge
- window.setTimeout(function(expected) {
+ window.setTimeout((expected) => {
// Only clear it if it's the expected grab (i.e. no one
// else has initiated a new grab)
if (_captureIndex === expected) {
diff --git a/core/util/eventtarget.js b/core/util/eventtarget.js
index 7e56cd5..bb8d6e0 100644
--- a/core/util/eventtarget.js
+++ b/core/util/eventtarget.js
@@ -32,7 +32,7 @@ export default class EventTargetMixin {
if (!this._listeners || !this._listeners.has(event.type)) {
return true;
}
- this._listeners.get(event.type).forEach(function (callback) {
+ this._listeners.get(event.type).forEach((callback) => {
callback.call(this, event);
}, this);
return !event.defaultPrevented;
diff --git a/core/util/logging.js b/core/util/logging.js
index 5669ad2..1f6a71e 100644
--- a/core/util/logging.js
+++ b/core/util/logging.js
@@ -12,10 +12,10 @@
let _log_level = 'warn';
-let Debug = function (msg) {};
-let Info = function (msg) {};
-let Warn = function (msg) {};
-let Error = function (msg) {};
+let Debug = () => {};
+let Info = () => {};
+let Warn = () => {};
+let Error = () => {};
export function init_logging (level) {
if (typeof level === 'undefined') {
@@ -24,7 +24,7 @@ export function init_logging (level) {
_log_level = level;
}
- Debug = Info = Warn = Error = function (msg) {};
+ Debug = Info = Warn = Error = () => {};
if (typeof window.console !== "undefined") {
/* eslint-disable no-console, no-fallthrough */
diff --git a/core/util/polyfill.js b/core/util/polyfill.js
index c991aa2..1971edf 100644
--- a/core/util/polyfill.js
+++ b/core/util/polyfill.js
@@ -38,8 +38,8 @@ if (typeof Object.assign != 'function') {
}
/* CustomEvent constructor (taken from MDN) */
-(function () {
- function CustomEvent ( event, params ) {
+(() => {
+ function CustomEvent (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
const evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
diff --git a/core/websock.js b/core/websock.js
index ce27c5b..9f09230 100644
--- a/core/websock.js
+++ b/core/websock.js
@@ -164,14 +164,12 @@ export default class Websock {
}
send_string(str) {
- this.send(str.split('').map(function (chr) {
- return chr.charCodeAt(0);
- }));
+ this.send(str.split('').map(chr => chr.charCodeAt(0)));
}
// Event Handlers
off(evt) {
- this._eventHandlers[evt] = function () {};
+ this._eventHandlers[evt] = () => {};
}
on(evt, handler) {
@@ -196,7 +194,7 @@ export default class Websock {
this._websocket.binaryType = 'arraybuffer';
this._websocket.onmessage = this._recv_message.bind(this);
- this._websocket.onopen = (function () {
+ this._websocket.onopen = () => {
Log.Debug('>> WebSock.onopen');
if (this._websocket.protocol) {
Log.Info("Server choose sub-protocol: " + this._websocket.protocol);
@@ -204,17 +202,17 @@ export default class Websock {
this._eventHandlers.open();
Log.Debug("<< WebSock.onopen");
- }).bind(this);
- this._websocket.onclose = (function (e) {
+ };
+ this._websocket.onclose = (e) => {
Log.Debug(">> WebSock.onclose");
this._eventHandlers.close(e);
Log.Debug("<< WebSock.onclose");
- }).bind(this);
- this._websocket.onerror = (function (e) {
+ };
+ this._websocket.onerror = (e) => {
Log.Debug(">> WebSock.onerror: " + e);
this._eventHandlers.error(e);
Log.Debug("<< WebSock.onerror: " + e);
- }).bind(this);
+ };
}
close() {
@@ -225,7 +223,7 @@ export default class Websock {
this._websocket.close();
}
- this._websocket.onmessage = function (e) { return; };
+ this._websocket.onmessage = () => {};
}
}
diff --git a/karma.conf.js b/karma.conf.js
index 9727c4c..f0a1343 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -1,6 +1,6 @@
// Karma configuration
-module.exports = function(config) {
+module.exports = (config) => {
const customLaunchers = {};
let browsers = [];
let useSauce = false;
diff --git a/po/xgettext-html b/po/xgettext-html
index 87638cb..ddb2cb2 100755
--- a/po/xgettext-html
+++ b/po/xgettext-html
@@ -89,7 +89,7 @@ for (let i = 0; i < opt.argv.length; i++) {
const dom = new jsdom.JSDOM(file, { includeNodeLocations: true });
const body = dom.window.document.body;
- const locator = function (elem) {
+ const locator = (elem) => {
const offset = dom.nodeLocation(elem).startOffset;
const line = file.slice(0, offset).split("\n").length;
return fn + ":" + line;
diff --git a/tests/.eslintrc b/tests/.eslintrc
index b52ebaf..dabeb4b 100644
--- a/tests/.eslintrc
+++ b/tests/.eslintrc
@@ -5,5 +5,8 @@
},
"globals": {
"chai": true
+ },
+ "rules": {
+ "prefer-arrow-callback": 0
}
} \ No newline at end of file
diff --git a/tests/assertions.js b/tests/assertions.js
index a336a7a..ba931c2 100644
--- a/tests/assertions.js
+++ b/tests/assertions.js
@@ -32,7 +32,7 @@ chai.use(function (_chai, utils) {
_chai.Assertion.addMethod('sent', function (target_data) {
const obj = this._obj;
- obj.inspect = function () {
+ obj.inspect = () => {
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
_sQ: new Uint8Array(obj._sQ.buffer, 0, obj._sQlen) };
res.prototype = obj;
diff --git a/tests/fake.websocket.js b/tests/fake.websocket.js
index e0290ed..2e1a3b9 100644
--- a/tests/fake.websocket.js
+++ b/tests/fake.websocket.js
@@ -74,7 +74,7 @@ FakeWebSocket.CLOSED = WebSocket.CLOSED;
FakeWebSocket.__is_fake = true;
-FakeWebSocket.replace = function () {
+FakeWebSocket.replace = () => {
if (!WebSocket.__is_fake) {
const real_version = WebSocket;
// eslint-disable-next-line no-global-assign
@@ -83,7 +83,7 @@ FakeWebSocket.replace = function () {
}
};
-FakeWebSocket.restore = function () {
+FakeWebSocket.restore = () => {
if (WebSocket.__is_fake) {
// eslint-disable-next-line no-global-assign
WebSocket = WebSocket.__real_version;
diff --git a/tests/playback-ui.js b/tests/playback-ui.js
index d2d0869..295f983 100644
--- a/tests/playback-ui.js
+++ b/tests/playback-ui.js
@@ -21,7 +21,7 @@ function loadFile() {
message("Loading " + fname);
- return new Promise(function (resolve, reject) {
+ return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.onload = resolve;
script.onerror = reject;
@@ -67,9 +67,9 @@ class IterationPlayer {
this._state = 'running';
- this.onfinish = function() {};
- this.oniterationfinish = function() {};
- this.rfbdisconnected = function() {};
+ this.onfinish = () => {};
+ this.oniterationfinish = () => {};
+ this.rfbdisconnected = () => {};
}
start(mode) {
@@ -147,15 +147,15 @@ function start() {
}
const player = new IterationPlayer(iterations, frames, encoding);
- player.oniterationfinish = function (evt) {
+ player.oniterationfinish = (evt) => {
message(`Iteration ${evt.number} took ${evt.duration}ms`);
};
- player.onrfbdisconnected = function (evt) {
+ player.onrfbdisconnected = (evt) => {
if (!evt.clean) {
message(`noVNC sent disconnected during iteration ${evt.iteration} frame ${evt.frame}`);
}
};
- player.onfinish = function (evt) {
+ player.onfinish = (evt) => {
const iterTime = parseInt(evt.duration / evt.iterations, 10);
message(`${evt.iterations} iterations took ${evt.duration}ms (average ${iterTime}ms / iteration)`);
@@ -165,4 +165,4 @@ function start() {
player.start(mode);
}
-loadFile().then(enableUI).catch(function (e) { message("Error loading recording: " + e); });
+loadFile().then(enableUI).catch(e => message("Error loading recording: " + e));
diff --git a/tests/playback.js b/tests/playback.js
index 6b422d8..cac9c8a 100644
--- a/tests/playback.js
+++ b/tests/playback.js
@@ -13,18 +13,18 @@ if (window.setImmediate === undefined) {
let _immediateIdCounter = 1;
const _immediateFuncs = {};
- window.setImmediate = function (func) {
+ window.setImmediate = (func) => {
const index = _immediateIdCounter++;
_immediateFuncs[index] = func;
window.postMessage("noVNC immediate trigger:" + index, "*");
return index;
};
- window.clearImmediate = function (id) {
+ window.clearImmediate = (id) => {
_immediateFuncs[id];
};
- const _onMessage = function (event) {
+ const _onMessage = (event) => {
if ((typeof event.data !== "string") ||
(event.data.indexOf("noVNC immediate trigger:") !== 0)) {
return;
@@ -71,7 +71,7 @@ export default class RecordingPlayer {
this._running = false;
- this.onfinish = function () {};
+ this.onfinish = () => {};
}
run(realtime, trafficManagement) {
@@ -96,9 +96,9 @@ export default class RecordingPlayer {
// _enablePlaybackMode mocks out things not required for running playback
_enablePlaybackMode() {
- this._rfb._sock.send = function (arr) {};
- this._rfb._sock.close = function () {};
- this._rfb._sock.flush = function () {};
+ this._rfb._sock.send = () => {};
+ this._rfb._sock.close = () => {};
+ this._rfb._sock.flush = () => {};
this._rfb._sock.open = function () {
this.init();
this._eventHandlers.open();
@@ -143,12 +143,11 @@ export default class RecordingPlayer {
_doPacket() {
// Avoid having excessive queue buildup in non-realtime mode
if (this._trafficManagement && this._rfb._flushing) {
- const player = this;
const orig = this._rfb._display.onflush;
- this._rfb._display.onflush = function () {
- player._rfb._display.onflush = orig;
- player._rfb._onFlush();
- player._doPacket();
+ this._rfb._display.onflush = () => {
+ this._rfb._display.onflush = orig;
+ this._rfb._onFlush();
+ this._doPacket();
};
return;
}
@@ -174,12 +173,11 @@ export default class RecordingPlayer {
_finish() {
if (this._rfb._display.pending()) {
- const player = this;
- this._rfb._display.onflush = function () {
- if (player._rfb._flushing) {
- player._rfb._onFlush();
+ this._rfb._display.onflush = () => {
+ if (this._rfb._flushing) {
+ this._rfb._onFlush();
}
- player._finish();
+ this._finish();
};
this._rfb._display.flush();
} else {
diff --git a/tests/test.base64.js b/tests/test.base64.js
index 0ff4bfe..a972448 100644
--- a/tests/test.base64.js
+++ b/tests/test.base64.js
@@ -27,7 +27,7 @@ describe('Base64 Tools', function() {
});
it('should throw an error if we have extra characters at the end of the string', function() {
- expect(function () { Base64.decode(B64_STR+'abcdef'); }).to.throw(Error);
+ expect(() => Base64.decode(B64_STR+'abcdef')).to.throw(Error);
});
});
});
diff --git a/tests/test.display.js b/tests/test.display.js
index a7afd06..e3810ef 100644
--- a/tests/test.display.js
+++ b/tests/test.display.js
@@ -284,7 +284,7 @@ describe('Display/Canvas Helper', function () {
it('should draw the logo on #clear with a logo set', function (done) {
display._logo = { width: 4, height: 4, type: "image/png", data: make_image_png(checked_data) };
display.clear();
- display.onflush = function () {
+ display.onflush = () => {
expect(display).to.have.displayed(checked_data);
expect(display._fb_width).to.equal(4);
expect(display._fb_height).to.equal(4);
@@ -325,7 +325,7 @@ describe('Display/Canvas Helper', function () {
it('should support drawing images via #imageRect', function (done) {
display.imageRect(0, 0, "image/png", make_image_png(checked_data));
display.flip();
- display.onflush = function () {
+ display.onflush = () => {
expect(display).to.have.displayed(checked_data);
done();
};
diff --git a/tests/test.keyboard.js b/tests/test.keyboard.js
index 3d409fb..c555b4f 100644
--- a/tests/test.keyboard.js
+++ b/tests/test.keyboard.js
@@ -24,7 +24,7 @@ describe('Key Event Handling', function() {
it('should decode keydown events', function(done) {
if (browser.isIE() || browser.isEdge()) this.skip();
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -36,7 +36,7 @@ describe('Key Event Handling', function() {
if (browser.isIE() || browser.isEdge()) this.skip();
let calls = 0;
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
if (calls++ === 1) {
@@ -57,7 +57,7 @@ describe('Key Event Handling', function() {
});
it('should decode keypress events', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -75,7 +75,7 @@ describe('Key Event Handling', function() {
});
it('should handle keypress with missing code', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -86,7 +86,7 @@ describe('Key Event Handling', function() {
});
it('should guess key if no keypress and numeric key', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x32);
expect(code).to.be.equal('Digit2');
expect(down).to.be.equal(true);
@@ -96,7 +96,7 @@ describe('Key Event Handling', function() {
});
it('should guess key if no keypress and alpha key', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -106,7 +106,7 @@ describe('Key Event Handling', function() {
});
it('should guess key if no keypress and alpha key (with shift)', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x41);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -116,7 +116,7 @@ describe('Key Event Handling', function() {
});
it('should not guess key if no keypress and unknown key', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -161,7 +161,7 @@ describe('Key Event Handling', function() {
if (browser.isIE() || browser.isEdge()) this.skip();
let count = 0;
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
switch (count++) {
case 0:
expect(keysym).to.be.equal(0x61);
@@ -208,7 +208,7 @@ describe('Key Event Handling', function() {
if (browser.isIE() || browser.isEdge()) this.skip();
let count = 0;
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
switch (count++) {
case 0:
expect(keysym).to.be.equal(0x61);
@@ -233,7 +233,7 @@ describe('Key Event Handling', function() {
});
it('should send release using the same keysym as the press', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
if (!down) {
@@ -246,7 +246,7 @@ describe('Key Event Handling', function() {
it('should send the same keysym for multiple presses', function() {
let count = 0;
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('KeyA');
expect(down).to.be.equal(true);
@@ -266,7 +266,7 @@ describe('Key Event Handling', function() {
describe('Legacy Events', function() {
it('should track keys using keyCode if no code', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('Platform65');
if (!down) {
@@ -278,7 +278,7 @@ describe('Key Event Handling', function() {
});
it('should ignore compositing code', function() {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('Unidentified');
};
@@ -286,7 +286,7 @@ describe('Key Event Handling', function() {
});
it('should track keys using keyIdentifier if no code', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0x61);
expect(code).to.be.equal('Platform65');
if (!down) {
@@ -328,7 +328,7 @@ describe('Key Event Handling', function() {
it('should change Alt to AltGraph', function() {
let count = 0;
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
switch (count++) {
case 0:
expect(keysym).to.be.equal(0xFF7E);
@@ -346,7 +346,7 @@ describe('Key Event Handling', function() {
});
it('should change left Super to Alt', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0xFFE9);
expect(code).to.be.equal('MetaLeft');
done();
@@ -355,7 +355,7 @@ describe('Key Event Handling', function() {
});
it('should change right Super to left Super', function(done) {
const kbd = new Keyboard(document);
- kbd.onkeyevent = function(keysym, code, down) {
+ kbd.onkeyevent = (keysym, code, down) => {
expect(keysym).to.be.equal(0xFFEB);
expect(code).to.be.equal('MetaRight');
done();
diff --git a/tests/test.mouse.js b/tests/test.mouse.js
index 58200a4..61db064 100644
--- a/tests/test.mouse.js
+++ b/tests/test.mouse.js
@@ -18,7 +18,7 @@ describe('Mouse Event Handling', function() {
// The real constructors might not work everywhere we
// want to run these tests
- const mouseevent = function(typeArg, MouseEventInit) {
+ const mouseevent = (typeArg, MouseEventInit) => {
const e = { type: typeArg };
for (let key in MouseEventInit) {
e[key] = MouseEventInit[key];
@@ -32,7 +32,7 @@ describe('Mouse Event Handling', function() {
describe('Decode Mouse Events', function() {
it('should decode mousedown events', function(done) {
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
expect(bmask).to.be.equal(0x01);
expect(down).to.be.equal(1);
done();
@@ -42,7 +42,7 @@ describe('Mouse Event Handling', function() {
it('should decode mouseup events', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
expect(bmask).to.be.equal(0x01);
if (calls++ === 1) {
expect(down).to.not.be.equal(1);
@@ -54,7 +54,7 @@ describe('Mouse Event Handling', function() {
});
it('should decode mousemove events', function(done) {
const mouse = new Mouse(target);
- mouse.onmousemove = function(x, y) {
+ mouse.onmousemove = (x, y) => {
// Note that target relative coordinates are sent
expect(x).to.be.equal(40);
expect(y).to.be.equal(10);
@@ -66,7 +66,7 @@ describe('Mouse Event Handling', function() {
it('should decode mousewheel events', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
calls++;
expect(bmask).to.be.equal(1<<6);
if (calls === 1) {
@@ -90,7 +90,7 @@ describe('Mouse Event Handling', function() {
it('should use same pos for 2nd tap if close enough', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
calls++;
if (calls === 1) {
expect(down).to.be.equal(1);
@@ -121,7 +121,7 @@ describe('Mouse Event Handling', function() {
it('should not modify 2nd tap pos if far apart', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
calls++;
if (calls === 1) {
expect(down).to.be.equal(1);
@@ -150,7 +150,7 @@ describe('Mouse Event Handling', function() {
it('should not modify 2nd tap pos if not soon enough', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
calls++;
if (calls === 1) {
expect(down).to.be.equal(1);
@@ -179,7 +179,7 @@ describe('Mouse Event Handling', function() {
it('should not modify 2nd tap pos if not touch', function(done) {
let calls = 0;
const mouse = new Mouse(target);
- mouse.onmousebutton = function(x, y, down, bmask) {
+ mouse.onmousebutton = (x, y, down, bmask) => {
calls++;
if (calls === 1) {
expect(down).to.be.equal(1);
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index cb72f4c..3d5bd28 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -8,7 +8,7 @@ import FakeWebSocket from './fake.websocket.js';
import sinon from '../vendor/sinon.js';
/* UIEvent constructor polyfill for IE */
-(function () {
+(() => {
if (typeof window.UIEvent === "function") return;
function UIEvent ( event, params ) {
@@ -23,18 +23,18 @@ import sinon from '../vendor/sinon.js';
window.UIEvent = UIEvent;
})();
-const push8 = function (arr, num) {
+const push8 = (arr, num) => {
"use strict";
arr.push(num & 0xFF);
};
-const push16 = function (arr, num) {
+const push16 = (arr, num) => {
"use strict";
arr.push((num >> 8) & 0xFF,
num & 0xFF);
};
-const push32 = function (arr, num) {
+const push32 = (arr, num) => {
"use strict";
arr.push((num >> 24) & 0xFF,
(num >> 16) & 0xFF,
@@ -852,7 +852,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should not result in a connect event if the state is not "connected"', function () {
const spy = sinon.spy();
client.addEventListener("connect", spy);
- client._sock._websocket.open = function () {}; // explicitly don't call onopen
+ client._sock._websocket.open = () => {}; // explicitly don't call onopen
client._updateConnectionState('connecting');
expect(spy).to.not.have.been.called;
});
@@ -866,7 +866,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should force disconnect if we do not call Websock.onclose within the disconnection timeout', function () {
sinon.spy(client, '_updateConnectionState');
- client._sock._websocket.close = function () {}; // explicitly don't call onclose
+ client._sock._websocket.close = () => {}; // explicitly don't call onclose
client._updateConnectionState('disconnecting');
this.clock.tick(3 * 1000);
expect(client._updateConnectionState).to.have.been.calledTwice;
@@ -891,7 +891,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should not result in a disconnect event', function () {
const spy = sinon.spy();
client.addEventListener("disconnect", spy);
- client._sock._websocket.close = function () {}; // explicitly don't call onclose
+ client._sock._websocket.close = () => {}; // explicitly don't call onclose
client._updateConnectionState('disconnecting');
expect(spy).to.not.have.been.called;
});
@@ -1239,11 +1239,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
});
function send_num_str_pairs(pairs, client) {
- const pairs_len = pairs.length;
const data = [];
- push32(data, pairs_len);
+ push32(data, pairs.length);
- for (let i = 0; i < pairs_len; i++) {
+ for (let i = 0; i < pairs.length; i++) {
push32(data, pairs[i][0]);
for (let j = 0; j < 4; j++) {
data.push(pairs[i][1].charCodeAt(j));
@@ -1618,7 +1617,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
const expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: () => {}};
RFB.messages.fbUpdateRequest(expected_msg, true, 0, 0, 640, 20);
- client._framebufferUpdate = function () { return true; };
+ client._framebufferUpdate = () => true;
client._sock._websocket._receive_data(new Uint8Array([0]));
expect(client._sock).to.have.sent(expected_msg._sQ);
@@ -1645,7 +1644,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should not send a request in continuous updates mode', function () {
client._enabledContinuousUpdates = true;
- client._framebufferUpdate = function () { return true; };
+ client._framebufferUpdate = () => true;
client._sock._websocket._receive_data(new Uint8Array([0]));
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
@@ -2231,7 +2230,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
// close events
it('should transition to "disconnected" from "disconnecting" on a close event', function () {
const real = client._sock._websocket.close;
- client._sock._websocket.close = function () {};
+ client._sock._websocket.close = () => {};
client.disconnect();
expect(client._rfb_connection_state).to.equal('disconnecting');
client._sock._websocket.close = real;
diff --git a/tests/test.websock.js b/tests/test.websock.js
index eb46df5..124d1bf 100644
--- a/tests/test.websock.js
+++ b/tests/test.websock.js
@@ -178,7 +178,7 @@ describe('Websock', function() {
it('should raise an error if we try to go back more than possible', function () {
sock.set_rQi(5);
- expect(function () { sock.rQwait('hi', RQ_TEMPLATE.length, 6); }).to.throw(Error);
+ expect(() => sock.rQwait('hi', RQ_TEMPLATE.length, 6)).to.throw(Error);
});
it('should not reduce rQi if there are enough bytes', function () {
diff --git a/utils/genkeysymdef.js b/utils/genkeysymdef.js
index 9d09775..cd89a68 100755
--- a/utils/genkeysymdef.js
+++ b/utils/genkeysymdef.js
@@ -108,7 +108,7 @@ out +=
"};\n" +
"\n" +
"export default {\n" +
-" lookup : function(u) {\n" +
+" lookup(u) {\n" +
" // Latin-1 is one-to-one mapping\n" +
" if ((u >= 0x20) && (u <= 0xff)) {\n" +
" return u;\n" +
diff --git a/utils/use_require.js b/utils/use_require.js
index 2d45f61..0dbdb0a 100755
--- a/utils/use_require.js
+++ b/utils/use_require.js
@@ -39,15 +39,14 @@ const no_transform_files = new Set([
path.join(paths.app, 'error-handler.js'),
]);
-no_copy_files.forEach((file) => no_transform_files.add(file));
+no_copy_files.forEach(file => no_transform_files.add(file));
// util.promisify requires Node.js 8.x, so we have our own
function promisify(original) {
return function () {
- const obj = this;
const args = Array.prototype.slice.call(arguments);
return new Promise((resolve, reject) => {
- original.apply(obj, args.concat((err, value) => {
+ original.apply(this, args.concat((err, value) => {
if (err) return reject(err);
resolve(value);
}));
@@ -70,29 +69,27 @@ const babelTransformFile = promisify(babel.transformFile);
// walkDir *recursively* walks directories trees,
// calling the callback for all normal files found.
-const walkDir = function (base_path, cb, filter) {
+function walkDir(base_path, cb, filter) {
return readdir(base_path)
- .then(files => {
+ .then((files) => {
const paths = files.map(filename => path.join(base_path, filename));
- return Promise.all(paths.map((filepath) => {
- return lstat(filepath)
- .then(stats => {
- if (filter !== undefined && !filter(filepath, stats)) return;
-
- if (stats.isSymbolicLink()) return;
- if (stats.isFile()) return cb(filepath);
- if (stats.isDirectory()) return walkDir(filepath, cb, filter);
- });
- }));
+ return Promise.all(paths.map(filepath => lstat(filepath)
+ .then((stats) => {
+ if (filter !== undefined && !filter(filepath, stats)) return;
+
+ if (stats.isSymbolicLink()) return;
+ if (stats.isFile()) return cb(filepath);
+ if (stats.isDirectory()) return walkDir(filepath, cb, filter);
+ })));
});
-};
+}
-const transform_html = function (legacy_scripts, only_legacy) {
+function transform_html (legacy_scripts, only_legacy) {
// write out the modified vnc.html file that works with the bundle
const src_html_path = path.resolve(__dirname, '..', 'vnc.html');
const out_html_path = path.resolve(paths.out_dir_base, 'vnc.html');
return readFile(src_html_path)
- .then(contents_raw => {
+ .then((contents_raw) => {
let contents = contents_raw.toString();
const start_marker = '<!-- begin scripts -->\n';
@@ -141,7 +138,7 @@ const transform_html = function (legacy_scripts, only_legacy) {
});
}
-const make_lib_files = function (import_format, source_maps, with_app_dir, only_legacy) {
+function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
if (!import_format) {
throw new Error("you must specify an import format to generate compiled noVNC libraries");
} else if (!SUPPORTED_FORMATS.has(import_format)) {
@@ -223,7 +220,7 @@ const make_lib_files = function (import_format, source_maps, with_app_dir, only_
}
return babelTransformFile(filename, opts)
- .then(res => {
+ .then((res) => {
console.log(`Writing ${legacy_path}`);
const {map} = res;
let {code} = res;
@@ -275,7 +272,7 @@ const make_lib_files = function (import_format, source_maps, with_app_dir, only_
const out_app_path = path.join(legacy_path_base, 'app.js');
console.log(`Writing ${out_app_path}`);
return helper.appWriter(out_path_base, legacy_path_base, out_app_path)
- .then(extra_scripts => {
+ .then((extra_scripts) => {
const rel_app_path = path.relative(out_path_base, out_app_path);
const legacy_scripts = extra_scripts.concat([rel_app_path]);
transform_html(legacy_scripts, only_legacy);
@@ -283,18 +280,17 @@ const make_lib_files = function (import_format, source_maps, with_app_dir, only_
.then(() => {
if (!helper.removeModules) return;
console.log(`Cleaning up temporary files...`);
- return Promise.all(outFiles.map(filepath => {
+ return Promise.all(outFiles.map((filepath) => {
unlink(filepath)
.then(() => {
// Try to clean up any empty directories if this
// was the last file in there
- const rmdir_r = dir => {
- return rmdir(dir)
+ const rmdir_r = dir =>
+ rmdir(dir)
.then(() => rmdir_r(path.dirname(dir)))
.catch(() => {
// Assume the error was ENOTEMPTY and ignore it
});
- };
return rmdir_r(path.dirname(filepath));
});
}));
@@ -304,7 +300,7 @@ const make_lib_files = function (import_format, source_maps, with_app_dir, only_
console.error(`Failure converting modules: ${err}`);
process.exit(1);
});
-};
+}
if (program.clean) {
console.log(`Removing ${paths.lib_dir_base}`);
diff --git a/utils/use_require_helpers.js b/utils/use_require_helpers.js
index 532e8f1..f0cbcf5 100644
--- a/utils/use_require_helpers.js
+++ b/utils/use_require_helpers.js
@@ -5,10 +5,9 @@ const path = require('path');
// util.promisify requires Node.js 8.x, so we have our own
function promisify(original) {
return function () {
- const obj = this;
const args = Array.prototype.slice.call(arguments);
return new Promise((resolve, reject) => {
- original.apply(obj, args.concat((err, value) => {
+ original.apply(this, args.concat((err, value) => {
if (err) return reject(err);
resolve(value);
}));
@@ -24,7 +23,7 @@ module.exports = {
// setup for requirejs
const ui_path = path.relative(base_out_path,
path.join(script_base_path, 'app', 'ui'));
- return writeFile(out_path, `requirejs(["${ui_path}"], function (ui) {});`)
+ return writeFile(out_path, `requirejs(["${ui_path}"], (ui) => {});`)
.then(() => {
console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`);
const require_path = path.relative(base_out_path,
@@ -43,7 +42,7 @@ module.exports = {
const browserify = require('browserify');
const b = browserify(path.join(script_base_path, 'app/ui.js'), {});
return promisify(b.bundle).call(b)
- .then((buf) => writeFile(out_path, buf))
+ .then(buf => writeFile(out_path, buf))
.then(() => []);
},
noCopyOverride: () => {},
diff --git a/vnc_lite.html b/vnc_lite.html
index 4a96d44..c580e11 100644
--- a/vnc_lite.html
+++ b/vnc_lite.html
@@ -229,7 +229,7 @@
rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
rfb.addEventListener("connect", connected);
rfb.addEventListener("disconnect", disconnected);
- rfb.addEventListener("capabilities", function () { updatePowerButtons(); });
+ rfb.addEventListener("capabilities", updatePowerButtons);
rfb.addEventListener("credentialsrequired", credentials);
rfb.addEventListener("desktopname", updateDesktopName);
rfb.scaleViewport = WebUtil.getConfigVar('scale', false);