durfdoen-2.0/content/assets/js/random_vereniging.js

16 lines
585 B
JavaScript
Raw Normal View History

2020-09-15 17:56:12 +02:00
window.addEventListener('load', function() {
let options = document.getElementsByClassName('randomVerenigingWrapper');
let selected = Array.from(options).map(x => ({ x, r: Math.random() + -0.5 * x.hasAttribute('data-iszeus')}))
.sort((a, b) => a.r - b.r)
.map(a => a.x)
.slice(0, 3)
.map(x => ({ x, r: Math.random()}))
.sort((a, b) => a.r - b.r)
.map(a => a.x);
let destination = document.getElementById("display_repo");
for (node of selected) {
node.getElementsByTagName("img")[0].setAttribute("loading", "eager");
2020-09-15 18:31:44 +02:00
destination.prepend(node);
2020-09-15 17:56:12 +02:00
}
});