feat(countdown): redirect to /adhesion at the end
This commit is contained in:
parent
741ba5c10e
commit
16aa9bd4bb
1 changed files with 21 additions and 14 deletions
|
@ -69,25 +69,32 @@
|
|||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/luxon/3.3.0/luxon.min.js" integrity="sha512-KKbQg5o92MwtJKR9sfm/HkREzfyzNMiKPIQ7i7SZOxwEdiNCm4Svayn2DBq7MKEdrqPJUOSIpy1v6PpFlCQ0YA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script>
|
||||
const components = ['days', 'hours', 'minutes', 'seconds']
|
||||
// to test: const target = luxon.DateTime.now().plus(luxon.Duration.fromISO("PT10S"))
|
||||
const target = luxon.DateTime.utc(2023, 7, 14, 10, 0, 0)
|
||||
|
||||
const components = ['days', 'hours', 'minutes', 'seconds']
|
||||
function render() {
|
||||
let now = luxon.DateTime.now()
|
||||
let duration = now.diff(target, components)
|
||||
console.debug(duration.values)
|
||||
|
||||
function render() {
|
||||
let duration = luxon.DateTime.now().diff(luxon.DateTime.utc(2023, 7, 14, 10, 0, 0), components)
|
||||
console.log(duration.values)
|
||||
if (target < now) {
|
||||
console.log("COUNTDOWN: Target reached!")
|
||||
document.location = document.location.origin + "/adhesion"
|
||||
}
|
||||
|
||||
components.forEach(key => {
|
||||
document.getElementById(key).innerText = (-duration.values[key]).toString().split(".")[0].padStart(2, "0")
|
||||
|
||||
// test with random values
|
||||
// document.getElementById(key).innerText = (Math.floor(Math.random() * 99)).toString().split(".")[0].padStart(2, "0")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render()
|
||||
setInterval(() => {
|
||||
render()
|
||||
}, 1000)
|
||||
|
||||
setInterval(() => {
|
||||
render()
|
||||
}, 1000)
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
|
|
Loading…
Reference in a new issue