From 0d779c6032ea5fbf0ef8c61515f5e95ef547dd38 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 23:10:07 -0700 Subject: [PATCH] refactor: avoid using `var` --- appIcons.js | 10 +++++----- intellihide.js | 2 +- panel.js | 2 +- prefs.js | 4 ++-- taskbar.js | 4 ++-- utils.js | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/appIcons.js b/appIcons.js index fedf226..01be947 100644 --- a/appIcons.js +++ b/appIcons.js @@ -1412,10 +1412,10 @@ export function getInterestingWindows(app, monitor, isolateMonitors) { } export function cssHexTocssRgba(cssHex, opacity) { - var bigint = parseInt(cssHex.slice(1), 16); - var r = (bigint >> 16) & 255; - var g = (bigint >> 8) & 255; - var b = bigint & 255; + let bigint = parseInt(cssHex.slice(1), 16); + let r = (bigint >> 16) & 255; + let g = (bigint >> 8) & 255; + let b = bigint & 255; return 'rgba(' + [r, g, b].join(',') + ',' + opacity + ')'; } @@ -1851,7 +1851,7 @@ export const MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { return; } - for (var entry = 0; entry < commandList.length; entry++) { + for (let entry = 0; entry < commandList.length; entry++) { _appendItem({ title: titleList[entry], cmd: commandList[entry].split(' ') diff --git a/intellihide.js b/intellihide.js index ea5873c..e47171f 100644 --- a/intellihide.js +++ b/intellihide.js @@ -42,7 +42,7 @@ const T2 = 'limitUpdateTimeout'; const T3 = 'postAnimateTimeout'; const T4 = 'panelBoxClipTimeout'; -var SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / (OverviewControls.SIDE_CONTROLS_ANIMATION_TIME > 1 ? 1000 : 1); +const SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / (OverviewControls.SIDE_CONTROLS_ANIMATION_TIME > 1 ? 1000 : 1); export const Hold = { NONE: 0, diff --git a/panel.js b/panel.js index 62cd29d..cb88701 100644 --- a/panel.js +++ b/panel.js @@ -1223,7 +1223,7 @@ export const Panel = GObject.registerClass({ return; } - var scrollDelay = SETTINGS.get_int('scroll-panel-delay'); + const scrollDelay = SETTINGS.get_int('scroll-panel-delay'); if (scrollDelay) { this._timeoutsHandler.add([T6, scrollDelay, () => {}]); diff --git a/prefs.js b/prefs.js index bc16ad5..6da427e 100644 --- a/prefs.js +++ b/prefs.js @@ -142,7 +142,7 @@ function checkHotkeyPrefix(settings) { } function mergeObjects(main, bck) { - for (var prop in bck) { + for (const prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { main[prop] = bck[prop]; } @@ -1933,7 +1933,7 @@ const Preferences = class { {objectName: 'panel_length_scale', valueName: '', range: LENGTH_MARKS } ]; - for(var idx in sizeScales) { + for(const idx in sizeScales) { let size_scale = this._builder.get_object(sizeScales[idx].objectName); let range = sizeScales[idx].range; size_scale.set_range(range[range.length - 1], range[0]); diff --git a/taskbar.js b/taskbar.js index b738544..f3018f3 100644 --- a/taskbar.js +++ b/taskbar.js @@ -47,7 +47,7 @@ import {SETTINGS} from './extension.js'; const SearchController = Main.overview.searchController; export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); -var DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; +const DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; export const MIN_ICON_SIZE = 4; const T1 = 'ensureAppIconVisibilityTimeout' @@ -1530,7 +1530,7 @@ export const TaskbarItemContainer = GObject.registerClass({ } }); -var DragPlaceholderItem = GObject.registerClass({ +const DragPlaceholderItem = GObject.registerClass({ }, class DragPlaceholderItem extends St.Widget { _init(appIcon, iconSize, isVertical) { diff --git a/utils.js b/utils.js index 8e5348d..b1fd40c 100644 --- a/utils.js +++ b/utils.js @@ -35,7 +35,7 @@ import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; const Gi = imports._gi; -var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); +const SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); // simplify global signals and function injections handling // abstract class @@ -270,7 +270,7 @@ export const find = function(array, predicate) { }; export const mergeObjects = function(main, bck) { - for (var prop in bck) { + for (const prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { main[prop] = bck[prop]; } @@ -869,8 +869,8 @@ export const drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, is height = 2.0 * Math.floor(height / 2.0); - var leftRadius = isRoundLeft ? height / 2.0 : 0.0; - var rightRadius = isRoundRight ? height / 2.0 : 0.0; + const leftRadius = isRoundLeft ? height / 2.0 : 0.0; + const rightRadius = isRoundRight ? height / 2.0 : 0.0; cr.moveTo(x + width - rightRadius, y); cr.lineTo(x + leftRadius, y);