web/public/res/script/cases.js
2024-04-09 15:29:00 +02:00

30 lines
No EOL
938 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'} ${c.url ? 'href="' + c.url + '"' : ''}><strong>${c.name}<strong> - ${c.description}</${c.url ? 'a' : 'span'}></li>`;
});
casesDiv.appendChild(list);
}
casesButton.onclick = showCases;