async function fetchfutureprojects() {
try {
const response = await fetch('futureprojects.json');
if (!response.ok) {
throw new Error("VPS response is bad");
}
const futureprojects = await response.json();
return futureprojects;
} catch (error) {
console.error("Failed to fetch futureprojects:", error);
return [];
};
};
function renderfutureprojects(filteredfutureprojects) {
const futureprojectList = document.getElementById('projectsFuture');
futureprojectList.innerHTML = "";
if (filteredfutureprojects.length === 0) {
futureprojectList.innerHTML = "
No futureprojects.
"
return;
}
filteredfutureprojects.sort((a, b) => b.description - a.description);
filteredfutureprojects.forEach(futureproject => {
const futureprojectItem = document.createElement("div");
futureprojectItem.className = "futureproject-div";
futureprojectItem.innerHTML = `
${futureproject.subheader}
${futureproject.description}
Go to ${futureproject.name}!
`;
futureprojectList.appendChild(futureprojectItem);
});
};
async function filterfutureprojects(filterType) {
const futureprojects = await fetchfutureprojects();
let filteredfutureprojects;
if (filterType) {
filteredfutureprojects = futureprojects;
}
renderfutureprojects(filteredfutureprojects);
}
filterfutureprojects('all');