Changed around line 1
- // Smooth scrolling for navigation links
- document.querySelectorAll('nav a').forEach(anchor => {
- anchor.addEventListener('click', function(e) {
- e.preventDefault();
- document.querySelector(this.getAttribute('href')).scrollIntoView({
- behavior: 'smooth'
- });
+ document.addEventListener('DOMContentLoaded', () => {
+ // Mobile menu toggle
+ const menuToggle = document.querySelector('.menu-toggle');
+ const navLinks = document.querySelector('.nav-links');
+
+ menuToggle.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ const spans = menuToggle.querySelectorAll('span');
+ spans[0].classList.toggle('rotate-45');
+ spans[1].classList.toggle('opacity-0');
+ spans[2].classList.toggle('rotate-neg-45');
- });
- // Add hover effect to cards
- const cards = document.querySelectorAll('.card');
- cards.forEach(card => {
- card.addEventListener('mouseenter', () => {
- card.style.boxShadow = '0 4px 8px rgba(0,0,0,0.2)';
- });
- card.addEventListener('mouseleave', () => {
- card.style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)';
- });
- });
+ // Sample data for requirements
+ const requirements = [
+ { id: 'REQ001', name: 'Voltage monitoring', spec: 'SPEC001', testCase: 'TC001', status: 'Completed' },
+ { id: 'REQ002', name: 'Temperature control', spec: 'SPEC002', testCase: 'TC002', status: 'In Progress' },
+ { id: 'REQ003', name: 'Fault detection', spec: 'SPEC003', testCase: 'TC003', status: 'Pending' }
+ ];
+
+ // Populate traceability matrix
+ const matrixBody = document.getElementById('matrixBody');
+ if (matrixBody) {
+ requirements.forEach(req => {
+ const row = document.createElement('tr');
+ row.innerHTML = `
+
${req.id} | +
${req.spec} | +
${req.testCase} | +
${req.status} | + `;
+ matrixBody.appendChild(row);
+ });
+ }
+
+ // Search functionality
+ const searchInput = document.querySelector('input[type="search"]');
+ if (searchInput) {
+ searchInput.addEventListener('input', (e) => {
+ const searchTerm = e.target.value.toLowerCase();
+ const rows = matrixBody.querySelectorAll('tr');
+
+ rows.forEach(row => {
+ const text = row.textContent.toLowerCase();
+ row.style.display = text.includes(searchTerm) ? '' : 'none';
+ });
+ });
+ }
+
+ // Add requirement button
+ const addBtn = document.querySelector('.add-btn');
+ if (addBtn) {
+ addBtn.addEventListener('click', () => {
+ // Implementation for adding new requirement
+ alert('Add requirement functionality to be implemented');
+ });
+ }
+ });