--- layout: none permalink: assets/js/main.js --- /** * AnchorJS */ $(document).ready(function () { anchors.options = { placement: 'left' }; anchors.add('h2:not(.no-anchor)'); }) /** * Function to open external links in separate tab */ $(document).ready(function external_new_window() { for (var c = document.getElementsByTagName("a"), a = 0; a < c.length; a++) { var b = c[a]; if (b.getAttribute("href") && b.hostname !== location.hostname) { b.target = "_blank"; b.rel = "noopener"; } } }); /** * Settings for side navigation */ $(document).ready(function () { // Initialize navgoco with default options $("#side-nav>ul").navgoco({ caretHtml: '', accordion: true, openClass: 'active', // open save: false, // leave false or nav highlighting doesn't work right cookie: { name: 'navgoco', expires: false, path: '/' }, slide: { duration: 400, easing: 'swing' } }); }); /** * Activate tooltips */ $(function () { var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl, { animation: false }) }) }) /** * Activate popovers */ $(function () { var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')) var popoverList = popoverTriggerList.map(function (popoverTriggerEl) { return new bootstrap.Popover(popoverTriggerEl) }) }) /** * Back to top button */ var toggleHeight = $(window).outerHeight() / 2; $(window).scroll(function () { if ($(window).scrollTop() > toggleHeight) { //Adds active class to make button visible $("#back-to-top").addClass("visible"); } else { //Removes active class to make button visible $("#back-to-top").removeClass("visible"); } }); //Scrolls the user to the top of the page again function topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } /** * Making relevant events visible */ function nowToDateString() { return new Date().toISOString().substring(0, 10); }; function show_upcoming_events() { var dstr = nowToDateString(); var events_block = $(document.getElementsByClassName("upcoming_events")); var elements = $('li.upcoming_event').filter(function () { return $(this).data('start') >= dstr; }); if ($(elements).length > 0) { events_block.show() } elements.show(); }; function show_past_events() { var dstr = nowToDateString(); var events_block = $(document.getElementsByClassName("past_events")); var elements = $('li.past_event').filter(function () { return $(this).data('start') < dstr; }); if ($(elements).length > 0) { events_block.show() } elements.show(); };