Publicidade

O Legado Genético das Ovelhas: Como a Física e a Biologia Decodificam 10 Mil Anos de Manipulação Humana

Publicidade

': '>', '"': '"', "'": ''' }[c]; }); } function plain(html) { var t = new DOMParser().parseFromString(html || '', 'text/html').body.textContent || ''; return t.replace(/\s+/g, ' ').trim(); } /* ===== MENU MOBILE ===== */ var toggleBtn = $('#mobileToggleBtn'), navMenu = $('#navMenu'); if (toggleBtn && navMenu) { toggleBtn.addEventListener('click', function () { var open = navMenu.classList.toggle('active'); toggleBtn.setAttribute('aria-expanded', open); }); $$('#navMenu > li > a[href="#"]').forEach(function (a) { a.addEventListener('click', function (e) { e.preventDefault(); a.parentNode.classList.toggle('open'); }); }); } /* ===== ITEM ATIVO DO MENU ===== */ (function () { var here = decodeURIComponent(location.pathname); var lis = $$('#navMenu > li'); var found = false; lis.forEach(function (li) { var hit = $$('a[href]', li).some(function (a) { var h = a.getAttribute('href'); return h && h !== '#' && decodeURIComponent(new URL(a.href).pathname) === here; }); if (hit) { found = true; } li.classList.toggle('active', hit); }); if (!found && lis[0] && here === '/') lis[0].classList.add('active'); })(); /* ===== CARROSSEL (ULTIMOS 5 POSTS, TROCA A CADA 3 SEGUNDOS) ===== */ var currentSlideIndex = 0, slides = [], dots = [], carouselInterval = null; function renderSlide(index) { if (!slides.length) return; currentSlideIndex = (index + slides.length) % slides.length; slides.forEach(function (s, i) { s.classList.toggle('active', i === currentSlideIndex); }); dots.forEach(function (x, i) { x.classList.toggle('active', i === currentSlideIndex); }); } function nextSlide() { renderSlide(currentSlideIndex + 1); } function startInterval() { if (!carouselInterval && slides.length > 1 && !reduce) carouselInterval = setInterval(nextSlide, 3000); } function stopInterval() { clearInterval(carouselInterval); carouselInterval = null; } function goToSlide(i) { renderSlide(i); stopInterval(); startInterval(); } window.goToSlide = goToSlide; var heroBox = $('#heroCarousel'); if (heroBox) { var prev = $('#heroPrev'), next = $('#heroNext'); if (prev) prev.addEventListener('click', function () { goToSlide(currentSlideIndex - 1); }); if (next) next.addEventListener('click', function () { goToSlide(currentSlideIndex + 1); }); heroBox.addEventListener('mouseenter', stopInterval); heroBox.addEventListener('mouseleave', startInterval); heroBox.addEventListener('focusin', stopInterval); heroBox.addEventListener('focusout', startInterval); fetch('/feeds/posts/default?alt=json&max-results=5') .then(function (r) { if (!r.ok) throw new Error('feed'); return r.json(); }) .then(function (data) { var entries = data.feed && data.feed.entry; if (!entries || !entries.length) return; var slidesHtml = '', dotsHtml = ''; entries.forEach(function (entry, idx) { var title = entry.title.$t; var postUrl = '#'; if (entry.link) { var alt = entry.link.filter(function (l) { return l.rel === 'alternate'; })[0]; if (alt) postUrl = alt.href; } var category = (entry.category && entry.category.length) ? entry.category[0].term : 'Notícias'; var snippet = plain(entry.summary ? entry.summary.$t : (entry.content ? entry.content.$t : '')); if (snippet.length > 150) snippet = snippet.substring(0, 150).replace(/\s+\S*$/, '') + '…'; var imgUrl = 'https://images.unsplash.com/photo-1462331940025-496dfbfc7564?w=1000&q=80'; if (entry.media$thumbnail) { imgUrl = entry.media$thumbnail.url.replace(/\/s72-c\//, '/s1280/').replace(/\/w72-h72-p-k-no-nu\//, '/w1280/'); } else if (entry.content && entry.content.$t) { var m = entry.content.$t.match(/src=["']([^"']+)["']/); if (m) imgUrl = m[1]; } var act = idx === 0 ? ' active' : ''; slidesHtml += ''; dotsHtml += ''; }); $('#carouselSlidesContainer').innerHTML = slidesHtml; $('#carouselDotsContainer').innerHTML = dotsHtml; slides = $$('.banner-slide', heroBox); dots = $$('.dot', heroBox); currentSlideIndex = 0; startInterval(); }) .catch(function () { /* mantem o destaque padrao */ }); } /* ===== PARALLAX (FUNDO E IMAGEM DO DESTAQUE) ===== */ var layers = $$('.px-layer'); var ticking = false; function parallax() { var y = window.pageYOffset || d.documentElement.scrollTop; layers.forEach(function (l) { l.style.transform = 'translate3d(0,' + (y * parseFloat(l.getAttribute('data-speed'))).toFixed(1) + 'px,0)'; }); if (heroBox) heroBox.style.setProperty('--py', Math.min(y * 0.12, 18).toFixed(1) + 'px'); ticking = false; } if (!reduce) { window.addEventListener('scroll', function () { if (!ticking) { ticking = true; requestAnimationFrame(parallax); } }, { passive: true }); parallax(); } /* ===== RELOGIO ===== */ var DIAS = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']; var MESES = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']; function updateClock() { var now = new Date(); var c = $('#homeClock'), dt = $('#homeDate'); if (c) c.textContent = now.toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' }); if (dt) dt.textContent = DIAS[now.getDay()] + ', ' + now.getDate() + ' ' + MESES[now.getMonth()]; } updateClock(); setInterval(updateClock, 1000); /* ===== DATAS EM PT-BR ===== */ $$('time.js-date').forEach(function (t) { var v = new Date(t.getAttribute('datetime')); if (!isNaN(v)) t.textContent = v.toLocaleDateString('pt-BR', { day: '2-digit', month: 'long', year: 'numeric' }); }); /* ===== NEWSLETTER (FEEDBURNER) ===== */ var nf = $('.nl-form'); if (nf) nf.addEventListener('submit', function () { window.open('https://feedburner.google.com/fb/a/mailverify?uri=' + encodeURIComponent(nf.getAttribute('data-feed')), 'popupwindow', 'scrollbars=yes,width=550,height=520'); return true; }); /* ===== ADSENSE: ativa cada espaco visivel uma unica vez ===== */ function loadAds() { $$('ins.adsbygoogle').forEach(function (ins) { if (ins.getAttribute('data-adsbygoogle-status') || ins.offsetWidth === 0) return; try { (window.adsbygoogle = window.adsbygoogle || []).push({}); } catch (e) { /* ignora */ } }); } if (d.readyState === 'complete') loadAds(); else window.addEventListener('load', loadAds); })(); //]]>