2020-05-29 17:39:33 +02:00
|
|
|
window._domloaded = false;
|
|
|
|
document.addEventListener("DOMContentLoaded",function() {
|
|
|
|
if(window._domloaded) return;
|
|
|
|
window._domloaded = true;
|
|
|
|
|
|
|
|
(function sandwich() {
|
2020-06-02 09:55:36 +02:00
|
|
|
const navbar = document.querySelector('.navbar-collapse');
|
|
|
|
const navtoggle = document.querySelector('.navbar-toggle');
|
|
|
|
const navCollapse = () => {
|
2020-05-29 17:39:33 +02:00
|
|
|
navbar.setAttribute('class', 'navbar-collapse collapse');
|
|
|
|
}
|
2020-06-02 09:55:36 +02:00
|
|
|
const navCollapsing = () => {
|
2020-05-29 17:39:33 +02:00
|
|
|
navbar.setAttribute('class', 'navbar-collapse collapsing');
|
|
|
|
}
|
|
|
|
|
2020-06-11 13:20:07 +02:00
|
|
|
const someHeader = document.querySelector('header')
|
|
|
|
if(someHeader) someHeader.addEventListener('click', navCollapse)
|
2020-06-03 10:21:45 +02:00
|
|
|
document.querySelector('main').addEventListener('click', navCollapse)
|
2020-05-29 17:39:33 +02:00
|
|
|
|
2020-06-03 10:21:45 +02:00
|
|
|
document.querySelector('nav').addEventListener('click', () => {
|
2020-05-29 17:39:33 +02:00
|
|
|
if(window.getComputedStyle(navtoggle)['display'] === 'none') return;
|
|
|
|
if(navbar.getAttribute('class').indexOf('collapsing') >= 0) {
|
|
|
|
navCollapse();
|
|
|
|
} else {
|
|
|
|
navCollapsing();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
|
2020-06-11 12:28:11 +02:00
|
|
|
new SimpleLightbox('.lbox');
|
|
|
|
new Headroom(document.querySelector(".navbar"), {
|
|
|
|
offset: 100,
|
|
|
|
tolerance: {
|
|
|
|
up: 10,
|
|
|
|
down: 0
|
|
|
|
},
|
|
|
|
classes : {
|
|
|
|
initial : "headroom",
|
|
|
|
pinned : "headroom-pinned",
|
|
|
|
unpinned : "headroom-unpinned",
|
|
|
|
top : "headroom-top",
|
|
|
|
notTop : "headroom-not-top",
|
|
|
|
bottom : "headroom-bottom",
|
|
|
|
notBottom : "headroom-not-bottom",
|
|
|
|
frozen: "headroom-frozen"
|
|
|
|
}
|
|
|
|
}).init();
|
2020-05-30 10:04:25 +02:00
|
|
|
|
2020-06-10 15:51:32 +02:00
|
|
|
(function() {
|
|
|
|
const $target = document.querySelector('#searchapp');
|
|
|
|
const $pages = document.querySelector('#resultaten .pages');
|
|
|
|
if(!($target && window.searchposts)) return;
|
|
|
|
|
|
|
|
const query = new URLSearchParams(window.location.search);
|
|
|
|
const searchString = query.get('q') || "";
|
|
|
|
document.querySelector('#zoekentxt').value = searchString;
|
|
|
|
|
|
|
|
// Our index uses title as a reference
|
|
|
|
const postsByTitle = window.searchposts.reduce((acc, curr) => {
|
|
|
|
acc[curr.title] = curr;
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
fetch('/js/brainbaking-post.json').then(function (res) {
|
|
|
|
return res.json();
|
|
|
|
}).then(function (data) {
|
|
|
|
const index = lunr.Index.load(data);
|
|
|
|
const matches = index.search(searchString);
|
|
|
|
const matchPosts = [];
|
|
|
|
matches.forEach((m) => {
|
|
|
|
matchPosts.push(postsByTitle[m.ref]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$pages.innerHTML = `(${matches.length})`;
|
|
|
|
if (matchPosts.length > 0) {
|
|
|
|
$target.innerHTML = matchPosts.filter(p => p).map(p => {
|
|
|
|
return `<article>
|
|
|
|
<h3><a href="${p.link}">${p.title}</a></h3>
|
|
|
|
<p>${p.content}...</p>
|
|
|
|
</article>`;
|
|
|
|
}).join('');
|
|
|
|
} else {
|
|
|
|
$target.innerHTML = `<article>No relevant search results found.</article>`;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})()
|
|
|
|
|
2020-05-29 17:39:33 +02:00
|
|
|
});
|