(function($) { $(document).ready(function() { if ($('body.ps.home')) { // Make each .media section clickable to reach .// [ 'gfx', 'txt', 'vdo' ].forEach(function(id) { $('#' + id) .click(function(e) { window.location = `/${id}/`; return false }) .mouseover(function(e) { e.target.style.cursor = 'pointer' return false }) .mouseout(function(e) { e.target.style.cursor = 'not-allowed' return false }) }) $('.media').mouseout(function(e) { e.target.style.cursor = 'auto' return false }) } // EN/FR switch $('body') .append('') $('#lang-switch').click(function(e) { var lang = $('html').attr('lang') setLang(lang == 'fr' ? 'en' : 'fr') return false }) // Use ?lang=XX if available var URLParams = new URLSearchParams(window.location.search); if (URLParams.has('lang')) { console.log('Setting lang from param to ' + URLParams.get('lang')) setLang(URLParams.get('lang')) } else if (C.get('lang')) { console.log('Setting lang to ' + C.get('lang')) setLang(C.get('lang')) } // Translate to target lang function setLang(lang) { if (lang == 'fr') { $('html').attr('lang', lang) $('#lang-switch').html('EN').attr('title', 'Read in English') } else { lang = 'en' $('html').attr('lang', lang) $('#lang-switch').html('FR').attr('title', 'Lire en français') } C.set('lang', lang) } }); // Basic cookie functions var C = { set: function(name, value) { // Make the cookie expire at the end of session var cookie = name + '=' + encodeURIComponent(value) + ';path=/;domain=.lesoiseaux.io;secure' document.cookie = cookie return cookie }, get: function(name) { try { var val = document.cookie.split(';')[0] var key = name + '=' return (val.indexOf(key) == 0) ? decodeURIComponent(val.substr(key.length)) : null } catch(e) { return null } }, has: function(name) { try { return (document.cookie.split(';')[0].indexOf(name + '=') == 0) } catch(e) { return false } } } })($)