Download script.js from 03dutoit/documind-ai-study-assistant: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/spaces/03dutoit/documind-ai-study-assistant/resolve/main/script.js
- Command line
-
hf download hf://spaces/03dutoit/documind-ai-study-assistant/script.js
-
curl -L -o script.js https://huggingface.co/spaces/03dutoit/documind-ai-study-assistant/resolve/main/script.js
2.3 kB
| // Dark mode toggle functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Check for saved theme preference | |
| if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| document.documentElement.classList.add('dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| // Upload area interaction | |
| const uploadArea = document.querySelector('.border-dashed'); | |
| if (uploadArea) { | |
| uploadArea.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| uploadArea.classList.add('border-primary-500', 'bg-primary-50', 'dark:bg-gray-700'); | |
| uploadArea.classList.remove('border-gray-300', 'dark:border-gray-600'); | |
| }); | |
| uploadArea.addEventListener('dragleave', () => { | |
| uploadArea.classList.remove('border-primary-500', 'bg-primary-50', 'dark:bg-gray-700'); | |
| uploadArea.classList.add('border-gray-300', 'dark:border-gray-600'); | |
| }); | |
| uploadArea.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| uploadArea.classList.remove('border-primary-500', 'bg-primary-50', 'dark:bg-gray-700'); | |
| uploadArea.classList.add('border-gray-300', 'dark:border-gray-600'); | |
| // Handle file upload here | |
| if (e.dataTransfer.files.length) { | |
| handleFileUpload(e.dataTransfer.files[0]); | |
| } | |
| }); | |
| } | |
| // File upload handler (mock for now) | |
| function handleFileUpload(file) { | |
| console.log('File to upload:', file); | |
| // Here you would typically send the file to your backend for processing | |
| // For now, we'll just show a success message | |
| alert(`File "${file.name}" received! This would be processed to extract text and generate a summary in a real implementation.`); | |
| } | |
| // Listen for upload events from the custom element | |
| document.addEventListener('file-uploaded', (e) => { | |
| handleFileUpload(e.detail.file); | |
| }); | |
| }); | |
| // Shared function to toggle dark mode | |
| function toggleDarkMode() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| localStorage.setItem('color-theme', html.classList.contains('dark') ? 'dark' : 'light'); | |
| } |