web/public/res/script/cases.js

30 lines
938 B
JavaScript
Raw Normal View History

2024-03-29 16:17:59 +01:00
class Case {
2024-03-29 17:54:45 +01:00
constructor(name = "Project", description = "This is a project.", url = undefined) {
2024-03-29 16:17:59 +01:00
this.name = name;
this.description = description;
this.url = url;
}
}
const CASES = [
];
const casesButton = document.querySelector("button#cases-button");
const casesDiv = document.querySelector("div#cases");
2024-03-29 17:54:45 +01:00
if (casesButton && CASES.length > 0) casesButton.hidden = false;
2024-03-29 16:17:59 +01:00
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
2024-03-29 17:54:45 +01:00
list.innerHTML += `<li><${c.url ? 'a' : 'span'} ${c.url ? 'href="' + c.url + '"' : ''}><strong>${c.name}<strong> - ${c.description}</${c.url ? 'a' : 'span'}></li>`;
2024-03-29 16:17:59 +01:00
});
casesDiv.appendChild(list);
}
casesButton.onclick = showCases;