File size: 1,005 Bytes
801b8b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | // Main application logic
document.addEventListener('DOMContentLoaded', () => {
// Initialize browser functionality
const urlBar = document.getElementById('url-bar');
if (urlBar) {
urlBar.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
navigateTo(urlBar.value);
}
});
}
});
function navigateTo(url) {
if (!url) return;
// Basic URL validation
let finalUrl = url;
if (!url.startsWith('http://') && !url.startsWith('https://')) {
if (url.includes(' ') || url.includes('.') === false) {
// Treat as search query
finalUrl = `https://www.google.com/search?q=${encodeURIComponent(url)}`;
} else {
finalUrl = `https://${url}`;
}
}
// In a real implementation, this would load the URL in the browser view
console.log(`Navigating to: ${finalUrl}`);
// window.location.href = `/browser?url=${encodeURIComponent(finalUrl)}`;
} |