File size: 3,615 Bytes
e11ebc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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';
}