4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
6 button(@click="display='live'") Live games
7 button(@click="display='corr'") Correspondance games
8 GameList(v-show="display=='live'" :games="filterGames('live')"
10 GameList(v-show="display=='corr'" :games="filterGames('corr')"
11 @show-game="showGame")
15 import { store } from "@/store";
16 import { GameStorage } from "@/utils/gameStorage";
17 import { ajax } from "@/utils/ajax";
18 import GameList from "@/components/GameList.vue";
33 GameStorage.getAll((localGames) => {
34 localGames.forEach((g) => g.type = this.classifyObject(g));
35 //Array.prototype.push.apply(this.games, localGames); /TODO: Vue3...
36 this.games = this.games.concat(localGames);
38 if (this.st.user.id > 0)
40 ajax("/games", "GET", {uid: this.st.user.id}, (res) => {
41 res.games.forEach((g) => g.type = this.classifyObject(g));
42 //Array.prototype.push.apply(this.games, res.games); //TODO: Vue 3
43 this.games = this.games.concat(res.games);
48 // TODO: classifyObject and filterGames are redundant (see Hall.vue)
49 classifyObject: function(o) {
50 return (o.timeControl.indexOf('d') === -1 ? "live" : "corr");
52 filterGames: function(type) {
53 return this.games.filter(g => g.type == type);
55 showGame: function(g) {
56 this.$router.push("/game/" + g.id);