Ahmedzaki6987/telecom-data-dynamo
0
1document.addEventListener('DOMContentLoaded', function() {2 const analyzeBtn = document.getElementById('analyze-btn');3 const rruInput = document.getElementById('rru-input');4 const resultsContainer = document.getElementById('results-container');5 const resultsBody = document.getElementById('results-body');6 const copyBtn = document.getElementById('copy-btn');7 8 analyzeBtn.addEventListener('click', analyzeRRUData);9 copyBtn.addEventListener('click', copyResultsToClipboard);10 11 function analyzeRRUData() {12 const inputText = rruInput.value.trim();13 if (!inputText) {14 alert('Please paste RRU data to analyze');15 return;16 }17 18 const lines = inputText.split('\n');19 const rruCounts = {};20 21 lines.forEach(line => {22 const fields = line.split(',');23 if (fields.length < 2) return;24 25 // Extract model number26 const modelMatch = fields[0].match(/RRU(\d+)/i);27 if (!modelMatch) return;28 const model = modelMatch[1];29 30 // Analyze frequencies to determine band31 let band = '';32 const freqString = fields[1];33 34 if (freqString.includes('TX925-960MHz') || freqString.includes('RX880-915MHz')) {35 band = 'B8(900)';36 } else if (freqString.includes('TX1805-1880MHz') || freqString.includes('RX1710-1785MHz')) {37 band = 'B3(1800)';38 } else if (freqString.includes('TX2110-2170MHz') || freqString.includes('RX1920-1980MHz')) {39 band = 'B1(2100)';40 } else if (freqString.includes('TX:2496-2690MHz') || freqString.includes('RX:2496-2690MHz')) {41 band = 'B41(2600)';42 }43 44 if (band) {45 const key = `RRUs ${model} ${band}`;46 rruCounts[key] = (rruCounts[key] || 0) + 1;47 }48 });49 50 // Convert to array and sort by count descending51 const sortedResults = Object.entries(rruCounts)52 .map(([type, count]) => ({ type, count }))53 .sort((a, b) => b.count - a.count || a.type.localeCompare(b.type));54 55 // Display results56 resultsBody.innerHTML = '';57 sortedResults.forEach(item => {58 const row = document.createElement('tr');59 row.innerHTML = `60 <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.type}</td>61 <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.count}</td>62 `;63 resultsBody.appendChild(row);64 });65 66 resultsContainer.classList.remove('hidden');67 }68 69 function copyResultsToClipboard() {70 const rows = Array.from(resultsBody.querySelectorAll('tr'));71 const text = rows.map(row => {72 const cells = row.querySelectorAll('td');73 return `${cells[0].textContent}\t${cells[1].textContent}`;74 }).join('\n');75 76 navigator.clipboard.writeText(text).then(() => {77 const originalText = copyBtn.innerHTML;78 copyBtn.innerHTML = '<i data-feather="check" class="mr-2"></i> Copied!';79 feather.replace();80 81 setTimeout(() => {82 copyBtn.innerHTML = originalText;83 feather.replace();84 }, 2000);85 });86 }87});