Download script.js from iprofitx/helphub-knowledge-base-explorer: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/iprofitx/helphub-knowledge-base-explorer/resolve/main/script.js
- Command line
-
hf download hf://spaces/iprofitx/helphub-knowledge-base-explorer/script.js
-
curl -L -o script.js https://huggingface.co/spaces/iprofitx/helphub-knowledge-base-explorer/resolve/main/script.js
2.53 kB
| // Initialize tooltips | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize any tooltips or popovers | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| }); | |
| // Search functionality | |
| function performSearch(query) { | |
| console.log('Searching for:', query); | |
| // In a real implementation, this would fetch search results from an API | |
| // and update the DOM with the results | |
| } | |
| // Load articles from API | |
| async function loadArticles() { | |
| try { | |
| // In a real implementation, this would fetch from your API | |
| const response = await fetch('https://jsonplaceholder.typicode.com/posts?_limit=6'); | |
| if (!response.ok) throw new Error('Failed to fetch articles'); | |
| return await response.json(); | |
| } catch (error) { | |
| console.error('Error loading articles:', error); | |
| return []; | |
| } | |
| } | |
| // Article view tracking | |
| function trackArticleView(articleId) { | |
| console.log('Tracking view for article:', articleId); | |
| // In a real implementation, this would send analytics data | |
| } | |
| // Filter articles by category | |
| function filterArticles(category) { | |
| const articles = document.querySelectorAll('custom-article-card'); | |
| articles.forEach(article => { | |
| if (category === 'all' || article.getAttribute('category') === category) { | |
| article.style.display = 'block'; | |
| } else { | |
| article.style.display = 'none'; | |
| } | |
| }); | |
| } | |
| // Initialize category filtering | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const categoryLinks = document.querySelectorAll('[data-filter-category]'); | |
| categoryLinks.forEach(link => { | |
| link.addEventListener('click', (e) => { | |
| e.preventDefault(); | |
| const category = link.getAttribute('data-filter-category'); | |
| filterArticles(category); | |
| // Update active state | |
| categoryLinks.forEach(l => l.classList.remove('text-blue-600')); | |
| link.classList.add('text-blue-600'); | |
| }); | |
| }); | |
| }); | |