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) var date_string = [ "", days, 'days', hours, 'hours,', minutes, 'minutes,', seconds, 'seconds', ].join(' ') this.$el.html( date_string + "
until the big day!") setTimeout(this.update.bind(this), 1000) }, })