import GameCommon from '../common/GameCommon.js'; import Time from '../common/Time.js' const Upload = { name: 'upload', props: { accept: String, label: String, }, template: ` `, methods: { async upload(evt) { const file = evt.target.files[0] if (!file) return; const formData = new FormData(); formData.append('file', file, file.name); const res = await fetch('/upload', { method: 'post', body: formData, }) const j = await res.json() this.$emit('uploaded', j) }, } } const GameTeaser = { name: 'game-teaser', props: { game: Object, }, template: `
`, computed: { style() { const url = this.game.imageUrl.replace('uploads/', 'uploads/r/') + '-375x210.webp' return { 'background-image': `url("${url}")`, } }, }, methods: { time(start, end) { const icon = end ? '🏁' : '⏳' const from = start; const to = end || Time.timestamp() const timeDiffStr = Time.timeDiffStr(from, to) return `${icon} ${timeDiffStr}` }, }, } const ImageTeaser = { name: 'image-teaser', props: { image: Object }, template: ``, computed: { style() { const url = this.image.url.replace('uploads/', 'uploads/r/') + '-150x100.webp' return { 'background-image': `url("${url}")`, } }, }, methods: { onClick() { this.$emit('click') }, }, } export default { components: { Upload, GameTeaser, ImageTeaser, }, props: { gamesRunning: Array, gamesFinished: Array, images: Array, }, template: `|
|
|
|
|
|
| Start new game | |