Download script.js from AKt123479/https-github-com-soweto7-open-genspark-c4tx6o73s25: direct link, hf CLI and curl.
- Browser
- Download file 10.8 kB
-
https://huggingface.co/spaces/AKt123479/https-github-com-soweto7-open-genspark-c4tx6o73s25/resolve/main/script.js
- Command line
-
hf download hf://spaces/AKt123479/https-github-com-soweto7-open-genspark-c4tx6o73s25/script.js
-
curl -L -o script.js https://huggingface.co/spaces/AKt123479/https-github-com-soweto7-open-genspark-c4tx6o73s25/resolve/main/script.js
10.8 kB
| // Open Genspark AI Browser - Main JavaScript | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize all components | |
| initializeMobileMenu(); | |
| initializeChatInterface(); | |
| initializeAnimations(); | |
| initializeTooltips(); | |
| initializeStatusIndicators(); | |
| initializeProgressBars(); | |
| initializeBrowserFeatures(); | |
| // Simulate real-time features | |
| startRealtimeUpdates(); | |
| console.log('Open Genspark AI Browser initialized successfully'); | |
| }); | |
| // Mobile menu functionality | |
| function initializeMobileMenu() { | |
| const mobileMenuButton = document.getElementById('mobile-menu-button'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| if (mobileMenuButton && mobileMenu) { | |
| mobileMenuButton.addEventListener('click', function() { | |
| mobileMenu.classList.toggle('hidden'); | |
| // Animate hamburger menu to X | |
| const icon = mobileMenuButton.querySelector('i'); | |
| if (mobileMenu.classList.contains('hidden')) { | |
| icon.setAttribute('data-feather', 'menu'); | |
| } else { | |
| icon.setAttribute('data-feather', 'x'); | |
| } | |
| feather.replace(); | |
| }); | |
| // Close mobile menu when clicking on a link | |
| const mobileLinks = mobileMenu.querySelectorAll('a'); | |
| mobileLinks.forEach(link => { | |
| link.addEventListener('click', function() { | |
| mobileMenu.classList.add('hidden'); | |
| const icon = mobileMenuButton.querySelector('i'); | |
| icon.setAttribute('data-feather', 'menu'); | |
| feather.replace(); | |
| }); | |
| }); | |
| } | |
| } | |
| // Chat interface functionality | |
| function initializeChatInterface() { | |
| const chatInput = document.getElementById('chat-input'); | |
| const sendButton = document.getElementById('send-button'); | |
| const chatMessages = document.getElementById('chat-messages'); | |
| if (chatInput && sendButton && chatMessages) { | |
| // Send message on button click | |
| sendButton.addEventListener('click', sendMessage); | |
| // Send message on Enter key | |
| chatInput.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| sendMessage(); | |
| } | |
| }); | |
| // Auto-resize input | |
| chatInput.addEventListener('input', function() { | |
| this.style.height = 'auto'; | |
| this.style.height = Math.min(this.scrollHeight, 120) + 'px'; | |
| }); | |
| } | |
| function sendMessage() { | |
| const message = chatInput.value.trim(); | |
| if (message) { | |
| addMessage(message, 'user'); | |
| chatInput.value = ''; | |
| chatInput.style.height = 'auto'; | |
| // Simulate AI response | |
| setTimeout(() => { | |
| const aiResponse = generateAIResponse(message); | |
| addMessage(aiResponse, 'ai'); | |
| }, 1000); | |
| } | |
| } | |
| function addMessage(content, sender) { | |
| const messageDiv = document.createElement('div'); | |
| messageDiv.className = 'mb-4 chat-message'; | |
| if (sender === 'user') { | |
| messageDiv.innerHTML = ` | |
| <div class="flex justify-end"> | |
| <div class="bg-undefined-500 text-white rounded-lg p-3 max-w-xs ml-auto"> | |
| <p class="text-sm">${content}</p> | |
| </div> | |
| </div> | |
| `; | |
| } else { | |
| messageDiv.innerHTML = ` | |
| <div class="flex justify-start"> | |
| <div class="bg-undefined-100 rounded-lg p-3 max-w-xs"> | |
| <p class="text-sm text-gray-800">${content}</p> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| chatMessages.appendChild(messageDiv); | |
| chatMessages.scrollTop = chatMessages.scrollHeight; | |
| } | |
| function generateAIResponse(message) { | |
| const responses = [ | |
| "I can help you with web browsing, content analysis, and search optimization. What specific task would you like assistance with?", | |
| "That's an interesting question! I can analyze web content, provide summaries, and help you navigate to relevant information.", | |
| "I'm here to enhance your browsing experience. I can help you find information, analyze content, and optimize your web navigation.", | |
| "I understand you're looking for help. My AI capabilities include smart search, content summarization, and intelligent navigation assistance.", | |
| "Let me assist you with that. I can provide intelligent browsing suggestions and help analyze any web content you're interested in." | |
| ]; | |
| // Simple keyword-based response | |
| const lowerMessage = message.toLowerCase(); | |
| if (lowerMessage.includes('search')) { | |
| return "I can help you with AI-powered search! I use advanced algorithms to understand context and provide relevant results. What would you like to search for?"; | |
| } else if (lowerMessage.includes('privacy')) { | |
| return "Privacy is a top priority in our AI browser. All processing is done locally when possible, and we don't track your browsing habits. How can I help protect your privacy?"; | |
| } else if (lowerMessage.includes('speed') || lowerMessage.includes('fast')) { | |
| return "Our AI browser is optimized for performance! I use intelligent caching, predictive loading, and efficient algorithms to ensure lightning-fast browsing. Is there a specific speed issue you're experiencing?"; | |
| } | |
| return responses[Math.floor(Math.random() * responses.length)]; | |
| } | |
| } | |
| // Initialize scroll animations | |
| function initializeAnimations() { | |
| const observerOptions = { | |
| threshold: 0.1, | |
| rootMargin: '0px 0px -50px 0px' | |
| }; | |
| const observer = new IntersectionObserver(function(entries) { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('fade-in'); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, observerOptions); | |
| // Observe all feature cards and main sections | |
| const elementsToAnimate = document.querySelectorAll('.bg-white.shadow-lg.rounded-lg, .text-center.mb-12'); | |
| elementsToAnimate.forEach(el => { | |
| observer.observe(el); | |
| }); | |
| } | |
| // Initialize tooltips | |
| function initializeTooltips() { | |
| const tooltipElements = document.querySelectorAll('[data-tooltip]'); | |
| tooltipElements.forEach(element => { | |
| element.classList.add('tooltip'); | |
| }); | |
| } | |
| // Initialize status indicators | |
| function initializeStatusIndicators() { | |
| // Simulate connection status | |
| const statusIndicator = document.createElement('div'); | |
| statusIndicator.className = 'status-online w-3 h-3 rounded-full fixed bottom-4 right-4 z-50'; | |
| statusIndicator.title = 'AI Assistant Online'; | |
| document.body.appendChild(statusIndicator); | |
| // Add status text | |
| const statusText = document.createElement('div'); | |
| statusText.className = 'fixed bottom-8 right-4 text-sm text-gray-600 z-50'; | |
| statusText.textContent = 'AI Online'; | |
| document.body.appendChild(statusText); | |
| } | |
| // Initialize progress bars | |
| function initializeProgressBars() { | |
| // Create a demo progress bar for page loading simulation | |
| const progressContainer = document.createElement('div'); | |
| progressContainer.className = 'fixed top-0 left-0 w-full h-1 bg-gray-200 z-50'; | |
| progressContainer.innerHTML = '<div class="progress-bar h-full" style="width: 0%"></div>'; | |
| document.body.appendChild(progressContainer); | |
| // Simulate page loading | |
| let progress = 0; | |
| const progressBar = progressContainer.querySelector('.progress-bar'); | |
| const loadingInterval = setInterval(() => { | |
| progress += Math.random() * 30; | |
| if (progress >= 100) { | |
| progress = 100; | |
| clearInterval(loadingInterval); | |
| setTimeout(() => { | |
| progressContainer.style.display = 'none'; | |
| }, 500); | |
| } | |
| progressBar.style.width = progress + '%'; | |
| }, 200); | |
| } | |
| // Initialize browser features | |
| function initializeBrowserFeatures() { | |
| // Add keyboard shortcuts | |
| document.addEventListener('keydown', function(e) { | |
| // Ctrl/Cmd + K for search focus | |
| if ((e.ctrlKey || e.metaKey) && e.key === 'k') { | |
| e.preventDefault(); | |
| const chatInput = document.getElementById('chat-input'); | |
| if (chatInput) chatInput.focus(); | |
| } | |
| // Escape to close mobile menu | |
| if (e.key === 'Escape') { | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| if (mobileMenu && !mobileMenu.classList.contains('hidden')) { | |
| mobileMenu.classList.add('hidden'); | |
| const icon = document.getElementById('mobile-menu-button').querySelector('i'); | |
| icon.setAttribute('data-feather', 'menu'); | |
| feather.replace(); | |
| } | |
| } | |
| }); | |
| // Add smooth scroll behavior for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| const target = document.querySelector(this.getAttribute('href')); | |
| if (target) { | |
| target.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Add theme toggle functionality | |
| const body = document.body; | |
| const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| // Store theme preference | |
| if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && prefersDark)) { | |
| body.classList.add('dark-mode'); | |
| } | |
| } | |
| // Start real-time updates | |
| function startRealtimeUpdates() { | |
| // Simulate real-time status updates | |
| setInterval(() => { | |
| const statusIndicator = document.querySelector('.status-online, .status-offline'); | |
| if (statusIndicator) { | |
| // Randomly change status for demo purposes | |
| const isOnline = Math.random() > 0.1; // 90% uptime | |
| statusIndicator.className = isOnline ? 'status-online w-3 h-3 rounded-full fixed bottom-4 right-4 z-50' : 'status-offline w-3 h-3 rounded-full fixed bottom-4 right-4 z-50'; | |
| const statusText = document.querySelector('.fixed.bottom-8.right-4.text-sm'); | |
| if (statusText) { | |
| statusText.textContent = isOnline ? 'AI Online' : 'AI Offline'; | |
| } | |
| } | |
| }, 10000); // Check every 10 seconds | |
| } | |