Skip to content

Commit

Permalink
Merge pull request #189 from SergeBredin/alpha
Browse files Browse the repository at this point in the history
fix issue with favorite on Firefox + now date on avatars
  • Loading branch information
vallettea committed Jan 19, 2016
2 parents 94dc4d6 + f490b4b commit 45e93a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions client/js/favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion client/views/placeView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?
Expand Down
27 changes: 12 additions & 15 deletions server/getMeasures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
});
Expand All @@ -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<nbTicksX; ++i) {

var beginTick = new Date(start.getTime() + i*15*60*1000);
var endTick = new Date(start.getTime() + (i+1)*15*60*1000);
var beginTick = moment(start).add(15*i,'minutes').toDate();
var endTick = moment(start).add(15*(i+1),'minutes').toDate();

var date = new Date(now);
date.setHours(8+Math.floor(i/4),i*15%60, 0);
Expand Down Expand Up @@ -182,8 +181,8 @@ function processMeasures(place, start, end, mode){
var iTickXEnd = iTickXStart;
for (var i = 0; i<nbTicksX; ++i) {

var beginTick = new Date(start.getTime() + i*15*60*1000);
var endTick = new Date(start.getTime() + (i+1)*15*60*1000);
var beginTick = moment(start).add(15*i,'minutes').toDate();
var endTick = moment(start).add(15*(i+1),'minutes').toDate();

if(measure.date < endTick) break;
if(endTick > now ) break;
Expand All @@ -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;
Expand Down Expand Up @@ -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 ||
Expand Down

0 comments on commit 45e93a6

Please sign in to comment.