Prefer const/let over var

This commit is contained in:
Juanjo Diaz
2018-05-24 00:27:09 +03:00
parent cdb860ad84
commit 2b5f94fa6a
42 changed files with 1091 additions and 1131 deletions
+3 -3
View File
@@ -9,7 +9,7 @@
import * as Log from './logging.js';
// Touch detection
export var isTouchDevice = ('ontouchstart' in document.documentElement) ||
export let isTouchDevice = ('ontouchstart' in document.documentElement) ||
// requried for Chrome debugger
(document.ontouchstart !== undefined) ||
// required for MS Surface
@@ -20,12 +20,12 @@ window.addEventListener('touchstart', function onFirstTouch() {
window.removeEventListener('touchstart', onFirstTouch, false);
}, false);
var _cursor_uris_supported = null;
let _cursor_uris_supported = null;
export function supportsCursorURIs () {
if (_cursor_uris_supported === null) {
try {
var target = document.createElement('canvas');
const target = document.createElement('canvas');
target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
if (target.style.cursor) {
+9 -8
View File
@@ -20,14 +20,14 @@ export function stopEvent (e) {
}
// Emulate Element.setCapture() when not supported
var _captureRecursion = false;
var _captureElem = null;
let _captureRecursion = false;
let _captureElem = null;
function _captureProxy(e) {
// Recursion protection as we'll see our own event
if (_captureRecursion) return;
// Clone the event as we cannot dispatch an already dispatched event
var newEv = new e.constructor(e.type, e);
const newEv = new e.constructor(e.type, e);
_captureRecursion = true;
_captureElem.dispatchEvent(newEv);
@@ -49,12 +49,13 @@ function _captureProxy(e) {
// Follow cursor style of target element
function _captureElemChanged() {
var captureElem = document.getElementById("noVNC_mouse_capture_elem");
const captureElem = document.getElementById("noVNC_mouse_capture_elem");
captureElem.style.cursor = window.getComputedStyle(_captureElem).cursor;
}
var _captureObserver = new MutationObserver(_captureElemChanged);
var _captureIndex = 0;
const _captureObserver = new MutationObserver(_captureElemChanged);
let _captureIndex = 0;
export function setCapture (elem) {
if (elem.setCapture) {
@@ -69,7 +70,7 @@ export function setCapture (elem) {
// called multiple times without coordination
releaseCapture();
var captureElem = document.getElementById("noVNC_mouse_capture_elem");
let captureElem = document.getElementById("noVNC_mouse_capture_elem");
if (captureElem === null) {
captureElem = document.createElement("div");
@@ -129,7 +130,7 @@ export function releaseCapture () {
_captureObserver.disconnect();
var captureElem = document.getElementById("noVNC_mouse_capture_elem");
const captureElem = document.getElementById("noVNC_mouse_capture_elem");
captureElem.style.display = "none";
window.removeEventListener('mousemove', _captureProxy);
+1 -1
View File
@@ -6,7 +6,7 @@
* See README.md for usage and integration instructions.
*/
var EventTargetMixin = {
const EventTargetMixin = {
_listeners: null,
addEventListener: function(type, callback) {
+5 -5
View File
@@ -10,12 +10,12 @@
* Logging/debug routines
*/
var _log_level = 'warn';
let _log_level = 'warn';
var Debug = function (msg) {};
var Info = function (msg) {};
var Warn = function (msg) {};
var Error = function (msg) {};
let Debug = function (msg) {};
let Info = function (msg) {};
let Warn = function (msg) {};
let Error = function (msg) {};
export function init_logging (level) {
if (typeof level === 'undefined') {
+5 -5
View File
@@ -16,13 +16,13 @@ if (typeof Object.assign != 'function') {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
const to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
for (let index = 1; index < arguments.length; index++) {
const nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
for (let nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
@@ -41,7 +41,7 @@ if (typeof Object.assign != 'function') {
(function () {
function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent( 'CustomEvent' );
const evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
return evt;
}