Skip to content

Commit

Permalink
Add Darius' Trip and add an id to each Trip so perma-url can be provi…
Browse files Browse the repository at this point in the history
…ded.
  • Loading branch information
strongpauly committed Feb 21, 2016
1 parent 793aed9 commit adf5c4e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
40 changes: 22 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script type="text/javascript" src="script/SnowReport.js"></script>
<script type="text/javascript" src="script/WebServiceSnowReport.js"></script>
<script type="text/javascript" src="script/WindMap.js"></script>
<script type="text/javascript" src="script/destinations.js"></script>
<script type="text/javascript" src="script/destinations.js"></script>
<script type="text/javascript">
var withMillis = false;

Expand All @@ -26,7 +26,7 @@
params = params.split("&");
for (var i=0; i<params.length; i++)
{
var param = params[i].toLowerCase();
var param = params[i].toLowerCase();
if(param.indexOf('withmillis') == 0)
{
var pair = param.split('=');
Expand All @@ -42,31 +42,35 @@
}
}
})();
var trips = [

var trips = [
new Trip(portesDuSoleil, 'Season', 'Morzine, France',
new Date('December 29, 2015 14:10:00'),
new Date('December 30, 2015 10:00:00'),
new Date('December 29, 2015 14:10:00'),
new Date('December 30, 2015 10:00:00'),
new Date('April 20, 2016 17:00:00'))
, new Trip(portesDuSoleil, 'Spring Trip', 'Morzine, France',
new Date('March 06, 2016 14:10:00'),
new Date('March 07, 2016 10:00:00'),
new Date('March 06, 2016 14:10:00'),
new Date('March 07, 2016 10:00:00'),
new Date('March 13, 2016 17:00:00'))
];
, new Trip(portesDuSoleil, 'Darius Trip', 'Morzine, France',
new Date('March 16, 2016 17:00:00'),
new Date('March 17, 2016 10:00:00'),
new Date('March 21, 2016 17:00:00'))
];

trips.sort(function(a, b)
{
return a.flight - b.flight;
});

$(document).ready(function() {

var parent = $('#destinations');
var renderTime = new Date();
var allOver = true;
for(var i=0; i< trips.length; i++)
{
var trip = trips[i];
var trip = trips[i];
trip.render(parent, renderTime);
allOver = allOver && trip.isOver(renderTime);
}
Expand All @@ -75,30 +79,30 @@
{
parent.html("<h2><p>Boarding over for the season :( </p><p>Get planning!</p></h2>");
}

window.updating = 0;

function update()
{
{
var now = new Date();
for(var i=0; i< trips.length; i++)
{
var trip = trips[i];
var trip = trips[i];
trip.update(now);
}
}
window.updating = setTimeout(update, withMillis ? 100 : 1000);
}
update();
});
</script>
<title>Snowboarding!</title>
</head>
<body>
<body>
<div id="outer">
<h1><img src="img/flux.png"/>Snowboarding 2015/16</h1>
<div id="destinations"></div>
<div style="clear:both"></div>
<button onclick="clearTimeout(updating)" type="button" style="display:none">Stop</button>
<div style="clear:both"></div>
<button onclick="clearTimeout(updating)" type="button" style="display:none">Stop</button>
</div>
</body>
</html>
30 changes: 16 additions & 14 deletions script/Trip.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Trip = function(destination, name, resort, flight, board, end)
{
this.destination = destination;
this.name = name;
this.id = this.name = name;
this.resort = resort;
this.flight = flight;
this.board = board;
Expand All @@ -25,7 +25,7 @@ Trip.prototype.render = function(parent, now)
}
}

Trip.prototype.isOver = function(now)
Trip.prototype.isOver = function(now)
{
return this.end < now;
}
Expand All @@ -45,11 +45,11 @@ Trip.prototype.update = function(now)
var during = end > now;
if(flight)
{
message = during ? "You've arrived. Get boarding!" : "It's over :( Whens the next trip?";
message = during ? "You've arrived. Get boarding!" : "It's over :( Whens the next trip?";
}
else
else
{
message = during ? "You're there! Hope you're having fun!" : "It's over :( Whens the next trip?";
message = during ? "You're there! Hope you're having fun!" : "It's over :( Whens the next trip?";
}
return '<div class="pastEvent">'+message+'</div>'
}
Expand All @@ -59,7 +59,7 @@ Trip.prototype.update = function(now)
+'<div class="timeSeconds">' + now.timeUntilSeconds(date, offset) + '</div>';
}

$('.flightTime', this.dom).html(getTimeHtml(this.flight, 0, true));
$('.flightTime', this.dom).html(getTimeHtml(this.flight, 0, true));
$('.boardTime', this.dom).html(getTimeHtml(this.board, this.destination.offset, false));
}
}
Expand All @@ -70,7 +70,7 @@ Trip.prototype.getHtml = function(now)
if( this.isOver(now) )
{
return '';
}
}
var html = ['<div class="'];
var destination = this.destination;
if(destination.maps != null)
Expand All @@ -81,19 +81,21 @@ Trip.prototype.getHtml = function(now)
{
html.push('destination');
}
html.push('"><div class="times"><h2>');
html.push('" id="');
html.push(this.id)
html.push('"><div class="times"><h2>');
html.push('<div class="trip-name">');
html.push(this.name);
html.push('</div>');
html.push('</div>');
html.push('<div class="resort">');
//Fallback to destination resort if not specified.
html.push(this.resort != null ? this.resort : (destination.resort != null ? destination.resort + ', ' + destination.country : destination.country));
html.push('</div>');
html.push('<span class="localTime"></span>');
html.push('<span class="localTime"></span>');
html.push('</h2><h3>Flight: ' + this.flight.toDateTimeString() + '</h3>'
+'<div class="flightTime"></div>'
+'<h3>Snowboarding: '+this.board.toDateTimeString()+'</h3>'
+'<div class="boardTime"></div>');
+'<div class="boardTime"></div>');
if(destination.maps != null)
{
html.push('<h3>Maps</h3>');
Expand All @@ -105,7 +107,7 @@ Trip.prototype.getHtml = function(now)
html.push('</div>');
}
if(destination.webcams != null)
{
{
html.push('<h3>Web Cams</h3>');
html.push('<div class="webcams">');
for(var i=0; i<destination.webcams.length; i++)
Expand Down Expand Up @@ -141,8 +143,8 @@ Trip.prototype.getHtml = function(now)
html.push(destination.windMap.getHtml());
html.push('</div>');
}

html.push('</div>')
return html.join('');
}
})();
})();

0 comments on commit adf5c4e

Please sign in to comment.