Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 20 additions & 55 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,68 +775,33 @@ if (isIndexPage) {
// Clear out any cards from a previous search before showing new ones
resultsGrid.innerHTML = "";

if (!projects || projects.length === 0) { //if no projects returned from api, show the "no results" message and hide the grid
resultsGrid.style.display = "none";
resultsEmptyEl.style.display = "block";

// Show a friendly custom message when the user selected an interest
var selectedInterest = document.getElementById("interest")?.value;
if (selectedInterest) {
emptyMessageEl.textContent = "No projects are currently available for this interest. Please check back later or try a different area.";
} else if (message) {
emptyMessageEl.textContent = message;
} else {
emptyMessageEl.textContent = "Try adjusting your skills or choosing a different interest area.";
}

resultsSection.scrollIntoView({ behavior: "smooth" });
return;
if (!projects || projects.length === 0) {
resultsGrid.style.display = "none";
resultsEmptyEl.style.display = "block";

// Show a friendly custom message when the user selected an interest
var selectedInterest = document.getElementById("interest")?.value;
if (selectedInterest) {
emptyMessageEl.textContent = "No projects are currently available for this interest. Please check back later or try a different area.";
} else if (message) {
emptyMessageEl.textContent = message;
} else {
emptyMessageEl.textContent = "Try adjusting your skills or choosing a different interest area.";
}

resultsEmptyEl.style.display = "none";
resultsGrid.style.display = "grid";

//build a card for each project and add it to the grid
projects.forEach(function (project) {
resultsGrid.appendChild(buildProjectCard(project));
});

resultsSection.scrollIntoView({ behavior: "smooth" });
return;
}

// builds one project card as a DOM element and returns it
// the card has title, short description, tags and link
function buildProjectCard(project) {
var card = document.createElement("div");
card.className = "project-card";

// Title
var title = document.createElement("h3");
title.className = "project-card-title";
title.textContent = project.title;

// Description (truncated for visual consistency)
var desc = document.createElement("p");
desc.className = "project-card-desc";
// Cut description to 120 chars so all cards stay the same height
desc.textContent = truncate(project.description, 120);

// Tags row
var tagsRow = document.createElement("div");
tagsRow.className = "project-card-tags";

// Show all project skills as tags so users can see the full match
(project.skills || []).forEach(function (skill) {
tagsRow.appendChild(createTag(skill, "skill"));
});
resultsEmptyEl.style.display = "none";
resultsGrid.style.display = "grid";

// Level tag (colour-coded via CSS class)
// Lowercase so it matches the CSS class names like "level beginner", "level advanced"
var levelClass = "level " + (project.level || "").toLowerCase();
tagsRow.appendChild(createTag(project.level, levelClass));
projects.forEach(function (project) {
resultsGrid.appendChild(buildProjectCard(project));
});

// Time tag
tagsRow.appendChild(createTag("Time: " + project.time, "time"));
resultsSection.scrollIntoView({ behavior: "smooth" });
}

// builds one project card as a DOM element and returns it
// the card has title, short description, tags and link
Expand Down
Loading