|
|
|
|
|
if ('serviceWorker' in navigator) { |
|
|
window.addEventListener('load', () => { |
|
|
navigator.serviceWorker.register('sw.js').then(registration => { |
|
|
console.log('ServiceWorker registration successful'); |
|
|
}).catch(err => { |
|
|
console.log('ServiceWorker registration failed: ', err); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); |
|
|
tooltipTriggerList.map(function (tooltipTriggerEl) { |
|
|
return new bootstrap.Tooltip(tooltipTriggerEl); |
|
|
}); |
|
|
|
|
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
anchor.addEventListener('click', function (e) { |
|
|
e.preventDefault(); |
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({ |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const darkModeToggle = document.getElementById('darkModeToggle'); |
|
|
if (darkModeToggle) { |
|
|
darkModeToggle.addEventListener('click', function() { |
|
|
document.documentElement.classList.toggle('dark'); |
|
|
localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); |
|
|
}); |
|
|
} |
|
|
|
|
|
if (localStorage.getItem('darkMode') === 'true') { |
|
|
document.documentElement.classList.add('dark'); |
|
|
} |
|
|
|
|
|
|
|
|
let deferredPrompt; |
|
|
const installContainer = document.createElement('div'); |
|
|
installContainer.id = 'installContainer'; |
|
|
installContainer.innerHTML = ` |
|
|
<p>Install PyBotler for offline use?</p> |
|
|
<button id="installButton" class="btn-primary">Install</button> |
|
|
<button id="cancelInstall" class="btn-secondary">Not Now</button> |
|
|
`; |
|
|
document.body.appendChild(installContainer); |
|
|
|
|
|
window.addEventListener('beforeinstallprompt', (e) => { |
|
|
e.preventDefault(); |
|
|
deferredPrompt = e; |
|
|
installContainer.style.display = 'block'; |
|
|
}); |
|
|
|
|
|
document.getElementById('installButton').addEventListener('click', () => { |
|
|
installContainer.style.display = 'none'; |
|
|
deferredPrompt.prompt(); |
|
|
deferredPrompt.userChoice.then((choiceResult) => { |
|
|
if (choiceResult.outcome === 'accepted') { |
|
|
console.log('User accepted the install prompt'); |
|
|
} else { |
|
|
console.log('User dismissed the install prompt'); |
|
|
} |
|
|
deferredPrompt = null; |
|
|
}); |
|
|
}); |
|
|
|
|
|
document.getElementById('cancelInstall').addEventListener('click', () => { |
|
|
installContainer.style.display = 'none'; |
|
|
}); |
|
|
|
|
|
|
|
|
function simulateAIThinking() { |
|
|
const thinkingIndicators = document.querySelectorAll('.ai-thinking'); |
|
|
thinkingIndicators.forEach(indicator => { |
|
|
let dots = 0; |
|
|
setInterval(() => { |
|
|
dots = (dots + 1) % 4; |
|
|
indicator.textContent = 'AI Processing' + '.'.repeat(dots); |
|
|
}, 500); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
function autonomousTaskCompletion() { |
|
|
document.querySelectorAll('[data-automate]').forEach(element => { |
|
|
element.addEventListener('click', () => { |
|
|
const task = element.getAttribute('data-automate'); |
|
|
console.log(`[AUTONOMOUS_SYSTEM] Executing ${task}...`); |
|
|
|
|
|
setTimeout(() => { |
|
|
console.log(`[SYSTEM] ${task} completed with 98.7% accuracy`); |
|
|
}, 2000); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
simulateAIThinking(); |
|
|
autonomousTaskCompletion(); |
|
|
|
|
|
|
|
|
document.addEventListener('adb-connect', () => { |
|
|
console.log('[DEVICE_CONTROL] ADB connection initiated'); |
|
|
}); |
|
|
|
|
|
document.addEventListener('screen-capture', () => { |
|
|
console.log('[DEVICE_CONTROL] Screen capture initiated'); |
|
|
}); |
|
|
|
|
|
document.addEventListener('file-transfer', () => { |
|
|
console.log('[DEVICE_CONTROL] File transfer initiated'); |
|
|
}); |
|
|
|
|
|
document.addEventListener('disconnect', () => { |
|
|
console.log('[DEVICE_CONTROL] Disconnecting device'); |
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('add-task', (e) => { |
|
|
console.log(`[TASK_SCHEDULER] Adding new task: ${e.detail}`); |
|
|
}); |
|
|
}); |