2021-05-09 13:49:40 +02:00
|
|
|
"use strict"
|
|
|
|
|
|
2021-05-01 08:42:39 +02:00
|
|
|
import Time from './../../common/Time.js'
|
|
|
|
|
import GameTeaser from './../components/GameTeaser.vue.js'
|
2021-04-21 08:39:43 +02:00
|
|
|
|
2020-11-25 22:03:35 +01:00
|
|
|
export default {
|
|
|
|
|
components: {
|
2021-04-20 20:52:31 +02:00
|
|
|
GameTeaser,
|
2020-11-25 22:03:35 +01:00
|
|
|
},
|
|
|
|
|
template: `
|
2021-05-13 16:58:21 +02:00
|
|
|
<div>
|
|
|
|
|
<h1>Running games</h1>
|
|
|
|
|
<div class="game-teaser-wrap" v-for="g in gamesRunning">
|
|
|
|
|
<game-teaser :game="g" />
|
|
|
|
|
</div>
|
2020-11-25 22:03:35 +01:00
|
|
|
|
2021-05-13 16:58:21 +02:00
|
|
|
<h1>Finished games</h1>
|
|
|
|
|
<div class="game-teaser-wrap" v-for="g in gamesFinished">
|
|
|
|
|
<game-teaser :game="g" />
|
2020-11-25 22:03:35 +01:00
|
|
|
</div>
|
|
|
|
|
</div>`,
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-05-01 08:51:52 +02:00
|
|
|
gamesRunning: [],
|
|
|
|
|
gamesFinished: [],
|
2020-11-08 12:56:54 +01:00
|
|
|
}
|
2020-11-25 22:03:35 +01:00
|
|
|
},
|
2021-05-01 08:51:52 +02:00
|
|
|
async created() {
|
|
|
|
|
const res = await fetch('/api/index-data')
|
|
|
|
|
const json = await res.json()
|
|
|
|
|
this.gamesRunning = json.gamesRunning
|
|
|
|
|
this.gamesFinished = json.gamesFinished
|
|
|
|
|
},
|
2020-11-25 22:03:35 +01:00
|
|
|
methods: {
|
2020-12-06 21:55:23 +01:00
|
|
|
time(start, end) {
|
|
|
|
|
const icon = end ? '🏁' : '⏳'
|
|
|
|
|
const from = start;
|
2021-04-14 19:30:45 +02:00
|
|
|
const to = end || Time.timestamp()
|
|
|
|
|
const timeDiffStr = Time.timeDiffStr(from, to)
|
|
|
|
|
return `${icon} ${timeDiffStr}`
|
2020-12-06 21:55:23 +01:00
|
|
|
},
|
2020-11-07 11:35:29 +01:00
|
|
|
}
|
|
|
|
|
}
|