Theres currently no place holder posts under the "search Questions" spot and the Unanswered filter is not selected
Browse files
script.js
CHANGED
|
@@ -70,9 +70,39 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 70 |
document.addEventListener('DOMContentLoaded', function() {
|
| 71 |
setActiveNav(unansweredLink);
|
| 72 |
showUnansweredPanel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
});
|
| 74 |
-
|
| 75 |
-
// Navigation
|
| 76 |
allQuestionsLink.addEventListener('click', function(e) {
|
| 77 |
e.preventDefault();
|
| 78 |
setActiveNav(allQuestionsLink);
|
|
@@ -116,82 +146,39 @@ function setActiveNav(activeElement) {
|
|
| 116 |
feedContainer.className = 'space-y-4';
|
| 117 |
feedContainer.id = 'questions-feed';
|
| 118 |
|
| 119 |
-
// Add
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
<span class="bg-indigo-100 text-indigo-800 text-xs px-2 py-1 rounded-full">Week3</span>
|
| 134 |
-
</div>
|
| 135 |
-
<div class="flex justify-between text-sm text-gray-500">
|
| 136 |
-
<span>0 responses</span>
|
| 137 |
-
<span>Just now</span>
|
| 138 |
-
</div>
|
| 139 |
-
`;
|
| 140 |
-
feedContainer.appendChild(userPostElement);
|
| 141 |
-
|
| 142 |
-
// Add sample unanswered posts
|
| 143 |
-
const unansweredPosts = [
|
| 144 |
-
{
|
| 145 |
-
title: "Confused about recursion in binary trees",
|
| 146 |
-
body: "I'm having trouble understanding how recursion works with binary tree traversal. Can someone explain the base case and recursive case?",
|
| 147 |
-
tags: ["Recursion", "Binary Trees"],
|
| 148 |
-
responses: 0,
|
| 149 |
-
time: "2 hours ago"
|
| 150 |
-
},
|
| 151 |
-
{
|
| 152 |
-
title: "Need help with HW3 problem 2",
|
| 153 |
-
body: "The problem statement says we need to implement a function with O(n) time complexity, but I'm not sure what approach to take.",
|
| 154 |
-
tags: ["Homework", "Algorithms"],
|
| 155 |
-
responses: 0,
|
| 156 |
-
time: "4 hours ago"
|
| 157 |
-
},
|
| 158 |
-
{
|
| 159 |
-
title: "Lecture slides question",
|
| 160 |
-
body: "On slide 45, there's a notation I don't understand. What does Θ(n log n) mean exactly?",
|
| 161 |
-
tags: ["Lecture", "Notation"],
|
| 162 |
-
responses: 0,
|
| 163 |
-
time: "1 day ago"
|
| 164 |
-
}
|
| 165 |
-
];
|
| 166 |
-
|
| 167 |
-
unansweredPosts.forEach(post => {
|
| 168 |
-
const postElement = document.createElement('div');
|
| 169 |
-
postElement.className = 'bg-white rounded-lg shadow-sm p-6 transition-all hover:shadow-md';
|
| 170 |
-
postElement.innerHTML = `
|
| 171 |
-
<div class="flex justify-between items-start mb-2">
|
| 172 |
-
<h3 class="font-bold text-lg">${post.title}</h3>
|
| 173 |
-
<span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded-full flex items-center">
|
| 174 |
-
<i data-feather="help-circle" class="w-3 h-3 mr-1"></i>
|
| 175 |
-
Needs help
|
| 176 |
-
</span>
|
| 177 |
-
</div>
|
| 178 |
-
<p class="text-gray-600 mb-3">${post.body}</p>
|
| 179 |
-
<div class="flex flex-wrap gap-2 mb-3">
|
| 180 |
-
${post.tags.map(tag => `<span class="bg-indigo-100 text-indigo-800 text-xs px-2 py-1 rounded-full">${tag}</span>`).join('')}
|
| 181 |
-
</div>
|
| 182 |
-
<div class="flex justify-between text-sm text-gray-500">
|
| 183 |
-
<span>${post.responses} ${post.responses === 1 ? 'response' : 'responses'}</span>
|
| 184 |
-
<span>${post.time}</span>
|
| 185 |
-
</div>
|
| 186 |
-
`;
|
| 187 |
feedContainer.appendChild(postElement);
|
| 188 |
});
|
| 189 |
-
|
| 190 |
postsList.appendChild(feedContainer);
|
| 191 |
feather.replace();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
}
|
| 193 |
-
|
| 194 |
-
function showPanel2(newPost) {
|
| 195 |
// Add fade out animation to form
|
| 196 |
postForm.classList.add('fade-out');
|
| 197 |
|
|
|
|
| 70 |
document.addEventListener('DOMContentLoaded', function() {
|
| 71 |
setActiveNav(unansweredLink);
|
| 72 |
showUnansweredPanel();
|
| 73 |
+
|
| 74 |
+
// Add placeholder posts
|
| 75 |
+
const placeholderPosts = [
|
| 76 |
+
{
|
| 77 |
+
title: "How to implement binary search tree?",
|
| 78 |
+
body: "I'm struggling with implementing the insert function for a BST. Can someone explain the recursive approach?",
|
| 79 |
+
tags: ["BST", "Data Structures", "Recursion"],
|
| 80 |
+
responses: 0,
|
| 81 |
+
time: "30 minutes ago",
|
| 82 |
+
status: "unanswered"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
title: "Question about HW3 problem 5",
|
| 86 |
+
body: "The problem asks for O(n) solution but I can only think of O(n^2). Any hints?",
|
| 87 |
+
tags: ["Homework", "Algorithms"],
|
| 88 |
+
responses: 0,
|
| 89 |
+
time: "1 hour ago",
|
| 90 |
+
status: "unanswered"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
title: "Lecture 8 slides clarification",
|
| 94 |
+
body: "On slide 25, the time complexity analysis isn't clear to me. Can someone explain?",
|
| 95 |
+
tags: ["Lecture", "Time Complexity"],
|
| 96 |
+
responses: 0,
|
| 97 |
+
time: "2 hours ago",
|
| 98 |
+
status: "unanswered"
|
| 99 |
+
}
|
| 100 |
+
];
|
| 101 |
+
|
| 102 |
+
// Store for later use
|
| 103 |
+
window.placeholderPosts = placeholderPosts;
|
| 104 |
});
|
| 105 |
+
// Navigation
|
|
|
|
| 106 |
allQuestionsLink.addEventListener('click', function(e) {
|
| 107 |
e.preventDefault();
|
| 108 |
setActiveNav(allQuestionsLink);
|
|
|
|
| 146 |
feedContainer.className = 'space-y-4';
|
| 147 |
feedContainer.id = 'questions-feed';
|
| 148 |
|
| 149 |
+
// Add placeholder posts
|
| 150 |
+
window.placeholderPosts.forEach(post => {
|
| 151 |
+
const postElement = document.createElement('custom-post-card');
|
| 152 |
+
postElement.setAttribute('post', JSON.stringify({
|
| 153 |
+
title: post.title,
|
| 154 |
+
content: post.body,
|
| 155 |
+
tags: post.tags,
|
| 156 |
+
responses: post.responses,
|
| 157 |
+
time: post.time,
|
| 158 |
+
status: post.status,
|
| 159 |
+
confidence: Math.floor(Math.random() * 100),
|
| 160 |
+
upvotes: Math.floor(Math.random() * 10),
|
| 161 |
+
author: "Student " + Math.floor(Math.random() * 100)
|
| 162 |
+
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
feedContainer.appendChild(postElement);
|
| 164 |
});
|
|
|
|
| 165 |
postsList.appendChild(feedContainer);
|
| 166 |
feather.replace();
|
| 167 |
+
|
| 168 |
+
// Highlight unanswered filter in sidebar
|
| 169 |
+
const sidebar = document.querySelector('custom-sidebar');
|
| 170 |
+
if (sidebar) {
|
| 171 |
+
const shadow = sidebar.shadowRoot;
|
| 172 |
+
const filterItems = shadow.querySelectorAll('.filter-item');
|
| 173 |
+
filterItems.forEach(item => {
|
| 174 |
+
item.classList.remove('active');
|
| 175 |
+
if (item.textContent.includes('Unanswered')) {
|
| 176 |
+
item.classList.add('active');
|
| 177 |
+
}
|
| 178 |
+
});
|
| 179 |
+
}
|
| 180 |
}
|
| 181 |
+
function showPanel2(newPost) {
|
|
|
|
| 182 |
// Add fade out animation to form
|
| 183 |
postForm.classList.add('fade-out');
|
| 184 |
|