caddy-website/new/resources/js/home.js

28 lines
1 KiB
JavaScript
Raw Normal View History

2023-10-10 12:03:33 -06:00
const resp = fetch("/resources/testimonials.json").then(async resp => {
const testimonials = await resp.json();
2023-10-07 16:43:39 -06:00
console.log(testimonials);
2023-10-10 12:03:33 -06:00
ready(function() {
for (let i = 0; i < testimonials.length; i++) {
const testimonial = testimonials[i];
const tpl = cloneTemplate('#tpl-testimonial');
$_('.testimonial-picture', tpl).src = testimonial.picture || "";
$_('.testimonial-quote', tpl).innerText = `"${testimonial.quote}"`;
if (testimonial.username) {
$_('.testimonial-name', tpl).innerText = ` @${testimonial.username}`;
} else {
$_('.testimonial-name', tpl).innerText = testimonial.name || "";
}
2023-12-05 20:55:44 -07:00
if (testimonial.link) {
$_('.testimonial-name', tpl).href = testimonial.link;
}
$_('.testimonial-role', tpl).innerText = testimonial.role || "";
if (testimonial.org) {
$_('.testimonial-role', tpl).appendChild(document.createElement("br"));
$_('.testimonial-role', tpl).appendChild(document.createTextNode(testimonial.org));
}
$_(`.testimonial-col:nth-child(${i%3 + 1})`).append(tpl);
2023-10-10 12:03:33 -06:00
}
});
});