Skip to content

Commit

Permalink
Some minor JS touchups (#1688)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
joshk and nshoes authored Dec 9, 2024
1 parent 862f1ca commit d721560
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 1 addition & 3 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
8 changes: 4 additions & 4 deletions assets/js/console.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint no-console: ["error", { allow: ["log"] }] */
/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */

import { Socket } from 'phoenix'
import { Terminal } from 'xterm'
Expand Down Expand Up @@ -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 => {
Expand All @@ -175,7 +176,7 @@ channel.on('metadata', payload => {

let downloadingFileBuffer = []

channel.on('file-data/start', payload => {
channel.on('file-data/start', () => {
downloadingFileBuffer = []
})

Expand Down Expand Up @@ -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()

Expand Down
19 changes: 11 additions & 8 deletions assets/ui-rework/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit d721560

Please sign in to comment.