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)")
7 | {{ st.tr["Live games"] }}
8 button.tabbtn#corrGames(@click="setDisplay('corr',$event)")
9 | {{ st.tr["Correspondance games"] }}
11 v-show="display=='live'"
16 v-show="display=='corr'"
23 import { store } from "@/store";
24 import { GameStorage } from "@/utils/gameStorage";
25 import { ajax } from "@/utils/ajax";
26 import GameList from "@/components/GameList.vue";
41 GameStorage.getAll(localGames => {
42 localGames.forEach(g => (g.type = this.classifyObject(g)));
43 this.liveGames = localGames;
45 if (this.st.user.id > 0) {
46 ajax("/games", "GET", { uid: this.st.user.id }, res => {
47 res.games.forEach(g => (g.type = this.classifyObject(g)));
48 this.corrGames = res.games;
53 const showType = localStorage.getItem("type-myGames") || "live";
54 this.setDisplay(showType);
57 setDisplay: function(type, e) {
59 localStorage.setItem("type-myGames", type);
60 let elt = e ? e.target : document.getElementById(type + "Games");
61 elt.classList.add("active");
62 if (elt.previousElementSibling)
63 elt.previousElementSibling.classList.remove("active");
64 else elt.nextElementSibling.classList.remove("active");
66 // TODO: classifyObject is redundant (see Hall.vue)
67 classifyObject: function(o) {
68 return o.cadence.indexOf("d") === -1 ? "live" : "corr";
70 showGame: function(g) {
71 this.$router.push("/game/" + g.id);
77 <style lang="sass" scoped>
82 background-color: #f9faee