web/public/res/cases.js
2024-03-29 16:17:59 +01:00

30 lines
No EOL
901 B
JavaScript

class Case {
constructor (name = "Project", description = "This is a project.", url = undefined) {
this.name = name;
this.description = description;
this.url = url;
}
}
const CASES = [
];
const casesButton = document.querySelector("button#cases-button");
const casesDiv = document.querySelector("div#cases");
if (casesButton && CASES.length > 0) casesButton.hidden = false;
function showCases() {
if (!casesButton) return console.log("k");
if (casesDiv.hidden) casesDiv.innerHTML = "";
casesDiv.hidden = !casesDiv.hidden;
let list = document.createElement("ul");
CASES.forEach(c => {
console.log(c);
// a dirty hack :p
list.innerHTML += `<li><${c.url ? 'a' : 'span'}><strong>${c.name}<strong> - ${c.description}</${c.url ? 'a' : 'span'}></li>`;
});
casesDiv.appendChild(list);
}
casesButton.onclick = showCases;