summaryrefslogtreecommitdiff
path: root/src/server/web/app/mobile/views/pages/othello.vue
blob: b110bf309e9fd6f48dd7cab8595a996012bfed5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
<mk-ui>
	<span slot="header">%fa:gamepad%オセロ</span>
	<mk-othello v-if="!fetching" :init-game="game" @gamed="onGamed"/>
</mk-ui>
</template>

<script lang="ts">
import Vue from 'vue';
import Progress from '../../../common/scripts/loading';

export default Vue.extend({
	data() {
		return {
			fetching: false,
			game: null
		};
	},
	watch: {
		$route: 'fetch'
	},
	created() {
		this.fetch();
	},
	mounted() {
		document.title = 'Misskey オセロ';
		document.documentElement.style.background = '#fff';
	},
	methods: {
		fetch() {
			if (this.$route.params.game == null) return;

			Progress.start();
			this.fetching = true;

			(this as any).api('othello/games/show', {
				game_id: this.$route.params.game
			}).then(game => {
				this.game = game;
				this.fetching = false;

				Progress.done();
			});
		},
		onGamed(game) {
			history.pushState(null, null, '/othello/' + game.id);
		}
	}
});
</script>