Spaces:
Running
Running
Download script.js from lhrql/voyagesphere: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/spaces/lhrql/voyagesphere/resolve/main/script.js
- Command line
-
hf download hf://spaces/lhrql/voyagesphere/script.js
-
curl -L -o script.js https://huggingface.co/spaces/lhrql/voyagesphere/resolve/main/script.js
1.77 kB
| // Language detection and RTL handling | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Detect Arabic language | |
| const userLang = navigator.language || navigator.userLanguage; | |
| const isArabic = userLang.startsWith('ar'); | |
| if (isArabic) { | |
| document.documentElement.dir = 'rtl'; | |
| document.documentElement.lang = 'ar'; | |
| } | |
| // Initialize all tooltips | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| // AI Search functionality | |
| const searchForm = document.querySelector('.search-form'); | |
| if (searchForm) { | |
| searchForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const query = this.querySelector('input').value; | |
| processAISearch(query); | |
| }); | |
| } | |
| // Voice search initialization | |
| if ('webkitSpeechRecognition' in window) { | |
| const voiceSearchBtn = document.querySelector('.voice-search'); | |
| if (voiceSearchBtn) { | |
| voiceSearchBtn.addEventListener('click', startVoiceRecognition); | |
| } | |
| } | |
| }); | |
| function processAISearch(query) { | |
| console.log('Processing AI search for:', query); | |
| // TODO: Implement AI search API integration | |
| } | |
| function startVoiceRecognition() { | |
| const recognition = new webkitSpeechRecognition(); | |
| recognition.lang = document.documentElement.lang || 'en-US'; | |
| recognition.onresult = function(event) { | |
| const transcript = event.results[0][0].transcript; | |
| document.querySelector('.search-form input').value = transcript; | |
| processAISearch(transcript); | |
| }; | |
| recognition.start(); | |
| } |