diff --git a/app/static/js/scout.add.js b/app/static/js/scout.add.js index 8df40d3..a8f4597 100644 --- a/app/static/js/scout.add.js +++ b/app/static/js/scout.add.js @@ -1,42 +1,3 @@ -const updateTotal = () => { - // Auto Coral Points - const autoCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="auto_coral_level${level}"]`).value) || 0) * level; - }, 0); - - // Teleop Coral Points - const teleopCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="teleop_coral_level${level}"]`).value) || 0) * level; - }, 0); - - // Auto Algae Points - const autoAlgaeNet = (parseInt(document.querySelector('input[name="auto_algae_net"]').value) || 0) * 2; - const autoAlgaeProcessor = (parseInt(document.querySelector('input[name="auto_algae_processor"]').value) || 0) * 3; - - // Teleop Algae Points - const teleopAlgaeNet = (parseInt(document.querySelector('input[name="teleop_algae_net"]').value) || 0) * 2; - const teleopAlgaeProcessor = (parseInt(document.querySelector('input[name="teleop_algae_processor"]').value) || 0) * 3; - - const humanPlayerPoints = (parseInt(document.querySelector('input[name="human_player"]').value) || 0) * 2; - - const climbType = document.querySelector('select[name="climb_type"]').value; - const climbSuccess = document.querySelector('input[name="climb_success"]').checked; - let climbPoints = 0; - if (climbSuccess) { - switch(climbType) { - case 'shallow': climbPoints = 6; break; - case 'deep': climbPoints = 12; break; - case 'park': climbPoints = 2; break; - } - } - - const total = autoCoralPoints + teleopCoralPoints + - autoAlgaeNet + autoAlgaeProcessor + - teleopAlgaeNet + teleopAlgaeProcessor + - humanPlayerPoints + climbPoints; - document.getElementById('totalPoints').textContent = total; -}; - const updateMatchResult = () => { const allianceScore = parseInt(allianceScoreInput.value) || 0; const opponentScore = parseInt(opponentScoreInput.value) || 0; @@ -117,7 +78,7 @@ function stopDrawing(e) { } function handleTouchStart(e) { - if (e.touches.length === 1) { // Only draw with one finger + if (e.touches.length === 1) { e.preventDefault(); const touch = e.touches[0]; startDrawing({ @@ -129,7 +90,7 @@ function handleTouchStart(e) { } function handleTouchMove(e) { - if (e.touches.length === 1) { // Only draw with one finger + if (e.touches.length === 1) { e.preventDefault(); const touch = e.touches[0]; draw({ @@ -162,7 +123,6 @@ function redrawPaths() { function updateHiddenInput() { const input = document.getElementById('auto_path'); - // Store the paths array as a JSON string input.value = JSON.stringify(paths); } @@ -195,12 +155,12 @@ function zoomIn(event) { } else if (event.clientX !== undefined) { // Mouse event mouseX = event.clientX - rect.left; mouseY = event.clientY - rect.top; - } else { // Button click without position + } else { mouseX = rect.width / 2; mouseY = rect.height / 2; } - coordSystem.zoom(mouseX, mouseY, 1.1); // Reduced from 1.2 + coordSystem.zoom(mouseX, mouseY, 1.1); redrawPaths(); } @@ -209,27 +169,24 @@ function zoomOut(event) { const rect = canvas.getBoundingClientRect(); let mouseX, mouseY; - if (event.touches) { // Touch event + if (event.touches) { mouseX = event.touches[0].clientX - rect.left; mouseY = event.touches[0].clientY - rect.top; - } else if (event.clientX !== undefined) { // Mouse event + } else if (event.clientX !== undefined) { mouseX = event.clientX - rect.left; mouseY = event.clientY - rect.top; - } else { // Button click without position + } else { mouseX = rect.width / 2; mouseY = rect.height / 2; } - coordSystem.zoom(mouseX, mouseY, 0.9); // Increased from 0.8 + coordSystem.zoom(mouseX, mouseY, 0.9); redrawPaths(); } -// Form-related functionality document.addEventListener('DOMContentLoaded', function() { - // Initialize canvas initCanvas(); - // Auto-capitalize event code const eventCodeInput = document.querySelector('input[name="event_code"]'); if (eventCodeInput) { eventCodeInput.addEventListener('input', function(e) { @@ -237,31 +194,13 @@ document.addEventListener('DOMContentLoaded', function() { }); } - // Calculate total points in real-time - const pointInputs = ['auto_points', 'teleop_points', 'endgame_points']; - const totalPointsDisplay = document.getElementById('totalPoints'); - - pointInputs.forEach(inputName => { - document.querySelector(`input[name="${inputName}"]`).addEventListener('input', updateTotal); - }); - - // Add event listeners for all scoring inputs - document.querySelectorAll('input[type="number"], input[type="checkbox"], select[name="climb_type"]') - .forEach(input => input.addEventListener('input', updateTotal)); - - // Initialize total - updateTotal(); - - // Auto-calculate match result const allianceScoreInput = document.querySelector('input[name="alliance_score"]'); const opponentScoreInput = document.querySelector('input[name="opponent_score"]'); - const matchResultInput = document.getElementById('match_result'); allianceScoreInput.addEventListener('input', updateMatchResult); opponentScoreInput.addEventListener('input', updateMatchResult); - updateMatchResult(); // Initial calculation + updateMatchResult(); - // Form submission handler const form = document.getElementById('scoutingForm'); if (form) { form.addEventListener('submit', async function(e) { diff --git a/app/static/js/scout.edit.js b/app/static/js/scout.edit.js index dd5575e..ace3cb2 100644 --- a/app/static/js/scout.edit.js +++ b/app/static/js/scout.edit.js @@ -1,42 +1,3 @@ -const updateTotal = () => { - // Auto Coral Points - const autoCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="auto_coral_level${level}"]`).value) || 0) * level; - }, 0); - - // Teleop Coral Points - const teleopCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="teleop_coral_level${level}"]`).value) || 0) * level; - }, 0); - - // Auto Algae Points - const autoAlgaeNet = (parseInt(document.querySelector('input[name="auto_algae_net"]').value) || 0) * 2; - const autoAlgaeProcessor = (parseInt(document.querySelector('input[name="auto_algae_processor"]').value) || 0) * 3; - - // Teleop Algae Points - const teleopAlgaeNet = (parseInt(document.querySelector('input[name="teleop_algae_net"]').value) || 0) * 2; - const teleopAlgaeProcessor = (parseInt(document.querySelector('input[name="teleop_algae_processor"]').value) || 0) * 3; - - const humanPlayerPoints = (parseInt(document.querySelector('input[name="human_player"]').value) || 0) * 2; - - const climbType = document.querySelector('select[name="climb_type"]').value; - const climbSuccess = document.querySelector('input[name="climb_success"]').checked; - let climbPoints = 0; - if (climbSuccess) { - switch(climbType) { - case 'shallow': climbPoints = 6; break; - case 'deep': climbPoints = 12; break; - case 'park': climbPoints = 2; break; - } - } - - const total = autoCoralPoints + teleopCoralPoints + - autoAlgaeNet + autoAlgaeProcessor + - teleopAlgaeNet + teleopAlgaeProcessor + - humanPlayerPoints + climbPoints; - document.getElementById('totalPoints').textContent = total; -}; - let canvas, coordSystem; let isDrawing = false; let currentPath = []; @@ -195,13 +156,13 @@ function zoomIn(event) { const rect = canvas.getBoundingClientRect(); let mouseX, mouseY; - if (event.touches) { // Touch event + if (event.touches) { mouseX = event.touches[0].clientX - rect.left; mouseY = event.touches[0].clientY - rect.top; - } else if (event.clientX !== undefined) { // Mouse event + } else if (event.clientX !== undefined) { mouseX = event.clientX - rect.left; mouseY = event.clientY - rect.top; - } else { // Button click without position + } else { mouseX = rect.width / 2; mouseY = rect.height / 2; } @@ -215,13 +176,13 @@ function zoomOut(event) { const rect = canvas.getBoundingClientRect(); let mouseX, mouseY; - if (event.touches) { // Touch event + if (event.touches) { mouseX = event.touches[0].clientX - rect.left; mouseY = event.touches[0].clientY - rect.top; - } else if (event.clientX !== undefined) { // Mouse event + } else if (event.clientX !== undefined) { mouseX = event.clientX - rect.left; mouseY = event.clientY - rect.top; - } else { // Button click without position + } else { mouseX = rect.width / 2; mouseY = rect.height / 2; } @@ -243,13 +204,6 @@ document.addEventListener('DOMContentLoaded', function() { }); } - // Add event listeners for all scoring inputs - document.querySelectorAll('input[type="number"], input[type="checkbox"], select[name="climb_type"]') - .forEach(input => input.addEventListener('input', updateTotal)); - - // Initialize total - updateTotal(); - // Form submission handler const form = document.getElementById('scoutingForm'); if (form) { diff --git a/app/static/js/scout.list.js b/app/static/js/scout.list.js index bbb9b17..b7ce91a 100644 --- a/app/static/js/scout.list.js +++ b/app/static/js/scout.list.js @@ -4,23 +4,19 @@ let currentPathData = null; function showAutoPath(pathData, autoNotes, deviceType) { currentPathData = pathData; - // Show the modal const modal = document.getElementById('autoPathModal'); modal.classList.remove('hidden'); - // Initialize canvas and coordinate system if not already done if (!modalCanvas) { modalCanvas = document.getElementById('modalAutoPath'); modalCoordSystem = new CanvasCoordinateSystem(modalCanvas); - // Set canvas size to match container resizeModalCanvas(); window.addEventListener('resize', resizeModalCanvas); } redrawPaths(); - // Set auto notes const notesElement = document.getElementById('modalAutoNotes'); if (notesElement) { notesElement.textContent = autoNotes || 'No notes available'; @@ -129,19 +125,16 @@ const filterRows = () => { row.style.display = searchValue.includes(searchTerm) ? '' : 'none'; }); - // Hide section if all rows are hidden const visibleRows = Array.from(section.querySelectorAll('.team-row')).filter(row => row.style.display !== 'none'); section.style.display = visibleRows.length > 0 ? '' : 'none'; }); }; document.addEventListener('DOMContentLoaded', function() { - // Initialize DOM elements filterType = document.getElementById('filterType'); searchInput = document.getElementById('searchInput'); eventSections = document.querySelectorAll('.event-section'); - // Add event listeners after elements are found if (searchInput && filterType) { searchInput.addEventListener('input', filterRows); filterType.addEventListener('change', filterRows); @@ -155,39 +148,4 @@ document.addEventListener('DOMContentLoaded', function() { } }); } -}); - -function updateTotal() { - // Auto scoring - const autoCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="auto_coral_level${level}"]`).value) || 0) * level; - }, 0); - - const autoAlgaeNet = (parseInt(document.querySelector('input[name="auto_algae_net"]').value) || 0) * 2; - const autoAlgaeProcessor = (parseInt(document.querySelector('input[name="auto_algae_processor"]').value) || 0) * 3; - - // Teleop scoring - const teleopCoralPoints = [1, 2, 3, 4].reduce((sum, level) => { - return sum + (parseInt(document.querySelector(`input[name="teleop_coral_level${level}"]`).value) || 0) * level; - }, 0); - - const teleopAlgaeNet = (parseInt(document.querySelector('input[name="teleop_algae_net"]').value) || 0) * 2; - const teleopAlgaeProcessor = (parseInt(document.querySelector('input[name="teleop_algae_processor"]').value) || 0) * 3; - const humanPlayerPoints = (parseInt(document.querySelector('input[name="human_player"]').value) || 0) * 2; - const climbType = document.querySelector('select[name="climb_type"]').value; - const climbSuccess = document.querySelector('input[name="climb_success"]').checked; - let climbPoints = 0; - if (climbSuccess) { - switch(climbType) { - case 'shallow': climbPoints = 6; break; - case 'deep': climbPoints = 12; break; - case 'park': climbPoints = 2; break; - } - } - - - const total = autoCoralPoints + autoAlgaeNet + autoAlgaeProcessor + - teleopCoralPoints + teleopAlgaeNet + teleopAlgaeProcessor + - humanPlayerPoints + climbPoints; - document.getElementById('totalPoints').textContent = total; -} \ No newline at end of file +}); \ No newline at end of file