From 6aa99359877cf58560305be6104c78a8a9439638 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 13 Jul 2019 13:02:58 +0200 Subject: adding countdown!!! --- public/assets/js/lib/views/index/countdown.js | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 public/assets/js/lib/views/index/countdown.js (limited to 'public/assets/js/lib/views/index/countdown.js') diff --git a/public/assets/js/lib/views/index/countdown.js b/public/assets/js/lib/views/index/countdown.js new file mode 100644 index 0000000..f2fd666 --- /dev/null +++ b/public/assets/js/lib/views/index/countdown.js @@ -0,0 +1,40 @@ +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) + }, +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2