Skip to content

Commit

Permalink
Refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
cherriae committed Feb 19, 2025
1 parent 11df5cf commit 4a9995f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 18 deletions.
4 changes: 3 additions & 1 deletion app/static/js/CanvasCoordinateSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class CanvasCoordinateSystem {
}

drawPath(points, color = 'red', width = 2) {
if (!points || points.length < 2) return;
if (!points || points.length < 2) {
return;
}

this.ctx.beginPath();
this.ctx.moveTo(points[0].x, points[0].y);
Expand Down
32 changes: 24 additions & 8 deletions app/static/js/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ function updateTeamCards(data) {
const cardNum = index + 1;
const cardId = `team${cardNum}-info`;
const card = document.getElementById(cardId);
if (!card) return;
if (!card) {
return;
}

// Show the card
card.classList.remove('hidden');
Expand Down Expand Up @@ -124,13 +126,17 @@ function updateTeamCards(data) {
// Hide team3 card if no third team
if (Object.keys(data).length < 3) {
const team3Card = document.getElementById('team3-info');
if (team3Card) team3Card.classList.add('hidden');
if (team3Card) {
team3Card.classList.add('hidden');
}
}
}

function updateRadarChart(data) {
const canvas = document.getElementById('radarChart');
if (!canvas) return;
if (!canvas) {
return;
}

if (radarChart) {
radarChart.destroy();
Expand Down Expand Up @@ -197,7 +203,9 @@ window.addEventListener('resize', () => {

function updateRawDataTable(data) {
const tbody = document.getElementById('raw-data-tbody');
if (!tbody) return;
if (!tbody) {
return;
}

tbody.innerHTML = '';

Expand Down Expand Up @@ -310,7 +318,9 @@ function resizeModalCanvas() {
}

function redrawPaths() {
if (!modalCoordSystem || !currentPathData) return;
if (!modalCoordSystem || !currentPathData) {
return;
}

modalCoordSystem.clear();

Expand Down Expand Up @@ -346,7 +356,9 @@ function redrawPaths() {
}

function zoomIn(event) {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
const rect = modalCanvas.getBoundingClientRect();
let mouseX = rect.width / 2;
let mouseY = rect.height / 2;
Expand All @@ -356,7 +368,9 @@ function zoomIn(event) {
}

function zoomOut(event) {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
const rect = modalCanvas.getBoundingClientRect();
let mouseX = rect.width / 2;
let mouseY = rect.height / 2;
Expand All @@ -366,7 +380,9 @@ function zoomOut(event) {
}

function resetZoom() {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
modalCoordSystem.resetView();
redrawPaths();
}
Expand Down
16 changes: 12 additions & 4 deletions app/static/js/scout.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,19 @@ function startDrawing(e) {
}

function draw(e) {
if (!isDrawing) return;
if (!isDrawing) {
return;
}
e.preventDefault();
const point = getPointFromEvent(e);
currentPath.push(point);
redrawPaths();
}

function stopDrawing(e) {
if (!isDrawing) return;
if (!isDrawing) {
return;
}
e.preventDefault();
isDrawing = false;
if (currentPath.length > 1) {
Expand Down Expand Up @@ -176,7 +180,9 @@ function resetZoom() {
}

function zoomIn(event) {
if (!coordSystem) return;
if (!coordSystem) {
return;
}
const rect = canvas.getBoundingClientRect();
let mouseX, mouseY;

Expand All @@ -196,7 +202,9 @@ function zoomIn(event) {
}

function zoomOut(event) {
if (!coordSystem) return;
if (!coordSystem) {
return;
}
const rect = canvas.getBoundingClientRect();
let mouseX, mouseY;

Expand Down
16 changes: 12 additions & 4 deletions app/static/js/scout.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function resizeModalCanvas() {
}

function redrawPaths() {
if (!modalCoordSystem || !currentPathData) return;
if (!modalCoordSystem || !currentPathData) {
return;
}

modalCoordSystem.clear();

Expand Down Expand Up @@ -68,7 +70,9 @@ function redrawPaths() {
}

function zoomIn(event) {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
const rect = modalCanvas.getBoundingClientRect();
let mouseX = rect.width / 2;
let mouseY = rect.height / 2;
Expand All @@ -78,7 +82,9 @@ function zoomIn(event) {
}

function zoomOut(event) {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
const rect = modalCanvas.getBoundingClientRect();
let mouseX = rect.width / 2;
let mouseY = rect.height / 2;
Expand All @@ -88,7 +94,9 @@ function zoomOut(event) {
}

function resetZoom() {
if (!modalCoordSystem) return;
if (!modalCoordSystem) {
return;
}
modalCoordSystem.resetView();
redrawPaths();
}
Expand Down
4 changes: 3 additions & 1 deletion app/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function resizeModalCanvas() {
}

function redrawPaths() {
if (!modalCoordSystem || !currentPathData) return;
if (!modalCoordSystem || !currentPathData) {
return;
}

modalCoordSystem.clear();

Expand Down

0 comments on commit 4a9995f

Please sign in to comment.