Permalink
Browse files

Merge commit 'de0fadd1e830f701bef9286038fa8302fd3aced7'

  • Loading branch information...
2 parents c78b101 + de0fadd commit b0f9862ffe334964356d79d62f665eea7d57a8e7 @domharrington domharrington committed Feb 17, 2014
Showing with 117 additions and 1,172 deletions.
  1. +24 −1 app.js
  2. +0 −1,154 public/javascripts/countdown.js
  3. +58 −5 public/javascripts/index.js
  4. +24 −7 public/stylesheets/style.css
  5. +10 −5 views/index.jade
  6. +1 −0 views/layout.jade
View
25 app.js
@@ -26,7 +26,30 @@ if ('development' === app.get('env')) {
}
app.get('/', function (req, res) {
- res.render('index', { name: process.env.EVENT_NAME || 'No event', date: process.env.EVENT_DATE })
+ var events = JSON.parse(process.env.EVENTS)
+ , lastEventDate = new Date()
+ , newEventDate = new Date()
+ , nextEvent = false
+
+ events.forEach(function (event) {
+ var eventDate = new Date(event.date)
+
+ if (eventDate < lastEventDate) lastEventDate = eventDate
+
+ if (eventDate > newEventDate) {
+ nextEvent = event
+ }
+ })
+
+ // Default to Christmas
+ if (!nextEvent) {
+ var christmasDate = new Date()
+ christmasDate.setMonth(11, 25)
+
+ nextEvent = { name: 'Christmas', date: christmasDate.toString() }
+ }
+
+ res.render('index', { nextEvent: nextEvent, lastEventDate: lastEventDate.toString() })
})
http.createServer(app).listen(app.get('port'), function(){
Oops, something went wrong.

0 comments on commit b0f9862

Please sign in to comment.