4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
6 button.tabbtn#liveGames(@click="setDisplay('live',$event)") {{ st.tr["Live games"] }}
7 button.tabbtn#corrGames(@click="setDisplay('corr',$event)") {{ st.tr["Correspondance games"] }}
8 GameList(v-show="display=='live'" :games="liveGames"
10 GameList(v-show="display=='corr'" :games="corrGames"
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 this.liveGames = localGames;
37 if (this.st.user.id > 0) {
38 ajax("/games", "GET", { uid: this.st.user.id }, res => {
39 res.games.forEach(g => (g.type = this.classifyObject(g)));
40 this.corrGames = res.games;
45 const showType = localStorage.getItem("type-myGames") || "live";
46 this.setDisplay(showType);
49 setDisplay: function(type, e) {
51 localStorage.setItem("type-myGames", type);
52 let elt = e ? e.target : document.getElementById(type + "Games");
53 elt.classList.add("active");
54 if (elt.previousElementSibling)
55 elt.previousElementSibling.classList.remove("active");
56 else elt.nextElementSibling.classList.remove("active");
58 // TODO: classifyObject is redundant (see Hall.vue)
59 classifyObject: function(o) {
60 return o.cadence.indexOf("d") === -1 ? "live" : "corr";
62 showGame: function(g) {
63 this.$router.push("/game/" + g.id);
69 <style lang="sass" scoped>
74 background-color: #f9faee