6547865a567cbed9ff750ecf5c784ecb44ff7a7c
[vchess.git] / client / src / main.js
1 import Vue from "vue";
2 import App from "./App.vue";
3 import router from "./router";
4 // Global store: see https://medium.com/fullstackio/managing-state-in-vue-js-23a0352b1c87
5 import { store } from "./store";
6
7 Vue.config.productionTip = false;
8
9 new Vue({
10 router,
11 render: function(h) {
12 return h(App);
13 },
14 // watch: {
15 // $route: function(newRoute) {
16 // //console.log(this.$route.params);
17 // console.log("navig to " + newRoute);
18 // //TODO: conn.send("enter", newRoute)
19 // },
20 // },
21 created: function() {
22 window.doClick = (elemId) => { document.getElementById(elemId).click() };
23 store.initialize();
24
25 // TODO: AJAX call get corr games (all variants)
26 // si dernier lastMove sur serveur n'est pas le mien et nextColor == moi, alors background orange
27 // ==> background orange si à moi de jouer par corr (sur main index)
28 // (helper: static fonction "GetNextCol()" dans base_rules.js)
29
30 //TODO: si une partie en cours dans storage, rediriger vers cette partie
31 //(à condition que l'URL n'y corresponde pas déjà !)
32 // TODO: à l'arrivée sur le site : set peerID (un identifiant unique
33 // en tout cas...) si pas trouvé dans localStorage "myid"
34 // (l'identifiant de l'utilisateur si connecté)
35 // if (!!localStorage["variant"])
36 // location.hash = "#game?id=" + localStorage["gameId"];
37 },
38 }).$mount("#app");
39
40 // board2, 3, 4 automatiquement, mais rules separement (les 3 pour une)
41 // game : aussi systématique
42 // problems: on-demand
43 //
44 // See https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changes
45 // created: function() {
46 // window.onhashchange = this.setDisplay;
47 // },
48 //});