document.addEventListener('DOMContentLoaded', function() { // Initialize mock data let mockNumbers = [ { platform: 'Twilio', number: '+1 555-123-4567', country: 'USA', status: 'Available' }, { platform: 'Virtusim', number: '+44 7911 123456', country: 'UK', status: 'Available' }, { platform: 'IVASMS', number: '+62 812-3456-7890', country: 'Indonesia', status: 'Busy' } ]; // Load saved configuration loadConfiguration(); // Populate numbers table populateNumbersTable(); // Setup form submission document.getElementById('botConfigForm').addEventListener('submit', function(e) { e.preventDefault(); saveConfiguration(); showNotification('Configuration saved successfully!'); }); // Setup refresh button document.getElementById('refreshNumbers').addEventListener('click', function() { populateNumbersTable(); showNotification('Numbers refreshed!'); }); // Simulate incoming OTP messages setInterval(simulateIncomingOTP, 10000); function loadConfiguration() { const botToken = localStorage.getItem('botToken') || ''; const ownerId = localStorage.getItem('ownerId') || ''; const groupId = localStorage.getItem('groupId') || ''; document.getElementById('botToken').value = botToken; document.getElementById('ownerId').value = ownerId; document.getElementById('groupId').value = groupId; } function saveConfiguration() { const botToken = document.getElementById('botToken').value; const ownerId = document.getElementById('ownerId').value; const groupId = document.getElementById('groupId').value; localStorage.setItem('botToken', botToken); localStorage.setItem('ownerId', ownerId); localStorage.setItem('groupId', groupId); } function populateNumbersTable() { const tableBody = document.getElementById('numbersTableBody'); tableBody.innerHTML = ''; mockNumbers.forEach(number => { const row = document.createElement('tr'); row.className = 'border-t border-gray-600 hover:bg-gray-600 transition duration-150 fade-in'; row.innerHTML = ` ${number.platform} ${number.number} ${number.country} ${number.status} `; tableBody.appendChild(row); }); } function simulateIncomingOTP() { const platforms = ['Twilio', 'Virtusim', 'IVASMS']; const services = ['Google', 'Facebook', 'WhatsApp', 'Telegram', 'Twitter']; const platform = platforms[Math.floor(Math.random() * platforms.length)]; const service = services[Math.floor(Math.random() * services.length)]; const code = Math.floor(1000 + Math.random() * 9000); const otpMessages = document.getElementById('otpMessages'); if (otpMessages.firstChild?.className === 'text-center text-gray-500') { otpMessages.innerHTML = ''; } const messageDiv = document.createElement('div'); messageDiv.className = 'mb-3 fade-in'; messageDiv.innerHTML = `
${platform} ${new Date().toLocaleTimeString()}
Service: ${service}
OTP Code: ${code}
`; otpMessages.insertBefore(messageDiv, otpMessages.firstChild); } function showNotification(message) { const notification = document.createElement('div'); notification.className = 'notification'; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => { notification.classList.add('show'); }, 100); setTimeout(() => { notification.classList.remove('show'); setTimeout(() => { document.body.removeChild(notification); }, 300); }, 3000); } });