mirror of
https://github.com/caddyserver/website.git
synced 2025-04-22 04:56:17 -04:00
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
const resp = fetch("/resources/testimonials.json").then(async resp => {
|
|
const testimonials = await resp.json();
|
|
console.log(testimonials);
|
|
|
|
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 || "";
|
|
}
|
|
$_('.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);
|
|
}
|
|
|
|
on('mouseover', '.rollover', e => {
|
|
const target = e.target.closest('.rollover') || e.target;
|
|
$$_(`.${target.dataset.rollover}`).forEach(elem => elem.classList.add('show'));
|
|
});
|
|
on('mouseout', '.rollover', e => {
|
|
const target = e.target.closest('.rollover') || e.target;
|
|
$$_(`.${target.dataset.rollover}`).forEach(elem => elem.classList.remove('show'));
|
|
});
|
|
});
|
|
});
|