var Countdown = View.extend({ el: ".countdown", countdownTo: new Date(2019, 9, 5, 0, 0, 0), events: { }, initialize: function(){ this.__super__.initialize.call(this) this.update() }, update() { var now = (this.countdownTo - new Date()) / 1000 if (now < 0) { if (now > -86400) { this.$el.html("today's the day!") } else { this.$el.html("bucky says congrats!!!!") } return } var seconds = Math.floor(now % 60) now /= 60 var minutes = Math.floor(now % 60) now /= 60 var hours = Math.floor(now % 24) now /= 24 var days = Math.floor(now % 7) now /= 7 var weeks = Math.floor(now) var date_string = [ '', (weeks ? ( (weeks && days) ? weeks + ' week' + courtesy_s(weeks) + ',' : weeks + ' week' + courtesy_s(weeks) + '' ) : '' ), (days ? days + ' day' + courtesy_s(days) : ''), '', hours, 'hour' + courtesy_s(hours) + ',', minutes, 'minute' + courtesy_s(minutes) + ',', seconds, 'second' + courtesy_s(seconds), ].join(' ') this.$el.html( date_string + "
until the big day!") setTimeout(this.update.bind(this), 1000) }, })