document.addEventListener('DOMContentLoaded', function() { // Simulate login (in a real app, this would be handled by a backend) const loginForm = document.querySelector('#login-form'); const dashboard = document.querySelector('#dashboard'); if (loginForm) { loginForm.addEventListener('submit', function(e) { e.preventDefault(); dashboard.classList.remove('hidden'); document.querySelector('#login-modal').classList.add('hidden'); window.location.hash = '#dashboard'; }); } // Check for hash on load if (window.location.hash === '#dashboard') { dashboard.classList.remove('hidden'); document.querySelector('#login-modal').classList.add('hidden'); } // Testing type selection const testingTypeCards = document.querySelectorAll('.testing-type-card'); const testingDashboard = document.querySelector('#testing-dashboard'); const testingTypeTitle = document.querySelector('#testing-type-title'); testingTypeCards.forEach(card => { card.addEventListener('click', function() { const type = this.getAttribute('data-type'); testingDashboard.classList.remove('hidden'); testingTypeTitle.textContent = type.charAt(0).toUpperCase() + type.slice(1) + ' Testing'; // Scroll to dashboard testingDashboard.scrollIntoView({ behavior: 'smooth' }); }); }); // Trigger modal const triggerModalBtn = document.querySelector('#trigger-modal-btn'); const triggerModal = document.querySelector('#trigger-modal'); const closeModalBtn = document.querySelector('#close-modal'); if (triggerModalBtn) { triggerModalBtn.addEventListener('click', function() { triggerModal.classList.remove('hidden'); }); } if (closeModalBtn) { closeModalBtn.addEventListener('click', function() { triggerModal.classList.add('hidden'); }); } // Close modal when clicking outside triggerModal.addEventListener('click', function(e) { if (e.target === triggerModal) { triggerModal.classList.add('hidden'); } }); // Show/hide specific fields based on testing type const testForm = document.querySelector('#test-form'); const functionalFields = document.querySelector('#functional-fields'); const performanceFields = document.querySelector('#performance-fields'); if (testForm) { testForm.addEventListener('submit', function(e) { e.preventDefault(); alert('Test execution started!'); triggerModal.classList.add('hidden'); }); } // Dynamic fields based on testing type testingTypeCards.forEach(card => { card.addEventListener('click', function() { const type = this.getAttribute('data-type'); // Hide all specific fields first functionalFields.classList.add('hidden'); performanceFields.classList.add('hidden'); // Show relevant fields if (type === 'functional') { functionalFields.classList.remove('hidden'); } else if (type === 'performance') { performanceFields.classList.remove('hidden'); } }); }); // Sample data updates setInterval(() => { const executingTests = document.querySelector('#executing-tests'); if (executingTests) { const current = parseInt(executingTests.textContent); executingTests.textContent = Math.max(0, current + (Math.random() > 0.5 ? -1 : 1)); } }, 5000); });