Spaces:
Running
Running
Download script.js from eriksaether/chatterbox-haven: direct link, hf CLI and curl.
- Browser
- Download file 3.62 kB
-
https://huggingface.co/spaces/eriksaether/chatterbox-haven/resolve/main/script.js
- Command line
-
hf download hf://spaces/eriksaether/chatterbox-haven/script.js
-
curl -L -o script.js https://huggingface.co/spaces/eriksaether/chatterbox-haven/resolve/main/script.js
3.62 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mock data for demonstration | |
| const discussions = [ | |
| { | |
| id: 1, | |
| title: "What's your favorite programming language?", | |
| author: "CodeMaster", | |
| replies: 24, | |
| views: 156, | |
| lastActivity: "2 hours ago", | |
| category: "Technology" | |
| }, | |
| { | |
| id: 2, | |
| title: "Best practices for remote work", | |
| author: "RemoteWorker", | |
| replies: 18, | |
| views: 98, | |
| lastActivity: "5 hours ago", | |
| category: "Work" | |
| }, | |
| { | |
| id: 3, | |
| title: "Show off your latest projects!", | |
| author: "CreativeMind", | |
| replies: 32, | |
| views: 210, | |
| lastActivity: "1 day ago", | |
| category: "Showcase" | |
| }, | |
| { | |
| id: 4, | |
| title: "How do you stay productive?", | |
| author: "ProductivityGuru", | |
| replies: 15, | |
| views: 87, | |
| lastActivity: "3 days ago", | |
| category: "Lifestyle" | |
| } | |
| ]; | |
| // Render discussions | |
| const discussionsList = document.getElementById('discussions-list'); | |
| discussions.forEach(discussion => { | |
| const discussionElement = document.createElement('div'); | |
| discussionElement.className = 'bg-gray-50 hover:bg-gray-100 rounded-lg p-4 transition duration-200 new-message'; | |
| discussionElement.innerHTML = ` | |
| <div class="flex items-start gap-4"> | |
| <div class="bg-blue-100 text-blue-600 rounded-full p-3"> | |
| <i data-feather="message-square" class="w-5 h-5"></i> | |
| </div> | |
| <div class="flex-1"> | |
| <h3 class="font-semibold text-gray-800 mb-1">${discussion.title}</h3> | |
| <div class="flex flex-wrap items-center gap-3 text-sm text-gray-500"> | |
| <span>by ${discussion.author}</span> | |
| <span>•</span> | |
| <span>${discussion.replies} replies</span> | |
| <span>•</span> | |
| <span>${discussion.views} views</span> | |
| <span>•</span> | |
| <span class="bg-${getCategoryColor(discussion.category)}-100 text-${getCategoryColor(discussion.category)}-600 px-2 py-1 rounded-full text-xs"> | |
| ${discussion.category} | |
| </span> | |
| </div> | |
| </div> | |
| <div class="text-sm text-gray-500"> | |
| ${discussion.lastActivity} | |
| </div> | |
| </div> | |
| `; | |
| discussionsList.appendChild(discussionElement); | |
| }); | |
| // Update stats | |
| document.getElementById('active-users').textContent = Math.floor(Math.random() * 2000) + 500; | |
| document.getElementById('total-posts').textContent = Math.floor(Math.random() * 8000) + 2000; | |
| document.getElementById('total-topics').textContent = Math.floor(Math.random() * 100) + 20; | |
| // Form submission | |
| document.getElementById('new-post-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| alert('Your post has been submitted!'); | |
| this.reset(); | |
| }); | |
| // Initialize feather icons | |
| feather.replace(); | |
| }); | |
| function getCategoryColor(category) { | |
| const colors = { | |
| 'Technology': 'blue', | |
| 'Work': 'green', | |
| 'Showcase': 'purple', | |
| 'Lifestyle': 'orange', | |
| 'General': 'gray' | |
| }; | |
| return colors[category] || 'gray'; | |
| } |