// About page hero — vanilla fade-carousel (replaces Bootstrap Carousel). (function () { const caro = document.getElementById('caro-lead'); const tv = document.getElementById('tv'); // full-bleed grayscale bg video if (tv) { try { tv.play(); } catch (e) {} } if (!caro) return; const slides = Array.from(caro.querySelectorAll('.dw-fade-slide')); const dots = Array.from(caro.querySelectorAll('.dw-fade-dot')); const INTERVAL = 5000; let index = 0; let timer = null; // The brain slide's #brain SVG ships with .hide-svg; reveal + line-draw it. function drawBrain(slide) { const brain = slide.querySelector('#brain'); if (!brain || !window.DrawFillSVG) return; window.setTimeout(function () { brain.classList.remove('hide-svg', 'fade-svg'); try { new window.DrawFillSVG({ elementId: 'brain' }).replay(); } catch (e) {} }, 600); } function activate(i) { i = Math.max(0, Math.min(slides.length - 1, i)); // wrap:false → clamp index = i; slides.forEach((s, n) => s.classList.toggle('active', n === i)); dots.forEach((d, n) => d.classList.toggle('active', n === i)); drawBrain(slides[i]); } function next() { if (index >= slides.length - 1) { stop(); return; } // wrap:false — stop at end activate(index + 1); } function start() { stop(); timer = window.setInterval(next, INTERVAL); } function stop() { if (timer) { window.clearInterval(timer); timer = null; } } dots.forEach(function (d) { d.addEventListener('click', function (e) { e.preventDefault(); activate(parseInt(d.dataset.slide, 10) || 0); start(); }); }); document.addEventListener('keyup', function (e) { if (e.key === 'ArrowRight') activate(index + 1); else if (e.key === 'ArrowLeft') activate(index - 1); }); caro.addEventListener('mouseenter', stop); caro.addEventListener('mouseleave', start); activate(0); start(); })(); // navbar hide/show on scroll (ported from jQuery dw_hidenav) (function () { const navbar = document.querySelector('.navbar'); if (!navbar) return; const title = document.querySelector('.site-title a'); const headerHeight = navbar.offsetHeight; let previousTop = 0; window.addEventListener('scroll', function () { const currentTop = window.scrollY; if (currentTop < previousTop) { if (currentTop > 0 && navbar.classList.contains('fixed')) { navbar.classList.add('visible'); if (title) title.classList.remove('light'); } else { navbar.classList.remove('visible', 'fixed'); if (title) title.classList.add('light'); } } else { navbar.classList.remove('visible'); if (currentTop > headerHeight && !navbar.classList.contains('fixed')) { navbar.classList.add('fixed'); } } previousTop = currentTop; }, { passive: true }); })(); document.querySelectorAll('.nav-toggle').forEach(function (el) { el.addEventListener('click', function (e) { e.preventDefault(); el.classList.toggle('active'); }); }); // Comment-form validation (jquery-validation) + FullCalendar still use jQuery. jQuery(document).ready(function ($) { $('#commentform').validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 3 } }, messages: { author: 'Please enter in your name.', email: 'Please enter a valid email address.', comment: 'Nothing to Say?' }, errorElement: 'div', errorPlacement: function (error, element) { element.before(error); } }); var calendarEl = document.getElementById('calendar'); if (calendarEl) { var calendar = new FullCalendar.Calendar(calendarEl, { headerToolbar: { start: 'title', center: '', end: 'prev,next' }, firstDay: 1, height: 380, views: { dayGrid: { hiddenDays: [0, 6, 7] }, timeGrid: { slotMinTime: '08:00:00', slotMaxTime: '17:00:00', dayHeaderFormat: { weekday: 'short' }, hiddenDays: [0, 6, 7] } }, googleCalendarApiKey: 'AIzaSyAGowGJYx6dOaQvG_vSUI73uT88VWOTcNQ', events: { googleCalendarId: 'davidawindham.com_bvrht1f8n2vgldgjenpgfdd4bk@group.calendar.google.com', className: 'gcal-event' }, eventDataTransform: function (event) { event.url = ''; return event; }, eventClick: function (info) { info.jsEvent.preventDefault(); } }); calendar.render(); } });