From d7215609eb3c8c5584168d0324bb0d0efa5a269d Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 10 Dec 2024 09:14:35 +1300 Subject: [PATCH] Some minor JS touchups (#1688) - Removed unused JS args in the two `app.js` files and `console.js` - Added an ESLint hint to not warn on an empty catch (try-catch) - And some minor indenting --------- Co-authored-by: Nate Shoemaker --- assets/js/app.js | 4 +--- assets/js/console.js | 8 ++++---- assets/ui-rework/app.js | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index e0ad9404a..c70c751ab 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -281,9 +281,7 @@ Hooks.WorldMap = { }); }, updated() { - let markers = this.markers; - let mode = this.el.dataset.mode; - var devices = []; + let mode = this.el.dataset.mode var myRenderer = L.canvas({ padding: 0.5 }); var clusterLayer = L.markerClusterGroup({ chunkedLoading: true, chunkProgress: this.updateProgressBar }); diff --git a/assets/js/console.js b/assets/js/console.js index 469a81d1c..77d6af06e 100644 --- a/assets/js/console.js +++ b/assets/js/console.js @@ -1,4 +1,5 @@ /* eslint no-console: ["error", { allow: ["log"] }] */ +/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */ import { Socket } from 'phoenix' import { Terminal } from 'xterm' @@ -155,7 +156,7 @@ channel.on('message', payload => { chatBody.scrollTop = chatBody.scrollHeight }) -chatBody.addEventListener('click', e => { +chatBody.addEventListener('click', () => { chatMessage.focus() }) chatMessage.addEventListener('keypress', e => { @@ -175,7 +176,7 @@ channel.on('metadata', payload => { let downloadingFileBuffer = [] -channel.on('file-data/start', payload => { +channel.on('file-data/start', () => { downloadingFileBuffer = [] }) @@ -253,8 +254,7 @@ dropzone.addEventListener( e => { e.preventDefault() e.stopPropagation() - - ;[...e.dataTransfer.items].forEach((item, i) => { + e.dataTransfer.items.forEach(item => { const file = item.getAsFile() const reader = file.stream().getReader() diff --git a/assets/ui-rework/app.js b/assets/ui-rework/app.js index d57b21bd7..764bb3940 100644 --- a/assets/ui-rework/app.js +++ b/assets/ui-rework/app.js @@ -274,9 +274,7 @@ Hooks.WorldMap = { }); }, updated() { - let markers = this.markers; - let mode = this.el.dataset.mode; - var devices = []; + let mode = this.el.dataset.mode var myRenderer = L.canvas({ padding: 0.5 }); var clusterLayer = L.markerClusterGroup({ chunkedLoading: true, chunkProgress: this.updateProgressBar }); @@ -334,12 +332,17 @@ let liveSocket = new LiveSocket('/live', Socket, { // Show progress bar on live navigation and form submits topbar.config({ -barColors: { 0: '#6366F1' }, -barThickness: 1.5, -shadowColor: 'rgba(0, 0, 0, .3)' + barColors: { 0: '#6366F1' }, + barThickness: 1.5, + shadowColor: 'rgba(0, 0, 0, .3)' +}) + +window.addEventListener('phx:page-loading-start', () => { + topbar.show(300) +}) +window.addEventListener('phx:page-loading-stop', () => { + topbar.hide() }) -window.addEventListener('phx:page-loading-start', _info => topbar.show(300)) -window.addEventListener('phx:page-loading-stop', _info => topbar.hide()) liveSocket.connect()