From dd8613060013040d7e5479de83bb36392dcc7556 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 8 Jul 2021 03:19:34 -0700 Subject: [PATCH] GUACAMOLE-724: Migrate usage of var to const/let in all directly touched code. --- .../client/controllers/clientController.js | 52 +++++++------- .../src/app/client/directives/guacClient.js | 70 +++++++++---------- .../directives/guacClientNotification.js | 66 ++++++++--------- .../app/client/directives/guacClientPanel.js | 8 +-- .../app/client/directives/guacClientZoom.js | 2 +- .../directives/guacFileTransferManager.js | 6 +- .../app/client/directives/guacTiledClients.js | 18 ++--- .../client/directives/guacTiledThumbnails.js | 4 +- .../app/client/services/guacClientManager.js | 42 +++++------ .../src/app/client/types/ManagedClient.js | 68 +++++++++--------- .../app/client/types/ManagedClientGroup.js | 22 +++--- .../app/clipboard/directives/guacClipboard.js | 6 +- .../clipboard/services/clipboardService.js | 16 ++--- .../src/app/element/directives/guacClick.js | 10 +-- .../app/index/controllers/indexController.js | 12 ++-- 15 files changed, 201 insertions(+), 201 deletions(-) diff --git a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js index 12899b7ea..2db800029 100644 --- a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js +++ b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js @@ -24,26 +24,26 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams function clientController($scope, $routeParams, $injector) { // Required types - var ConnectionGroup = $injector.get('ConnectionGroup'); - var ManagedClient = $injector.get('ManagedClient'); - var ManagedClientGroup = $injector.get('ManagedClientGroup'); - var ManagedClientState = $injector.get('ManagedClientState'); - var ManagedFilesystem = $injector.get('ManagedFilesystem'); - var Protocol = $injector.get('Protocol'); - var ScrollState = $injector.get('ScrollState'); + const ConnectionGroup = $injector.get('ConnectionGroup'); + const ManagedClient = $injector.get('ManagedClient'); + const ManagedClientGroup = $injector.get('ManagedClientGroup'); + const ManagedClientState = $injector.get('ManagedClientState'); + const ManagedFilesystem = $injector.get('ManagedFilesystem'); + const Protocol = $injector.get('Protocol'); + const ScrollState = $injector.get('ScrollState'); // Required services - var $location = $injector.get('$location'); - var authenticationService = $injector.get('authenticationService'); - var connectionGroupService = $injector.get('connectionGroupService'); - var clipboardService = $injector.get('clipboardService'); - var dataSourceService = $injector.get('dataSourceService'); - var guacClientManager = $injector.get('guacClientManager'); - var iconService = $injector.get('iconService'); - var preferenceService = $injector.get('preferenceService'); - var requestService = $injector.get('requestService'); - var tunnelService = $injector.get('tunnelService'); - var userPageService = $injector.get('userPageService'); + const $location = $injector.get('$location'); + const authenticationService = $injector.get('authenticationService'); + const connectionGroupService = $injector.get('connectionGroupService'); + const clipboardService = $injector.get('clipboardService'); + const dataSourceService = $injector.get('dataSourceService'); + const guacClientManager = $injector.get('guacClientManager'); + const iconService = $injector.get('iconService'); + const preferenceService = $injector.get('preferenceService'); + const requestService = $injector.get('requestService'); + const tunnelService = $injector.get('tunnelService'); + const userPageService = $injector.get('userPageService'); /** * The minimum number of pixels a drag gesture must move to result in the @@ -230,7 +230,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams $scope.addRemoveClient = function addRemoveClient(id, remove) { // Deconstruct current path into corresponding client IDs - var ids = ManagedClientGroup.getClientIdentifiers($routeParams.id); + const ids = ManagedClientGroup.getClientIdentifiers($routeParams.id); // Add/remove ID as requested if (remove) @@ -247,9 +247,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams * Reloads the contents of $scope.clientGroup to reflect the client IDs * currently listed in the URL. */ - var reparseRoute = function reparseRoute() { + const reparseRoute = function reparseRoute() { - var previousClients = $scope.clientGroup ? $scope.clientGroup.clients.slice() : []; + const previousClients = $scope.clientGroup ? $scope.clientGroup.clients.slice() : []; // Replace existing group with new group setAttachedGroup(guacClientManager.getManagedClientGroup($routeParams.id)); @@ -282,7 +282,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams * @param {ManagedClientGroup} [managedClientGroup] * The ManagedClientGroup to attach to the interface, if any. */ - var setAttachedGroup = function setAttachedGroup(managedClientGroup) { + const setAttachedGroup = function setAttachedGroup(managedClientGroup) { if ($scope.clientGroup) { @@ -290,7 +290,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // seen their status) _.filter($scope.clientGroup.clients, client => { - var connectionState = client.clientState.connectionState; + const connectionState = client.clientState.connectionState; return connectionState === ManagedClientState.ConnectionState.DISCONNECTED || connectionState === ManagedClientState.ConnectionState.TUNNEL_ERROR || connectionState === ManagedClientState.ConnectionState.CLIENT_ERROR; @@ -393,7 +393,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams * @returns {boolean} * true if Ctrl+Alt+Shift has been pressed, false otherwise. */ - var isMenuShortcutPressed = function isMenuShortcutPressed(keyboard) { + const isMenuShortcutPressed = function isMenuShortcutPressed(keyboard) { // Ctrl+Alt+Shift has NOT been pressed if any key is currently held // down that isn't Ctrl, Alt, or Shift @@ -468,7 +468,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // Automatically track and cache the currently-focused client $scope.$on('guacClientFocused', function focusedClientChanged(event, newFocusedClient) { - var oldFocusedClient = $scope.focusedClient; + const oldFocusedClient = $scope.focusedClient; $scope.focusedClient = newFocusedClient; // Apply any parameter changes when focus is changing @@ -543,7 +543,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // Count total number of links within the ManagedClient's share link map var linkCount = 0; - for (var dummy in $scope.focusedClient.shareLinks) + for (const dummy in $scope.focusedClient.shareLinks) linkCount++; return linkCount; diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacClient.js b/guacamole/src/main/frontend/src/app/client/directives/guacClient.js index c1dce868a..717bf6e7b 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacClient.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacClient.js @@ -22,7 +22,7 @@ */ angular.module('client').directive('guacClient', [function guacClient() { - var directive = { + const directive = { restrict: 'E', replace: true, templateUrl: 'app/client/templates/guacClient.html' @@ -51,31 +51,31 @@ angular.module('client').directive('guacClient', [function guacClient() { function guacClientController($scope, $injector, $element) { // Required types - var ManagedClient = $injector.get('ManagedClient'); + const ManagedClient = $injector.get('ManagedClient'); // Required services - var $window = $injector.get('$window'); + const $window = $injector.get('$window'); /** * Whether the local, hardware mouse cursor is in use. * * @type Boolean */ - var localCursor = false; + let localCursor = false; /** * The current Guacamole client instance. * * @type Guacamole.Client */ - var client = null; + let client = null; /** * The display of the current Guacamole client instance. * * @type Guacamole.Display */ - var display = null; + let display = null; /** * The element associated with the display of the current @@ -83,21 +83,21 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Element */ - var displayElement = null; + let displayElement = null; /** * The element which must contain the Guacamole display element. * * @type Element */ - var displayContainer = $element.find('.display')[0]; + const displayContainer = $element.find('.display')[0]; /** * The main containing element for the entire directive. * * @type Element */ - var main = $element[0]; + const main = $element[0]; /** * Guacamole mouse event object, wrapped around the main client @@ -105,7 +105,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Guacamole.Mouse */ - var mouse = new Guacamole.Mouse(displayContainer); + const mouse = new Guacamole.Mouse(displayContainer); /** * Guacamole absolute mouse emulation object, wrapped around the @@ -113,7 +113,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Guacamole.Mouse.Touchscreen */ - var touchScreen = new Guacamole.Mouse.Touchscreen(displayContainer); + const touchScreen = new Guacamole.Mouse.Touchscreen(displayContainer); /** * Guacamole relative mouse emulation object, wrapped around the @@ -121,7 +121,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Guacamole.Mouse.Touchpad */ - var touchPad = new Guacamole.Mouse.Touchpad(displayContainer); + const touchPad = new Guacamole.Mouse.Touchpad(displayContainer); /** * Guacamole touch event handling object, wrapped around the main @@ -129,13 +129,13 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Guacamole.Touch */ - var touch = new Guacamole.Touch(displayContainer); + const touch = new Guacamole.Touch(displayContainer); /** * Updates the scale of the attached Guacamole.Client based on current window * size and "auto-fit" setting. */ - var updateDisplayScale = function updateDisplayScale() { + const updateDisplayScale = function updateDisplayScale() { if (!display) return; @@ -163,19 +163,19 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Guacamole.Mouse.State} mouseState The current mouse * state. */ - var scrollToMouse = function scrollToMouse(mouseState) { + const scrollToMouse = function scrollToMouse(mouseState) { // Determine mouse position within view - var mouse_view_x = mouseState.x + displayContainer.offsetLeft - main.scrollLeft; - var mouse_view_y = mouseState.y + displayContainer.offsetTop - main.scrollTop; + const mouse_view_x = mouseState.x + displayContainer.offsetLeft - main.scrollLeft; + const mouse_view_y = mouseState.y + displayContainer.offsetTop - main.scrollTop; // Determine viewport dimensions - var view_width = main.offsetWidth; - var view_height = main.offsetHeight; + const view_width = main.offsetWidth; + const view_height = main.offsetHeight; // Determine scroll amounts based on mouse position relative to document - var scroll_amount_x; + let scroll_amount_x; if (mouse_view_x > view_width) scroll_amount_x = mouse_view_x - view_width; else if (mouse_view_x < 0) @@ -183,7 +183,7 @@ angular.module('client').directive('guacClient', [function guacClient() { else scroll_amount_x = 0; - var scroll_amount_y; + let scroll_amount_y; if (mouse_view_y > view_height) scroll_amount_y = mouse_view_y - view_height; else if (mouse_view_y < 0) @@ -206,7 +206,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Guacamole.Mouse.MouseEvent} event * The mouse event to handle. */ - var handleMouseEvent = function handleMouseEvent(event) { + const handleMouseEvent = function handleMouseEvent(event) { // Do not attempt to handle mouse state changes if the client // or display are not yet available @@ -231,7 +231,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Guacamole.Mouse.MouseEvent} event * The mouse event to handle. */ - var handleEmulatedMouseEvent = function handleEmulatedMouseEvent(event) { + const handleEmulatedMouseEvent = function handleEmulatedMouseEvent(event) { // Do not attempt to handle mouse state changes if the client // or display are not yet available @@ -256,7 +256,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Guacamole.Touch.Event} touchEvent * The touch event. */ - var handleTouchEvent = function handleTouchEvent(event) { + const handleTouchEvent = function handleTouchEvent(event) { // Do not attempt to handle touch state changes if the client // or display are not yet available @@ -404,9 +404,9 @@ angular.module('client').directive('guacClient', [function guacClient() { // Connect, if not already connected ManagedClient.connect($scope.client, main.offsetWidth, main.offsetHeight); - var pixelDensity = $window.devicePixelRatio || 1; - var width = main.offsetWidth * pixelDensity; - var height = main.offsetHeight * pixelDensity; + const pixelDensity = $window.devicePixelRatio || 1; + const width = main.offsetWidth * pixelDensity; + const height = main.offsetHeight * pixelDensity; if (display.getWidth() !== width || display.getHeight() !== height) client.sendSize(width, height); @@ -436,7 +436,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Number */ - var initialScale = null; + let initialScale = null; /** * If a pinch gesture is in progress, the X coordinate of the point on the @@ -445,7 +445,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Number */ - var initialCenterX = 0; + let initialCenterX = 0; /** * If a pinch gesture is in progress, the Y coordinate of the point on the @@ -454,7 +454,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * * @type Number */ - var initialCenterY = 0; + let initialCenterY = 0; // Zoom and pan client via pinch gestures $scope.clientPinch = function clientPinch(inProgress, startLength, currentLength, centerX, centerY) { @@ -484,7 +484,7 @@ angular.module('client').directive('guacClient', [function guacClient() { } // Determine new scale absolutely - var currentScale = initialScale * currentLength / startLength; + let currentScale = initialScale * currentLength / startLength; // Fix scale within limits - scroll will be miscalculated otherwise currentScale = Math.max(currentScale, $scope.client.clientProperties.minScale); @@ -564,7 +564,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Event} e * The event related to the in-progress drag/drop operation. */ - var notifyDragStart = function notifyDragStart(e) { + const notifyDragStart = function notifyDragStart(e) { e.preventDefault(); e.stopPropagation(); @@ -583,7 +583,7 @@ angular.module('client').directive('guacClient', [function guacClient() { * @param {Event} e * The event related to the end of the former drag/drop operation. */ - var notifyDragEnd = function notifyDragEnd(e) { + const notifyDragEnd = function notifyDragEnd(e) { e.preventDefault(); e.stopPropagation(); @@ -608,8 +608,8 @@ angular.module('client').directive('guacClient', [function guacClient() { return; // Upload each file - var files = e.dataTransfer.files; - for (var i=0; i client.clientProperties.focused); + const focusedClients = _.filter(managedClientGroup.clients, client => client.clientProperties.focused); if (focusedClients.length === 1) return focusedClients[0]; } @@ -121,10 +121,10 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient // via shift-click if (shift) { - var minRow = $scope.clientGroup.rows - 1; - var minColumn = $scope.clientGroup.columns - 1; - var maxRow = 0; - var maxColumn = 0; + let minRow = $scope.clientGroup.rows - 1; + let minColumn = $scope.clientGroup.columns - 1; + let maxRow = 0; + let maxColumn = 0; // Determine extents of selected area ManagedClientGroup.forEach($scope.clientGroup, (client, row, column) => { diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacTiledThumbnails.js b/guacamole/src/main/frontend/src/app/client/directives/guacTiledThumbnails.js index 6436f0603..e6417c93b 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacTiledThumbnails.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacTiledThumbnails.js @@ -23,7 +23,7 @@ */ angular.module('client').directive('guacTiledThumbnails', [function guacTiledThumbnails() { - var directive = { + const directive = { restrict: 'E', replace: true, templateUrl: 'app/client/templates/guacTiledThumbnails.html' @@ -45,7 +45,7 @@ angular.module('client').directive('guacTiledThumbnails', [function guacTiledThu function guacTiledThumbnailsController($scope, $injector, $element) { // Required types - var ManagedClientGroup = $injector.get('ManagedClientGroup'); + const ManagedClientGroup = $injector.get('ManagedClientGroup'); /** * The overall height of the thumbnail view of the tiled grid of diff --git a/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js b/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js index 6dd8ced52..990d10cde 100644 --- a/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js +++ b/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js @@ -24,12 +24,12 @@ angular.module('client').factory('guacClientManager', ['$injector', function guacClientManager($injector) { // Required types - var ManagedClient = $injector.get('ManagedClient'); - var ManagedClientGroup = $injector.get('ManagedClientGroup'); + const ManagedClient = $injector.get('ManagedClient'); + const ManagedClientGroup = $injector.get('ManagedClientGroup'); // Required services - var $window = $injector.get('$window'); - var sessionStorageFactory = $injector.get('sessionStorageFactory'); + const $window = $injector.get('$window'); + const sessionStorageFactory = $injector.get('sessionStorageFactory'); var service = {}; @@ -63,7 +63,7 @@ angular.module('client').factory('guacClientManager', ['$injector', * * @type Function */ - var storedManagedClientGroups = sessionStorageFactory.create([], function destroyClientGroupStorage() { + const storedManagedClientGroups = sessionStorageFactory.create([], function destroyClientGroupStorage() { // Disconnect all clients when storage is destroyed service.clear(); @@ -89,13 +89,13 @@ angular.module('client').factory('guacClientManager', ['$injector', * @param {string} id * The ID of the ManagedClient to remove. */ - var ungroupManagedClient = function ungroupManagedClient(id) { + const ungroupManagedClient = function ungroupManagedClient(id) { - var managedClientGroups = storedManagedClientGroups(); + const managedClientGroups = storedManagedClientGroups(); // Remove client from all groups managedClientGroups.forEach(group => { - var removed = _.remove(group.clients, client => (client.id === id)); + const removed = _.remove(group.clients, client => (client.id === id)); if (removed.length) { // Reset focus state if client is being removed from a group @@ -165,20 +165,20 @@ angular.module('client').factory('guacClientManager', ['$injector', */ service.replaceManagedClient = function replaceManagedClient(id) { - var managedClients = storedManagedClients(); - var managedClientGroups = storedManagedClientGroups(); + const managedClients = storedManagedClients(); + const managedClientGroups = storedManagedClientGroups(); // Remove client if it exists if (id in managedClients) { - var hadFocus = managedClients[id].clientProperties.focused; + const hadFocus = managedClients[id].clientProperties.focused; managedClients[id].client.disconnect(); delete managedClients[id]; // Remove client from all groups managedClientGroups.forEach(group => { - var index = _.findIndex(group.clients, client => (client.id === id)); + const index = _.findIndex(group.clients, client => (client.id === id)); if (index === -1) return; @@ -235,8 +235,8 @@ angular.module('client').factory('guacClientManager', ['$injector', */ service.getManagedClientGroup = function getManagedClientGroup(id) { - var managedClientGroups = storedManagedClientGroups(); - var existingGroup = _.find(managedClientGroups, (group) => { + const managedClientGroups = storedManagedClientGroups(); + const existingGroup = _.find(managedClientGroups, (group) => { return id === ManagedClientGroup.getIdentifier(group); }); @@ -244,8 +244,8 @@ angular.module('client').factory('guacClientManager', ['$injector', if (existingGroup) return existingGroup; - var clients = []; - var clientIds = ManagedClientGroup.getClientIdentifiers(id); + const clients = []; + const clientIds = ManagedClientGroup.getClientIdentifiers(id); // Separate active clients by whether they should be displayed within // the current view @@ -253,7 +253,7 @@ angular.module('client').factory('guacClientManager', ['$injector', clients.push(service.getManagedClient(id)); }); - var group = new ManagedClientGroup({ + const group = new ManagedClientGroup({ clients : clients }); @@ -279,17 +279,17 @@ angular.module('client').factory('guacClientManager', ['$injector', */ service.removeManagedClientGroup = function removeManagedClientGroup(id) { - var managedClients = storedManagedClients(); - var managedClientGroups = storedManagedClientGroups(); + const managedClients = storedManagedClients(); + const managedClientGroups = storedManagedClientGroups(); // Remove all matching groups (there SHOULD only be one) - var removed = _.remove(managedClientGroups, (group) => ManagedClientGroup.getIdentifier(group) === id); + const removed = _.remove(managedClientGroups, (group) => ManagedClientGroup.getIdentifier(group) === id); // Disconnect all clients associated with the removed group(s) removed.forEach((group) => { group.clients.forEach((client) => { - var id = client.id; + const id = client.id; if (managedClients[id]) { managedClients[id].client.disconnect(); delete managedClients[id]; diff --git a/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js b/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js index 22d1690e2..ff120d55c 100644 --- a/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js +++ b/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js @@ -24,34 +24,34 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', function defineManagedClient($rootScope, $injector) { // Required types - var ClientProperties = $injector.get('ClientProperties'); - var ClientIdentifier = $injector.get('ClientIdentifier'); - var ClipboardData = $injector.get('ClipboardData'); - var ManagedArgument = $injector.get('ManagedArgument'); - var ManagedClientState = $injector.get('ManagedClientState'); - var ManagedClientThumbnail = $injector.get('ManagedClientThumbnail'); - var ManagedDisplay = $injector.get('ManagedDisplay'); - var ManagedFilesystem = $injector.get('ManagedFilesystem'); - var ManagedFileUpload = $injector.get('ManagedFileUpload'); - var ManagedShareLink = $injector.get('ManagedShareLink'); + const ClientProperties = $injector.get('ClientProperties'); + const ClientIdentifier = $injector.get('ClientIdentifier'); + const ClipboardData = $injector.get('ClipboardData'); + const ManagedArgument = $injector.get('ManagedArgument'); + const ManagedClientState = $injector.get('ManagedClientState'); + const ManagedClientThumbnail = $injector.get('ManagedClientThumbnail'); + const ManagedDisplay = $injector.get('ManagedDisplay'); + const ManagedFilesystem = $injector.get('ManagedFilesystem'); + const ManagedFileUpload = $injector.get('ManagedFileUpload'); + const ManagedShareLink = $injector.get('ManagedShareLink'); // Required services - var $document = $injector.get('$document'); - var $q = $injector.get('$q'); - var $rootScope = $injector.get('$rootScope'); - var $window = $injector.get('$window'); - var activeConnectionService = $injector.get('activeConnectionService'); - var authenticationService = $injector.get('authenticationService'); - var clipboardService = $injector.get('clipboardService'); - var connectionGroupService = $injector.get('connectionGroupService'); - var connectionService = $injector.get('connectionService'); - var preferenceService = $injector.get('preferenceService'); - var requestService = $injector.get('requestService'); - var tunnelService = $injector.get('tunnelService'); - var guacAudio = $injector.get('guacAudio'); - var guacHistory = $injector.get('guacHistory'); - var guacImage = $injector.get('guacImage'); - var guacVideo = $injector.get('guacVideo'); + const $document = $injector.get('$document'); + const $q = $injector.get('$q'); + const $rootScope = $injector.get('$rootScope'); + const $window = $injector.get('$window'); + const activeConnectionService = $injector.get('activeConnectionService'); + const authenticationService = $injector.get('authenticationService'); + const clipboardService = $injector.get('clipboardService'); + const connectionGroupService = $injector.get('connectionGroupService'); + const connectionService = $injector.get('connectionService'); + const preferenceService = $injector.get('preferenceService'); + const requestService = $injector.get('requestService'); + const tunnelService = $injector.get('tunnelService'); + const guacAudio = $injector.get('guacAudio'); + const guacHistory = $injector.get('guacHistory'); + const guacImage = $injector.get('guacImage'); + const guacVideo = $injector.get('guacVideo'); /** * The minimum amount of time to wait between updates to the client @@ -253,18 +253,18 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', * A promise which resolves with the string of connection parameters to * be passed to the Guacamole client, once the string is ready. */ - var getConnectString = function getConnectString(identifier, width, height) { + const getConnectString = function getConnectString(identifier, width, height) { - var deferred = $q.defer(); + const deferred = $q.defer(); // Calculate optimal width/height for display - var pixel_density = $window.devicePixelRatio || 1; - var optimal_dpi = pixel_density * 96; - var optimal_width = width * pixel_density; - var optimal_height = height * pixel_density; + const pixel_density = $window.devicePixelRatio || 1; + const optimal_dpi = pixel_density * 96; + const optimal_width = width * pixel_density; + const optimal_height = height * pixel_density; // Build base connect string - var connectString = + let connectString = "token=" + encodeURIComponent(authenticationService.getCurrentToken()) + "&GUAC_DATA_SOURCE=" + encodeURIComponent(identifier.dataSource) + "&GUAC_ID=" + encodeURIComponent(identifier.id) @@ -676,7 +676,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', return; // Parse connection details from ID - var clientIdentifier = ClientIdentifier.fromString(managedClient.id); + const clientIdentifier = ClientIdentifier.fromString(managedClient.id); // Connect the Guacamole client getConnectString(clientIdentifier, width, height) diff --git a/guacamole/src/main/frontend/src/app/client/types/ManagedClientGroup.js b/guacamole/src/main/frontend/src/app/client/types/ManagedClientGroup.js index e2c342329..cd42bdc75 100644 --- a/guacamole/src/main/frontend/src/app/client/types/ManagedClientGroup.js +++ b/guacamole/src/main/frontend/src/app/client/types/ManagedClientGroup.js @@ -33,7 +33,7 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de * The object whose properties should be copied within the new * ManagedClientGroup. */ - var ManagedClientGroup = function ManagedClientGroup(template) { + const ManagedClientGroup = function ManagedClientGroup(template) { // Use empty object by default template = template || {}; @@ -97,7 +97,7 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de */ ManagedClientGroup.recalculateTiles = function recalculateTiles(group) { - var recalculated = new ManagedClientGroup({ + const recalculated = new ManagedClientGroup({ clients : group.clients }); @@ -222,7 +222,7 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de // Generate a name from ONLY the focused clients, unless there are no // focused clients - var relevantClients = _.filter(group.clients, client => client.clientProperties.focused); + let relevantClients = _.filter(group.clients, client => client.clientProperties.focused); if (!relevantClients.length) relevantClients = group.clients; @@ -262,9 +262,9 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de * ManagedClientGroup. */ ManagedClientGroup.forEach = function forEach(group, callback) { - var current = 0; - for (var row = 0; row < group.rows; row++) { - for (var column = 0; column < group.columns; column++) { + let current = 0; + for (let row = 0; row < group.rows; row++) { + for (let column = 0; column < group.columns; column++) { callback(group.clients[current], row, column, current); current++; @@ -312,22 +312,22 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de */ ManagedClientGroup.getClientGrid = function getClientGrid(group) { - var index = 0; + let index = 0; // Operate on cached copy of grid - var clientGrid = group._grid || (group._grid = []); + const clientGrid = group._grid || (group._grid = []); // Delete any rows in excess of the required size clientGrid.splice(group.rows); - for (var row = 0; row < group.rows; row++) { + for (let row = 0; row < group.rows; row++) { // Prefer to use existing column arrays, deleting any columns in // excess of the required size - var currentRow = clientGrid[row] || (clientGrid[row] = []); + const currentRow = clientGrid[row] || (clientGrid[row] = []); currentRow.splice(group.columns); - for (var column = 0; column < group.columns; column++) { + for (let column = 0; column < group.columns; column++) { currentRow[column] = group.clients[index++] || null; } diff --git a/guacamole/src/main/frontend/src/app/clipboard/directives/guacClipboard.js b/guacamole/src/main/frontend/src/app/clipboard/directives/guacClipboard.js index fedca828b..f89494c4c 100644 --- a/guacamole/src/main/frontend/src/app/clipboard/directives/guacClipboard.js +++ b/guacamole/src/main/frontend/src/app/clipboard/directives/guacClipboard.js @@ -27,10 +27,10 @@ angular.module('clipboard').directive('guacClipboard', ['$injector', function guacClipboard($injector) { // Required types - var ClipboardData = $injector.get('ClipboardData'); + const ClipboardData = $injector.get('ClipboardData'); // Required services - var clipboardService = $injector.get('clipboardService'); + const clipboardService = $injector.get('clipboardService'); /** * Configuration object for the guacClipboard directive. @@ -78,7 +78,7 @@ angular.module('clipboard').directive('guacClipboard', ['$injector', * The ClipboardData to display within the clipboard editor for * editing. */ - var updateClipboardEditor = function updateClipboardEditor(data) { + const updateClipboardEditor = function updateClipboardEditor(data) { // If the clipboard data is a string, render it as text if (typeof data.data === 'string') diff --git a/guacamole/src/main/frontend/src/app/clipboard/services/clipboardService.js b/guacamole/src/main/frontend/src/app/clipboard/services/clipboardService.js index a7da73fcc..0c8409b54 100644 --- a/guacamole/src/main/frontend/src/app/clipboard/services/clipboardService.js +++ b/guacamole/src/main/frontend/src/app/clipboard/services/clipboardService.js @@ -26,13 +26,13 @@ angular.module('clipboard').factory('clipboardService', ['$injector', function clipboardService($injector) { // Get required services - var $q = $injector.get('$q'); - var $window = $injector.get('$window'); - var $rootScope = $injector.get('$rootScope'); - var sessionStorageFactory = $injector.get('sessionStorageFactory'); + const $q = $injector.get('$q'); + const $window = $injector.get('$window'); + const $rootScope = $injector.get('$rootScope'); + const sessionStorageFactory = $injector.get('sessionStorageFactory'); // Required types - var ClipboardData = $injector.get('ClipboardData'); + const ClipboardData = $injector.get('ClipboardData'); /** * Getter/setter which retrieves or sets the current stored clipboard @@ -42,7 +42,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector', * * @type Function */ - var storedClipboardData = sessionStorageFactory.create(new ClipboardData()); + const storedClipboardData = sessionStorageFactory.create(new ClipboardData()); var service = {}; @@ -189,7 +189,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector', * A promise that will resolve if setting the clipboard was successful, * and will reject if it failed. */ - var setLocalClipboard = function setLocalClipboard(data) { + const setLocalClipboard = function setLocalClipboard(data) { var deferred = $q.defer(); @@ -437,7 +437,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector', * if getting the clipboard was successful, and will reject if it * failed. */ - var getLocalClipboard = function getLocalClipboard() { + const getLocalClipboard = function getLocalClipboard() { // If the clipboard is already being read, do not overlap the read // attempts; instead share the result across all requests diff --git a/guacamole/src/main/frontend/src/app/element/directives/guacClick.js b/guacamole/src/main/frontend/src/app/element/directives/guacClick.js index ef847e0d1..230b18c6c 100644 --- a/guacamole/src/main/frontend/src/app/element/directives/guacClick.js +++ b/guacamole/src/main/frontend/src/app/element/directives/guacClick.js @@ -48,21 +48,21 @@ angular.module('element').directive('guacClick', [function guacClick() { * * @type guacClick~callback */ - var guacClick = $scope.$eval($attrs.guacClick); + const guacClick = $scope.$eval($attrs.guacClick); /** * The element which will register the click. * * @type Element */ - var element = $element[0]; + const element = $element[0]; /** * Whether either Shift key is currently pressed. * * @type boolean */ - var shift = false; + let shift = false; /** * Whether either Ctrl key is currently pressed. To allow the @@ -71,7 +71,7 @@ angular.module('element').directive('guacClick', [function guacClick() { * * @type boolean */ - var ctrl = false; + let ctrl = false; /** * Updates the state of the {@link shift} and {@link ctrl} flags @@ -81,7 +81,7 @@ angular.module('element').directive('guacClick', [function guacClick() { * @param {Guacamole.Keyboard} keyboard * The Guacamole.Keyboard instance to read key states from. */ - var updateModifiers = function updateModifiers(keyboard) { + const updateModifiers = function updateModifiers(keyboard) { shift = !!( keyboard.pressed[0xFFE1] // Left shift diff --git a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js index 5f7e70211..4d3bf9b73 100644 --- a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js +++ b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js @@ -24,12 +24,12 @@ angular.module('index').controller('indexController', ['$scope', '$injector', function indexController($scope, $injector) { // Required services - var $document = $injector.get('$document'); - var $route = $injector.get('$route'); - var $window = $injector.get('$window'); - var clipboardService = $injector.get('clipboardService'); - var guacNotification = $injector.get('guacNotification'); - var guacClientManager = $injector.get('guacClientManager'); + const $document = $injector.get('$document'); + const $route = $injector.get('$route'); + const $window = $injector.get('$window'); + const clipboardService = $injector.get('clipboardService'); + const guacNotification = $injector.get('guacNotification'); + const guacClientManager = $injector.get('guacClientManager'); /** * The error that prevents the current page from rendering at all. If no