diff --git a/client/js/favorite.js b/client/js/favorite.js index 2dc959a..f98ae03 100644 --- a/client/js/favorite.js +++ b/client/js/favorite.js @@ -17,10 +17,10 @@ function getCookie(sName) { function changeFavorite(e){ - var button = e.srcElement.parentNode; + var button = e.currentTarget; var isFavorite = button.class === 'place-favorite'; button.class = isFavorite ? 'place-no-favorite' : 'place-favorite'; - e.srcElement.src = isFavorite ? '../img/no-favorite.svg' : '../img/favorite.svg'; + e.currentTarget.firstChild.src = isFavorite ? '../img/no-favorite.svg' : '../img/favorite.svg'; var id = button.id.replace('register-',''); var cookie_places = getCookie('6element-places') || ''; if(isFavorite) setCookie('6element-places', cookie_places.replace(id + ';',''));// remove place in cookie diff --git a/client/views/placeView.jsx b/client/views/placeView.jsx index 269f767..cb294a2 100644 --- a/client/views/placeView.jsx +++ b/client/views/placeView.jsx @@ -40,7 +40,9 @@ module.exports = React.createClass({ // OPENING HOURS var oh = place.opening_hours === null ? undefined : new opening_hours(place.opening_hours); - var now = fromUTC(momentTZ().tz('Europe/Paris').format()); + var now = momentTZ().tz('Europe/Paris').toDate(); + //console.log(now); + //var now = fromUTC(momentTZ().tz('Europe/Paris').format()); var isOpen = oh ? oh.getState(now) : true; var calendarJSX = NotEmpty(place.opening_hours) ? diff --git a/server/getMeasures.js b/server/getMeasures.js index cf74b96..1a3aa71 100644 --- a/server/getMeasures.js +++ b/server/getMeasures.js @@ -85,7 +85,6 @@ function processMeasures(place, start, end, mode){ place.measures.today !== undefined){ measures = place.measures.today.map(function(measure){ - //console.log(measure.date, '->', measure.value.length); var date = new Date(measure.date); return { date: date, signals: measure.value.length } }); @@ -95,13 +94,13 @@ function processMeasures(place, start, end, mode){ place.measures.latest !== undefined) ? place.measures.latest.max: 0; var nbTicksX = (20-8)*4; // every 15 minutes from 8am to 8pm - var now = new Date(momentTZ().tz('Europe/Paris').format()); + var now = momentTZ().tz('Europe/Paris').toDate(); // For each tick of 15 minutes for (var i = 0; i now ) break; @@ -207,10 +206,8 @@ function processMeasures(place, start, end, mode){ // 2) For the rest of the day, we expand the last status of avilability for (var i = iTickXStart; i<=nbTicksX; ++i) { - var beginTick = new Date(start.getTime() + i*15*60*1000); - var endTick = new Date(start.getTime() + (i+1)*15*60*1000); - - //if(endTick > now ) break; + var beginTick = moment(start).add(15*i,'minutes').toDate(); + var endTick = moment(start).add(15*(i+1),'minutes').toDate(); // This time, we go forward so do not invert values: var isOpen = oh ? oh.getState(beginTick) : true; @@ -239,14 +236,14 @@ module.exports = function(selection){ return new Promise(function(resolve, reject){ - var strToday = moment(selection.date).format('YYYY-MM-DD'); - var start = momentTZ.tz(strToday + ' 08:00', 'Europe/Paris'); - var end = momentTZ.tz(strToday + ' 20:00', 'Europe/Paris'); + var start = momentTZ.tz(selection.date, 'Europe/Paris').add(8,'hours').toDate(); + var end = momentTZ.tz(selection.date, 'Europe/Paris').add(20,'hours').toDate(); + var parameters = { id: place.pheromon_id, type: undefined, - start: new Date(start.format()), - end: new Date(end.format()) + start: start, + end: end } if( place.pheromon_id === null ||