add countdown and some bug fixes like csv
This commit is contained in:
parent
2b1e35e55f
commit
d41551c806
18 changed files with 263 additions and 205 deletions
47
assets/development/scripts/countdown.js
Normal file
47
assets/development/scripts/countdown.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
const countdown = document.getElementById('countdown')
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
const daysContainer = document.getElementById('days')
|
||||
const hoursContainer = document.getElementById('hours')
|
||||
const minutesContainer = document.getElementById('minutes')
|
||||
const secondsContainer = document.getElementById('seconds')
|
||||
|
||||
let target = new Date("2020-09-04 15:00:00")
|
||||
|
||||
let shown = false
|
||||
|
||||
function render() {
|
||||
let current = new Date()
|
||||
let difference = target - current
|
||||
|
||||
var _second = 1000,
|
||||
_minute = _second * 60,
|
||||
_hour = _minute * 60,
|
||||
_day = _hour * 24;
|
||||
|
||||
var days = Math.floor(difference / _day),
|
||||
hours = Math.floor((difference % _day) / _hour),
|
||||
minutes = Math.floor((difference % _hour) / _minute),
|
||||
seconds = Math.floor((difference % _minute) / _second);
|
||||
|
||||
days = (String(days).length >= 2) ? days : '0' + days;
|
||||
hours = (String(hours).length >= 2) ? hours : '0' + hours;
|
||||
minutes = (String(minutes).length >= 2) ? minutes : '0' + minutes;
|
||||
seconds = (String(seconds).length >= 2) ? seconds : '0' + seconds;
|
||||
|
||||
daysContainer.textContent = days
|
||||
hoursContainer.textContent = hours
|
||||
minutesContainer.textContent = minutes
|
||||
secondsContainer.textContent = seconds
|
||||
|
||||
if (!shown) {
|
||||
setTimeout(() => {
|
||||
countdown.style.opacity = 1
|
||||
shown = true
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render()
|
||||
setInterval(render, 1000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue