()
| 11111 | const event = data.event; |
| 11112 | if (event === 'scanning') { |
| 11113 | button.textContent = 'Scanning...'; |
| 11114 | } else if (event === 'hostname') { |
| 11115 | // Extract short hostname (max 20 chars already in message) |
| 11116 | button.textContent = message; |
| 11117 | } else if (event === 'port_found') { |
| 11118 | const port = data.port; |
| 11119 | const service = data.service; |
| 11120 | button.textContent = `Port ${port} found`; |
| 11121 | } |
| 11122 | button.dataset.scanStatus = 'scanning'; |
| 11123 | // Save the updated state |
| 11124 | saveDeepScanButtonState(ip); |
| 11125 | } |
| 11126 | if (updateCustomStatus && message) { |
| 11127 | customStatusEl.textContent = message; |
| 11128 | } |
| 11129 | break; |
| 11130 | |
| 11131 | case 'deep_scan_completed': |
| 11132 | const portCount = data.open_ports ? data.open_ports.length : 0; |
| 11133 | const duration = data.scan_duration ? data.scan_duration.toFixed(2) : 'unknown'; |
| 11134 | addConsoleMessage(`✅ Deep scan of ${ip} complete: ${portCount} ports found in ${duration}s`, 'success'); |
| 11135 | |
| 11136 | // Show detailed port information |
| 11137 | if (data.open_ports && data.open_ports.length > 0) { |
| 11138 | const portList = data.open_ports.slice(0, 10).join(', '); |
| 11139 | const moreText = data.open_ports.length > 10 ? ` (+${data.open_ports.length - 10} more)` : ''; |
| 11140 | addConsoleMessage(` Open ports: ${portList}${moreText}`, 'info'); |
| 11141 | } |
| 11142 | |
| 11143 | // Update button to show completion |
| 11144 | if (button) { |
| 11145 | button.classList.remove('bg-blue-600', 'cursor-wait'); |
| 11146 | button.classList.add('bg-green-600'); |
| 11147 | button.textContent = `✅ ${portCount} ports`; |
| 11148 | button.disabled = true; |
| 11149 | button.dataset.scanStatus = 'completed'; |
| 11150 | // Save the updated state |
| 11151 | saveDeepScanButtonState(ip); |
| 11152 | |
| 11153 | // Reset button after 3 seconds |
| 11154 | setTimeout(() => { |
| 11155 | if (document.getElementById(buttonId)) { |
| 11156 | button.classList.remove('bg-green-600'); |
| 11157 | button.classList.add('bg-purple-600', 'hover:bg-purple-700'); |
| 11158 | button.textContent = 'Deep Scan'; |
| 11159 | button.disabled = false; |
| 11160 | button.dataset.scanStatus = 'idle'; |
| 11161 | // Clear the saved state since it's back to default |
| 11162 | clearDeepScanButtonState(ip); |
| 11163 | } |
| 11164 | }, 3000); |
| 11165 | } |
no test coverage detected