Skip to content

Commit

Permalink
linting cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
netbymatt committed Oct 22, 2024
1 parent 487c83f commit e2d7a96
Show file tree
Hide file tree
Showing 8 changed files with 900 additions and 584 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// express
// eslint-disable-next-line import/no-extraneous-dependencies
const express = require('express');

const app = express();
Expand Down
1,243 changes: 780 additions & 463 deletions package-lock.json

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions server/scripts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ const loadData = (_latLon, haveDataCallback) => {

const swipeCallBack = (direction) => {
switch (direction) {
case 'left':
btnNavigateNextClick();
break;

case 'right':
default:
btnNavigatePreviousClick();
break;
case 'left':
btnNavigateNextClick();
break;

case 'right':
default:
btnNavigatePreviousClick();
break;
}
};

Expand Down Expand Up @@ -312,41 +312,41 @@ const documentKeydown = (e) => {

if (document.fullscreenElement || document.activeElement === document.body) {
switch (key) {
case ' ': // Space
// don't scroll
e.preventDefault();
btnNavigatePlayClick();
return false;

case 'ArrowRight':
case 'PageDown':
// don't scroll
e.preventDefault();
btnNavigateNextClick();
return false;

case 'ArrowLeft':
case 'PageUp':
// don't scroll
e.preventDefault();
btnNavigatePreviousClick();
return false;

case 'ArrowUp': // Home
e.preventDefault();
btnNavigateMenuClick();
return false;

case '0': // "O" Restart
btnNavigateRefreshClick();
return false;

case 'F':
case 'f':
btnFullScreenClick();
return false;

default:
case ' ': // Space
// don't scroll
e.preventDefault();
btnNavigatePlayClick();
return false;

case 'ArrowRight':
case 'PageDown':
// don't scroll
e.preventDefault();
btnNavigateNextClick();
return false;

case 'ArrowLeft':
case 'PageUp':
// don't scroll
e.preventDefault();
btnNavigatePreviousClick();
return false;

case 'ArrowUp': // Home
e.preventDefault();
btnNavigateMenuClick();
return false;

case '0': // "O" Restart
btnNavigateRefreshClick();
return false;

case 'F':
case 'f':
btnFullScreenClick();
return false;

default:
}
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions server/scripts/modules/hazards.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import STATUS from './status.mjs';
import { json } from './utils/fetch.mjs';
import WeatherDisplay from './weatherdisplay.mjs';
import { registerDisplay, msg } from './navigation.mjs';
import { registerDisplay } from './navigation.mjs';

const hazardLevels = {
Extreme: 10,
Expand All @@ -14,7 +14,7 @@ const hazardModifiers = {
'Hurricane Warning': 2,
'Tornado Warning': 3,
'Severe Thunderstorm Warning': 1,
}
};

class Hazards extends WeatherDisplay {
constructor(navId, elemId, defaultActive) {
Expand Down Expand Up @@ -160,7 +160,7 @@ const calcSeverity = (severity, event) => {
const baseSeverity = hazardLevels[severity] ?? 0;
const modifiedSeverity = hazardModifiers[event] ?? 0;
return baseSeverity + modifiedSeverity;
}
};

// register display
registerDisplay(new Hazards(0, 'hazards', true));
48 changes: 24 additions & 24 deletions server/scripts/modules/navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -238,30 +238,30 @@ const setPlaying = (newValue) => {
// handle all navigation buttons
const handleNavButton = (button) => {
switch (button) {
case 'play':
setPlaying(true);
break;
case 'playToggle':
setPlaying(!playing);
break;
case 'stop':
setPlaying(false);
break;
case 'next':
setPlaying(false);
navTo(msg.command.nextFrame);
break;
case 'previous':
setPlaying(false);
navTo(msg.command.previousFrame);
break;
case 'menu':
setPlaying(false);
progress.showCanvas();
hideAllCanvases();
break;
default:
console.error(`Unknown navButton ${button}`);
case 'play':
setPlaying(true);
break;
case 'playToggle':
setPlaying(!playing);
break;
case 'stop':
setPlaying(false);
break;
case 'next':
setPlaying(false);
navTo(msg.command.nextFrame);
break;
case 'previous':
setPlaying(false);
navTo(msg.command.previousFrame);
break;
case 'menu':
setPlaying(false);
progress.showCanvas();
hideAllCanvases();
break;
default:
console.error(`Unknown navButton ${button}`);
}
};

Expand Down
28 changes: 14 additions & 14 deletions server/scripts/modules/status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const STATUS = {

const calcStatusClass = (statusCode) => {
switch (statusCode) {
case STATUS.loading:
return 'loading';
case STATUS.loaded:
return 'press-here';
case STATUS.failed:
return 'failed';
case STATUS.noData:
return 'no-data';
case STATUS.disabled:
return 'disabled';
case STATUS.retrying:
return 'retrying';
default:
return '';
case STATUS.loading:
return 'loading';
case STATUS.loaded:
return 'press-here';
case STATUS.failed:
return 'failed';
case STATUS.noData:
return 'no-data';
case STATUS.disabled:
return 'disabled';
case STATUS.retrying:
return 'retrying';
default:
return '';
}
};

Expand Down
26 changes: 13 additions & 13 deletions server/scripts/modules/utils/fetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const fetchAsync = async (_url, responseType, _params = {}) => {
if (!response.ok) throw new Error(`Fetch error ${response.status} ${response.statusText} while fetching ${response.url}`);
// return the requested response
switch (responseType) {
case 'json':
return response.json();
case 'text':
return response.text();
case 'blob':
return response.blob();
default:
return response;
case 'json':
return response.json();
case 'text':
return response.text();
case 'blob':
return response.blob();
default:
return response;
}
};

Expand Down Expand Up @@ -84,11 +84,11 @@ const delay = (time, func, ...args) => new Promise((resolve) => {

const retryDelay = (retryNumber) => {
switch (retryNumber) {
case 1: return 1000;
case 2: return 2000;
case 3: return 5000;
case 4: return 10_000;
default: return 30_000;
case 1: return 1000;
case 2: return 2000;
case 3: return 5000;
case 4: return 10_000;
default: return 30_000;
}
};

Expand Down
46 changes: 23 additions & 23 deletions server/scripts/modules/utils/setting.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class Setting {

// call the change function on startup
switch (type) {
case 'select':
this.selectChange({ target: { value: this.myValue } });
break;
case 'checkbox':
default:
this.checkboxChange({ target: { checked: this.myValue } });
case 'select':
this.selectChange({ target: { value: this.myValue } });
break;
case 'checkbox':
default:
this.checkboxChange({ target: { checked: this.myValue } });
}
}

Expand Down Expand Up @@ -129,12 +129,12 @@ class Setting {
const storedValue = JSON.parse(allSettings)?.[this.shortName];
if (storedValue !== undefined) {
switch (this.type) {
case 'boolean':
return storedValue;
case 'select':
return storedValue;
default:
return null;
case 'boolean':
return storedValue;
case 'select':
return storedValue;
default:
return null;
}
}
}
Expand All @@ -152,12 +152,12 @@ class Setting {
// update the state
this.myValue = newValue;
switch (this.type) {
case 'select':
this.selectHighlight(newValue);
break;
case 'checkbox':
default:
this.element.checked = newValue;
case 'select':
this.selectHighlight(newValue);
break;
case 'checkbox':
default:
this.element.checked = newValue;
}
this.storeToLocalStorage(this.myValue);

Expand All @@ -174,11 +174,11 @@ class Setting {

generate() {
switch (this.type) {
case 'select':
return this.generateSelect();
case 'checkbox':
default:
return this.generateCheckbox();
case 'select':
return this.generateSelect();
case 'checkbox':
default:
return this.generateCheckbox();
}
}
}
Expand Down

0 comments on commit e2d7a96

Please sign in to comment.