var isIphone = !! (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) var isIpad = !! (navigator.userAgent.match(/iPad/i)) var isAndroid = !! (navigator.userAgent.match(/Android/i)) var isMobile = isIphone || isIpad || isAndroid var isDesktop = ! isMobile var youtubePlayer = null document.body.classList.add(isDesktop ? 'desktop' : 'mobile') $(function(){ $.getJSON('/db.json', function(data){ site = data var entries = site.entries = {} site.entry.forEach(function(entry){ entries[entry.id] = entry entry.tags = entry.tags.split('#').map(function(tag){ return tag.trim() }) }) ready() }); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-35821710-3', 'auto'); ga('send', 'pageview'); }) function ready() { bind() build() } function bind(){ $('.cell').click( function(){ var id = $(this).data().id var entry = site.entries[id] show_entry(entry) }) $('.close').click( function(){ close_modals() }) $('.page, #entry').click( function(){ close_modals() }) $('.inner').click( function(e){ e.stopPropagation() }) $('.tag').click( function(){ var tag = $(this).html() filter_by_tag(tag) }) new Flickity( "#testimonials", { cellSelector: '.testimonial', wrapAround: true, prevNextButtons: false, pageDots: false, setGallerySize: false, draggable: true, autoPlay: 5000, }) postGallery = new Flickity( "#posts", { cellSelector: '.cell', wrapAround: true, prevNextButtons: false, pageDots: false, setGallerySize: false, draggable: true, autoPlay: 0, }) $("#left").click(() => { postGallery.next() }) $("#right").click(() => { postGallery.previous() }) } function build(){ $('.cell').each( function(){ var id = $(this).data().id var entry = site.entries[id] if (! entry) return if (entry.media && entry.media.length) { /* var media = entry.media[0] switch (media.type) { case 'youtube': bg = media.thumb break case 'image': bg = media.uri break } */ // $(this).css('background-image', 'url(' + bg + ')') if (youtubePlayer) { youtubePlayer.seekTo(0, true) return youtubePlayer.playVideo() } } }) } function show_entry(entry){ console.log('showing', entry) $('#entry h2').html(entry.title) $('#entry .content').html(newlineToBr(entry.body)) $('#entry .media').empty() if (entry.gallery) { } else { } $('body').addClass('entry') } function hide_entry(){ setTimeout(clear_entry, 500) } function clear_entry(){ } function close_modals(){ $('body').removeClass('entry').removeClass('about') } function newlineToBr(s){ return s.replace(/\n/g,'
') }