forked from nebulosus/web
30 lines
No EOL
901 B
JavaScript
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; |