X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fmain.js;h=e68447ee2dafd410cab229e0c34e9f981a99972c;hb=98f3902b0f3c4370b07d534f5fcbca146a7a651d;hp=0b9b40230e848671d2150110417998770b50a65d;hpb=625022fdcf750f0aff8fcd699f7e9b89730e1d10;p=vchess.git diff --git a/client/src/main.js b/client/src/main.js index 0b9b4023..e68447ee 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -1,6 +1,7 @@ import Vue from "vue"; import App from "./App.vue"; import router from "./router"; +import params from "./parameters"; //for socket connection import { ajax } from "./utils/ajax"; Vue.config.productionTip = false; @@ -12,11 +13,24 @@ new Vue({ }, created: function() { //alert("test"); - ajax("http://localhost:3000/variants", "GET", variantArray => { - console.log("Got variants:"); - console.log(variantArray); + ajax("/variants", "GET", res => { + Vue.prototype.$variants = res.variantArray; }); + Vue.prototype.$conn = null; //TODO + const myid = localStorage["myid"] || util.getRandString(); + // NOTE: in this version, we don't say on which page we are, yet + // ==> we'll say "enter/leave" page XY (in fact juste "enter", seemingly) + Vue.prototype.$conn = new WebSocket(params.socketUrl + "/?sid=" + myid); + //TODO: si une partie en cours dans storage, rediriger vers cette partie + //(à condition que l'URL n'y corresponde pas déjà !) + // TODO: à l'arrivée sur le site : set peerID (un identifiant unique + // en tout cas...) si pas trouvé dans localStorage "myid" + // (l'identifiant de l'utilisateur si connecté) }, + // Later, for icons (if using feather): +// mounted: function() { +// feather.replace(); +// }, }).$mount("#app"); // TODO: get rules, dynamic import @@ -25,3 +39,15 @@ new Vue({ // const lang = selectLanguage(req, res); // res.render("rules/" + req.params["vname"] + "/" + lang); // }); +// +// board2, 3, 4 automatiquement, mais rules separement (les 3 pour une) +// game : aussi systématique +// problems: on-demand +// +// It works (to watch for route change), in a component: +//watch: { +// $route: function(newRoute) { +// console.log(this.$route.params); +// }, +//}, +// See https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changes