//use strict; //import * as Farapp from './fara.js'; let homeRE = new RegExp(/(https?:\S+\/$|index.html$)/); if (homeRE.test(window.location.href)) { window.addEventListener('load', () => { let nextimage = 0; let header = document.querySelector('header'); slider(); function slider() { /*** Fade in??*/ //opacity = 1; let images = [ 'img/fara_background.jpg', //'img/fara_bg_2.jpg', 'img/fara_bg_3.jpg', 'img/fara_bg_4.jpg', 'img/fara_bg_5.jpg', //'img/fara_bg_6.jpg', 'img/fara_bg_7.jpg', 'img/fara_bg_8.jpg', 'img/fara_bg_9.jpg', 'img/fara_bg_10.png', 'img/fara_bg_11.jpg', ]; if (nextimage >= images.length) { nextimage = 0; } header.setAttribute('style', 'background-image : url("' + images[nextimage++] + '");'); setTimeout(slider, 2000); } }); } /** * Apply active class to selected link... * @todo Inefficient!! */ window.addEventListener('load', () => { let navlinks = Array.from(document.querySelectorAll('#links a')); navlinks.forEach(element => { let ref = element.href.substr(element.href.lastIndexOf('/'), element.href.length); if (window.location.href.includes(ref)) { element.setAttribute('class', 'active'); } if (homeRE.test(window.location.href)) { navlinks[0].setAttribute('class', 'active'); } }); }); window.addEventListener('scroll', event => { let nav = document.querySelector('#nav'); let links = document.querySelector('#links'); if (window.pageYOffset !== 0) { nav.classList.add('bg-white', 'border'); nav.classList.remove('text-gray'); links.classList.add('nav-dark'); links.classList.remove('nav-light'); } else { nav.classList.add('text-gray'); nav.classList.remove('bg-white', 'border'); links.classList.add('nav-light'); links.classList.remove('nav-dark'); } });