var CONCERTS = [{date: '2019-11-16', title: "Concert privé", programme: '/concerts/2019-11-16/programme.jpg'}, {date: '2018-10-12', title: "Muzicozoologie à 4 voix", programme: '/concerts/2018-10-12/programme.jpg', poster: '/concerts/2018-10-12/poster.jpg', flyer: '/concerts/2018-10-12/flyer.jpg'}, {date: '2017-11-12', title: "Contes, mythes et légendes", programme: '/concerts/2017-11-12/programme.jpg', poster: '/concerts/2017-11-12/poster.jpg', flyer: '/concerts/2017-11-12/flyer.jpg'}, {date: '2016-10-16', title: "Une nuit avec…", programme: '/concerts/2016-10-16/programme.jpg', poster: '/concerts/2016-10-16/poster.jpg', flyer: '/concerts/2016-10-16/flyer.jpg'}, {date: '2015-12-19', title: "Concert en couleurs", programme: '/concerts/2015-12-19/programme.jpg', poster: '/concerts/2015-12-19/poster.jpg', flyer: '/concerts/2015-12-19/flyer.jpg'}, {date: '2015-10-11', title: "Concert en couleurs", programme: '/concerts/2015-10-11/programme.jpg', poster: '/concerts/2015-10-11/poster.jpg', flyer: '/concerts/2015-10-11/flyer.jpg'}, {date: '2014-12-20', title: "Concert de Noël à Saint-Cyr-la-Rivière", programme: '/concerts/2014-12-20/programme.jpg', poster: '/concerts/2014-12-20/poster.jpg', flyer: '/concerts/2014-12-20/flyer.jpg'}, {date: '2014-10-12', title: "Chants de l'Air et des Eaux", programme: '/concerts/2014-10-12/programme.jpg', poster: '/concerts/2014-10-12/poster.jpg', flyer: '/concerts/2014-10-12/flyer.jpg'}, {date: '2014-06-12', title: "Chants de l'Air et de l'Eau", programme: '/concerts/2014-06-12/programme.jpg'}, {date: '2013-12-17', title: "Chantons Noël !", programme: '/concerts/2013-12-17/programme.jpg'}, {date: '2013-06-27', title: "Pendaison de crémaillère", programme: '/concerts/2013-06-27/programme.jpg'}, {date: '2020-10-11', title: "Des larmes au rire", programme: '/concerts/2020-10-11/programme.jpg', poster: '/concerts/2020-10-11/poster.jpg', flyer: '/concerts/2020-10-11/flyer.jpg'}]; /* Mise à jour 07/10/2020 12:09:05 */ function ImageSet(name) { this.name = name; this.images = []; this.activate = function(index) { if(index >= this.images.length) index = 0; if(index < 0) index = this.images.length -1; this.images[index].activate(); } } var IMAGESETS = {poster: new ImageSet('poster'), programme: new ImageSet('programme')}; function LargeImage(concert, type) { this.type = type; this.imgAddress = concert[type]; this.image; this.caption; this.action = function(event) { event.stopPropagation(); var action = ''; var X = event.clientX, Y = event.clientY; var boxRect = this.image.getBoundingClientRect(); if(Y < boxRect.top) action = 'exit'; else { if(Y < boxRect.top + boxRect.height) { if(X < boxRect.left) action = 'goprev'; else if(X > boxRect.left + boxRect.width) action = 'gonext'; } } var newIndex = this.index; switch(action) { case 'goprev': newIndex--; break; case 'gonext': newIndex++; break; case 'exit': deactivate('figure.large'); default: return; } this.imageSet.activate(newIndex); } if(!this.imgAddress) return; this.image = newNode('img', 'src=' + this.imgAddress, 'alt'); this.imgBox = newNode('figure', '.imgBox', this.image); this.figure = newNode('figure', '.large', '.' + this.type, this.imgBox); if(concert.title) { this.caption = newNode('figcaption', concert.title); this.figure.appendChild(this.caption); } this.figure.addEventListener('click', this.action.bind(this)); document.body.appendChild(this.figure); this.imageSet = IMAGESETS[this.type]; this.index = this.imageSet.images.length; this.imageSet.images.push(this); this.activate = function() { activate(this.figure, 'figure.large'); } } var CONCERT_OBJECTS = [], CONCERT_DATES = []; var today = new Date().toISOString().replace(/T.*$/, ''); function nextConcertHide(event) { if(event) event.stopPropagation(); if(!nextConcert) return; nextConcert.classList.remove('active'); } function nextConcertShow() { if(!nextConcert) return; nextConcert.classList.add('active'); setTimeout(nextConcertHide, 5000); } function Concert(data) { for(var property in data) this[property] = data[property]; this.dateIndex = 'D' + this.date; this.posterFig = new LargeImage(this, 'poster'); this.programmeFig = new LargeImage(this, 'programme'); this.posterShow = function(event) { event.stopPropagation(); this.posterFig.activate(); } this.programmeShow = function(event) { event.stopPropagation(); this.programmeFig.activate(); } if(this.flyer) { var img = newNode('img', 'src=' + this.flyer, 'alt='); img.addEventListener('click', this.posterShow.bind(this)); var caption = ''; if(this.title) { var caption = newNode('figcaption', this.title); caption.addEventListener('click', this.programmeShow.bind(this)); } this.flyerFig = newNode('figure', '.small', '.flyer', img, caption); this.flyerFig.addEventListener('click', this.posterShow.bind(this)); if(this.date >= today) { if(!nextConcert) nextConcert = nextConcert = newNode('figure', '#nextConcert', '.large'); nextConcert.innerHTML = ''; var nextConcertTitle = newNode('figcaption', "Notre prochain concert"); nextConcertTitle.addEventListener('click', nextConcertHide); nextConcert.appendChild(nextConcertTitle); nextConcert.appendChild(newNode('img', 'src=' + this.flyer, 'alt=')); } } if(this.programme) { var img = newNode('img', 'src=' + this.programme); var caption = ''; if(this.title) var caption = newNode('figcaption', this.title); this.progFig = newNode('figure', '.small', '.prog', img, caption); this.progFig.addEventListener('click', this.programmeShow.bind(this)); } CONCERT_DATES.push(this.dateIndex); CONCERT_OBJECTS[this.dateIndex] = this; } for(var i = 0; i < CONCERTS.length;i++) new Concert(CONCERTS[i]); CONCERT_DATES.sort(); CONCERT_DATES.reverse(); // console.log(CONCERT_DATES); function MakeConcertSection() { var concertList = newNode('figure', '#concertList'); for(var i = 0; i < CONCERT_DATES.length;i++) { var dateIndex = CONCERT_DATES[i]; var concert = CONCERT_OBJECTS[dateIndex]; if(concert.flyerFig) concertList.appendChild(concert.flyerFig); } var section = newNode('section', '#concerts', '.page', newNode('h2', 'Concerts'), concertList); MAIN.appendChild(section); } function MakeProgSection() { var programmeList = newNode('figure', '#programmeList'); for(var i = 0; i < CONCERT_DATES.length;i++) { var dateIndex = CONCERT_DATES[i]; var concert = CONCERT_OBJECTS[dateIndex]; if(concert.progFig) programmeList.appendChild(concert.progFig); } var section = newNode('section', '#programmes', '.page', newNode('h2', 'Programmes'), programmeList); MAIN.appendChild(section); } MakeConcertSection(); MakeProgSection(); if(nextConcert) { MAIN.appendChild(nextConcert); setTimeout(nextConcertShow, 200); }