Changed around line 1
+ // Sample data
+ let sensorData = [
+ { mode: "4K60", resolution: "3840x2160", fps: 60, bitDepth: 12, adc: "Column", snr: 42.3, power: 350.5 },
+ { mode: "1080p120", resolution: "1920x1080", fps: 120, bitDepth: 10, adc: "Column", snr: 40.1, power: 280.0 },
+ { mode: "720p240", resolution: "1280x720", fps: 240, bitDepth: 10, adc: "Pixel", snr: 38.5, power: 420.2 }
+ ];
+
+ const tableBody = document.getElementById('tableBody');
+ const modal = document.getElementById('editModal');
+ const closeBtn = document.querySelector('.close');
+ const editForm = document.getElementById('editForm');
+ const searchInput = document.getElementById('searchInput');
+
+ let currentEditIndex = -1;
+
+ // Render table
+ function renderTable(data) {
+ tableBody.innerHTML = '';
+ data.forEach((row, index) => {
+ const tr = document.createElement('tr');
+ tr.innerHTML = `
+
${row.mode} | +
${row.resolution} | +
${row.fps} | +
${row.bitDepth} | +
${row.adc} | +
${row.snr} | +
${row.power} | + `;
+ tr.addEventListener('click', () => openEditModal(index));
+ tableBody.appendChild(tr);
+ });
+ }
+
+ // Open edit modal
+ function openEditModal(index) {
+ currentEditIndex = index;
+ const row = sensorData[index];
+
+ document.getElementById('editMode').value = row.mode;
+ document.getElementById('editResolution').value = row.resolution;
+ document.getElementById('editFps').value = row.fps;
+ document.getElementById('editBitDepth').value = row.bitDepth;
+ document.getElementById('editAdc').value = row.adc;
+ document.getElementById('editSnr').value = row.snr;
+ document.getElementById('editPower').value = row.power;
+
+ modal.style.display = 'block';
+ }
+
+ // Close modal
+ closeBtn.onclick = () => {
+ modal.style.display = 'none';
+ };
+
+ window.onclick = (event) => {
+ if (event.target === modal) {
+ modal.style.display = 'none';
+ }
+ };
+
+ // Handle form submission
+ editForm.onsubmit = (e) => {
+ e.preventDefault();
+
+ sensorData[currentEditIndex] = {
+ mode: document.getElementById('editMode').value,
+ resolution: document.getElementById('editResolution').value,
+ fps: parseInt(document.getElementById('editFps').value),
+ bitDepth: parseInt(document.getElementById('editBitDepth').value),
+ adc: document.getElementById('editAdc').value,
+ snr: parseFloat(document.getElementById('editSnr').value),
+ power: parseFloat(document.getElementById('editPower').value)
+ };
+
+ renderTable(sensorData);
+ modal.style.display = 'none';
+ };
+
+ // Search functionality
+ searchInput.addEventListener('input', (e) => {
+ const searchTerm = e.target.value.toLowerCase();
+ const filteredData = sensorData.filter(row =>
+ Object.values(row).some(value =>
+ value.toString().toLowerCase().includes(searchTerm)
+ )
+ );
+ renderTable(filteredData);
+ });
+
+ // Initial render
+ renderTable(sensorData);