3 input#modalInfo.modal(type="checkbox")
6 data-checkbox="modalInfo"
9 label.modal-close(for="modalInfo")
10 p(v-html="infoMessage")
11 input#modalAccept.modal(type="checkbox")
12 div#acceptDiv(role="dialog")
15 span.variantName {{ curChallToAccept.vname }}
16 span {{ curChallToAccept.cadence }}
17 span {{ st.tr["with"] + " " + curChallToAccept.from.name }}
18 .diagram(v-html="tchallDiag")
19 .button-group#buttonsTchall
20 button.acceptBtn(@click="decisionChallenge(true)") {{ st.tr["Accept challenge?"] }}
21 button.refuseBtn(@click="decisionChallenge(false)") {{ st.tr["Refuse"] }}
22 input#modalNewgame.modal(
24 @change="cadenceFocusIfOpened($event)"
28 data-checkbox="modalNewgame"
31 label#closeNewgame.modal-close(for="modalNewgame")
32 div(@keyup.enter="newChallenge()")
34 label(for="selectVariant") {{ st.tr["Variant"] }} *
36 @change="loadNewchallVariant(trySetNewchallDiag)"
37 v-model="newchallenge.vid"
40 v-for="v in st.variants"
42 :selected="newchallenge.vid==v.id"
46 label(for="cadence") {{ st.tr["Cadence"] }} *
47 div#predefinedCadences
48 button(type="button") 15+5
49 button(type="button") 45+30
50 button(type="button") 3d
51 button(type="button") 7d
54 v-model="newchallenge.cadence"
55 placeholder="5+0, 1h+30s, 5d ..."
58 label(for="selectRandomLevel") {{ st.tr["Randomness"] }}
59 select#selectRandomLevel(v-model="newchallenge.randomness")
60 option(value="0") {{ st.tr["Deterministic"] }}
61 option(value="1") {{ st.tr["Symmetric random"] }}
62 option(value="2") {{ st.tr["Asymmetric random"] }}
63 fieldset(v-if="st.user.id > 0")
64 label(for="selectPlayers") {{ st.tr["Play with?"] }}
67 v-model="newchallenge.to"
69 fieldset(v-if="st.user.id > 0 && newchallenge.to.length > 0")
72 @input="trySetNewchallDiag()"
74 v-model="newchallenge.fen"
76 .diagram(v-html="newchallenge.diag")
77 button(@click="newChallenge()") {{ st.tr["Send challenge"] }}
78 input#modalPeople.modal(
80 @click="resetSocialColor()"
84 data-checkbox="modalPeople"
87 label.modal-close(for="modalPeople")
91 v-for="sid in Object.keys(people)"
92 v-if="people[sid].name"
94 span {{ people[sid].name }}
96 v-if="isGamer(sid) || (st.user.id > 0 && sid!=st.user.sid)"
97 @click="challOrWatch(sid)"
99 | {{ getActionLabel(sid) }}
100 p.anonymous @nonymous ({{ anonymousCount }})
104 @mychat="processChat"
109 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
111 button#peopleBtn(onClick="window.doClick('modalPeople')")
112 | {{ st.tr["Who's there?"] }}
113 button(onClick="window.doClick('modalNewgame')")
114 | {{ st.tr["New game"] }}
116 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
119 button.tabbtn#btnClive(@click="setDisplay('c','live',$event)")
120 | {{ st.tr["Live challenges"] }}
121 button.tabbtn#btnCcorr(@click="setDisplay('c','corr',$event)")
122 | {{ st.tr["Correspondance challenges"] }}
124 v-show="cdisplay=='live'"
125 :challenges="filterChallenges('live')"
126 @click-challenge="clickChallenge"
129 v-show="cdisplay=='corr'"
130 :challenges="filterChallenges('corr')"
131 @click-challenge="clickChallenge"
135 button.tabbtn#btnGlive(@click="setDisplay('g','live',$event)")
136 | {{ st.tr["Live games"] }}
137 button.tabbtn#btnGcorr(@click="setDisplay('g','corr',$event)")
138 | {{ st.tr["Correspondance games"] }}
140 v-show="gdisplay=='live'"
141 :games="filterGames('live')"
143 @show-game="showGame"
146 v-show="gdisplay=='corr'"
147 :games="filterGames('corr')"
149 @show-game="showGame"
154 import { store } from "@/store";
155 import { checkChallenge } from "@/data/challengeCheck";
156 import { ArrayFun } from "@/utils/array";
157 import { ajax } from "@/utils/ajax";
158 import params from "@/parameters";
159 import { getRandString, shuffle } from "@/utils/alea";
160 import { getDiagram } from "@/utils/printDiagram";
161 import Chat from "@/components/Chat.vue";
162 import GameList from "@/components/GameList.vue";
163 import ChallengeList from "@/components/ChallengeList.vue";
164 import { GameStorage } from "@/utils/gameStorage";
165 import { processModalClick } from "@/utils/modalClick";
176 cdisplay: "live", //or corr
184 vid: parseInt(localStorage.getItem("vid")) || 0,
185 to: "", //name of challenged player (if any)
186 cadence: localStorage.getItem("cadence") || "",
187 randomness: parseInt(localStorage.getItem("randomness")) || 2,
188 // VariantRules object, stored to not interfere with
189 // diagrams of targetted challenges:
192 diag: "" //visualizing FEN
195 curChallToAccept: {from: {}},
199 // Related to (killing of) self multi-connects:
205 // st.variants changes only once, at loading from [] to [...]
206 "st.variants": function() {
207 // Set potential challenges and games variant names:
208 this.challenges.concat(this.games).forEach(o => {
209 if (o.vname == "") o.vname = this.getVname(o.vid);
211 if (!this.newchallenge.V && this.newchallenge.vid > 0)
212 this.loadNewchallVariant();
216 anonymousCount: function() {
218 Object.values(this.people).forEach(p => {
219 // Do not cound people who did not send their identity yet:
220 count += (!p.name && p.id === 0) ? 1 : 0;
225 created: function() {
226 if (this.st.variants.length > 0 && this.newchallenge.vid > 0)
227 this.loadNewchallVariant();
228 const my = this.st.user;
229 this.$set(this.people, my.sid, { id: my.id, name: my.name, pages: ["/"] });
230 // Ask server for current corr games (all but mines)
234 { uid: this.st.user.id, excluded: true },
236 this.games = this.games.concat(
237 response.games.map(g => {
238 const type = this.classifyObject(g);
239 const vname = this.getVname(g.vid);
240 return Object.assign({}, g, { type: type, vname: vname });
245 // Also ask for corr challenges (open + sent by/to me)
246 ajax("/challenges", "GET", { uid: this.st.user.id }, response => {
247 // Gather all senders names, and then retrieve full identity:
248 // (TODO [perf]: some might be online...)
250 response.challenges.forEach(c => {
251 if (c.uid != this.st.user.id) names[c.uid] = "";
252 else if (!!c.target && c.target != this.st.user.id)
253 names[c.target] = "";
255 const addChallenges = () => {
256 names[this.st.user.id] = this.st.user.name; //in case of
257 this.challenges = this.challenges.concat(
258 response.challenges.map(c => {
259 const from = { name: names[c.uid], id: c.uid }; //or just name
260 const type = this.classifyObject(c);
261 const vname = this.getVname(c.vid);
262 return Object.assign(
268 to: c.target ? names[c.target] : ""
275 if (Object.keys(names).length > 0) {
279 { ids: Object.keys(names).join(",") },
281 response2.users.forEach(u => {
282 names[u.id] = u.name;
287 } else addChallenges();
289 const connectAndPoll = () => {
290 this.send("connect");
291 this.send("pollclientsandgamers");
293 // Initialize connection
294 this.connexionString =
301 encodeURIComponent(this.$route.path);
302 this.conn = new WebSocket(this.connexionString);
303 this.conn.onopen = connectAndPoll;
304 this.conn.onmessage = this.socketMessageListener;
305 this.conn.onclose = this.socketCloseListener;
307 mounted: function() {
308 ["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => {
309 let elt = document.getElementById(eltName);
310 elt.addEventListener("click", processModalClick);
312 document.querySelectorAll("#predefinedCadences > button").forEach(b => {
313 b.addEventListener("click", () => {
314 this.newchallenge.cadence = b.innerHTML;
317 const dispCorr = this.$route.query["disp"];
319 dispCorr || localStorage.getItem("type-challenges") || "live";
321 dispCorr || localStorage.getItem("type-games") || "live";
322 this.setDisplay("c", showCtype);
323 this.setDisplay("g", showGtype);
325 beforeDestroy: function() {
326 this.send("disconnect");
330 cadenceFocusIfOpened: function() {
331 if (event.target.checked)
332 document.getElementById("cadence").focus();
334 send: function(code, obj) {
336 this.conn.send(JSON.stringify(Object.assign({ code: code }, obj)));
339 getVname: function(vid) {
340 const variant = this.st.variants.find(v => v.id == vid);
341 // this.st.variants might be uninitialized (variant == null)
342 return variant ? variant.name : "";
344 filterChallenges: function(type) {
345 return this.challenges.filter(c => c.type == type);
347 filterGames: function(type) {
348 return this.games.filter(g => g.type == type);
350 classifyObject: function(o) {
352 return o.cadence.indexOf("d") === -1 ? "live" : "corr";
354 setDisplay: function(letter, type, e) {
355 this[letter + "display"] = type;
356 localStorage.setItem(
357 "type-" + (letter == "c" ? "challenges" : "games"),
362 : document.getElementById("btn" + letter.toUpperCase() + type);
363 elt.classList.add("active");
364 elt.classList.remove("somethingnew"); //in case of
365 if (elt.previousElementSibling)
366 elt.previousElementSibling.classList.remove("active");
367 else elt.nextElementSibling.classList.remove("active");
369 isGamer: function(sid) {
370 return this.people[sid].pages.some(p => p.indexOf("/game/") >= 0);
372 getActionLabel: function(sid) {
375 console.log(this.people[sid]);
378 return this.people[sid].pages.some(p => p == "/")
382 challOrWatch: function(sid) {
383 if (this.people[sid].pages.some(p => p == "/")) {
384 // Available, in Hall
385 this.newchallenge.to = this.people[sid].name;
386 document.getElementById("modalPeople").checked = false;
387 window.doClick("modalNewgame");
389 // In some game, maybe playing maybe not: show a random one
391 this.people[sid].pages.forEach(p => {
392 const matchGid = p.match(/[a-zA-Z0-9]+$/);
393 if (matchGid) gids.push(matchGid[0]);
395 const gid = gids[Math.floor(Math.random() * gids.length)];
396 const game = this.games.find(g => g.id == gid);
397 if (game) this.showGame(game);
398 else this.$router.push("/game/" + gid); //game vs. me
401 showGame: function(g) {
402 // NOTE: we are an observer, since only games I don't play are shown here
403 // ==> Moves sent by connected remote player(s) if live game
404 let url = "/game/" + g.id;
405 if (g.type == "live")
406 url += "?rid=" + g.rids[Math.floor(Math.random() * g.rids.length)];
407 this.$router.push(url);
409 resetSocialColor: function() {
410 // TODO: this is called twice, once on opening an once on closing
411 document.getElementById("peopleBtn").classList.remove("somethingnew");
413 processChat: function(chat) {
414 this.send("newchat", { data: chat });
417 socketMessageListener: function(msg) {
418 if (!this.conn) return;
419 const data = JSON.parse(msg.data);
421 case "pollclientsandgamers": {
422 // Since people can be both in Hall and Game,
423 // need to track "askIdentity" requests:
424 let identityAsked = {};
425 data.sockIds.forEach(s => {
426 const page = s.page || "/";
427 if (s.sid != this.st.user.sid && !identityAsked[s.sid]) {
428 this.send("askidentity", { target: s.sid, page: page });
429 identityAsked[s.sid] = true;
431 if (!this.people[s.sid])
432 // Do not set name or id: identity unknown yet
433 this.$set(this.people, s.sid, { pages: [page] });
434 else if (this.people[s.sid].pages.indexOf(page) < 0)
435 this.people[s.sid].pages.push(page);
438 this.send("askchallenge", { target: s.sid });
440 else this.send("askgame", { target: s.sid, page: page });
446 const page = data.page || "/";
447 // NOTE: player could have been polled earlier, but might have logged in then
448 // So it's a good idea to ask identity if he was anonymous.
449 // But only ask game / challenge if currently disconnected.
450 if (!this.people[data.from]) {
451 this.$set(this.people, data.from, { pages: [page] });
452 if (data.code == "connect")
453 this.send("askchallenge", { target: data.from });
454 else this.send("askgame", { target: data.from, page: page });
456 // Append page if not already in list
457 if (this.people[data.from].pages.indexOf(page) < 0)
458 this.people[data.from].pages.push(page);
460 if (!this.people[data.from].name && this.people[data.from].id !== 0) {
461 // Identity not known yet
462 this.newConnect[data.from] = true; //for self multi-connects tests
463 this.send("askidentity", { target: data.from, page: page });
468 case "gdisconnect": {
469 // If the user reloads the page twice very quickly (experienced with Firefox),
470 // the first reload won't have time to connect but will trigger a "close" event anyway.
471 // ==> Next check is required.
472 if (!this.people[data.from]) return;
473 // Disconnect means no more tmpIds:
474 if (data.code == "disconnect") {
475 // Remove the live challenge sent by this player:
476 ArrayFun.remove(this.challenges, c => c.from.sid == data.from);
478 // Remove the matching live game if now unreachable
479 const gid = data.page.match(/[a-zA-Z0-9]+$/)[0];
480 const gidx = this.games.findIndex(g => g.id == gid);
482 const game = this.games[gidx];
484 game.type == "live" &&
485 game.rids.length == 1 &&
486 game.rids[0] == data.from
488 this.games.splice(gidx, 1);
492 const page = data.page || "/";
493 ArrayFun.remove(this.people[data.from].pages, p => p == page);
494 if (this.people[data.from].pages.length == 0)
495 this.$delete(this.people, data.from);
499 // I logged in elsewhere:
501 alert(this.st.tr["New connexion detected: tab now offline"]);
503 case "askidentity": {
504 // Request for identification (TODO: anonymous shouldn't need to reply)
506 // Decompose to avoid revealing email
507 name: this.st.user.name,
508 sid: this.st.user.sid,
511 this.send("identity", { data: me, target: data.from });
515 const user = data.data;
516 this.$set(this.people, user.sid, {
519 pages: this.people[user.sid].pages
522 // If I multi-connect, kill current connexion if no mark (I'm older)
524 this.newConnect[user.sid] &&
526 user.id == this.st.user.id &&
527 user.sid != this.st.user.sid
529 if (!this.killed[this.st.user.sid]) {
530 this.send("killme", { sid: this.st.user.sid });
531 this.killed[this.st.user.sid] = true;
535 delete this.newConnect[user.sid];
538 case "askchallenge": {
539 // Send my current live challenge (if any)
540 const cIdx = this.challenges.findIndex(
541 c => c.from.sid == this.st.user.sid && c.type == "live"
544 const c = this.challenges[cIdx];
545 // NOTE: in principle, should only send targeted challenge to the target.
546 // But we may not know yet the identity of the target (just name),
547 // so cannot decide if data.from is the target or not.
548 const myChallenge = {
550 from: this.st.user.sid,
552 randomness: c.randomness,
558 this.send("challenge", { data: myChallenge, target: data.from });
562 case "challenge": //after "askchallenge"
563 case "newchallenge": {
564 // NOTE about next condition: see "askchallenge" case.
565 const chall = data.data;
568 (this.people[chall.from].id > 0 &&
569 (chall.from == this.st.user.sid || chall.to == this.st.user.name))
571 let newChall = Object.assign({}, chall);
572 newChall.type = this.classifyObject(chall);
573 newChall.randomness = chall.randomness;
574 newChall.added = Date.now();
575 let fromValues = Object.assign({}, this.people[chall.from]);
576 delete fromValues["pages"]; //irrelevant in this context
577 newChall.from = Object.assign({ sid: chall.from }, fromValues);
578 newChall.vname = this.getVname(newChall.vid);
579 this.challenges.push(newChall);
581 (newChall.type == "live" && this.cdisplay == "corr") ||
582 (newChall.type == "corr" && this.cdisplay == "live")
585 .getElementById("btnC" + newChall.type)
586 .classList.add("somethingnew");
591 case "refusechallenge": {
592 const cid = data.data;
593 ArrayFun.remove(this.challenges, c => c.id == cid);
594 alert(this.st.tr["Challenge declined"]);
597 case "deletechallenge": {
598 // NOTE: the challenge may be already removed
599 const cid = data.data;
600 ArrayFun.remove(this.challenges, c => c.id == cid);
603 case "game": //individual request
605 // NOTE: it may be live or correspondance
606 const game = data.data;
607 // Ignore games where I play (corr games)
608 if (game.players.every(p =>
609 p.sid != this.st.user.sid || p.id != this.st.user.id))
611 let locGame = this.games.find(g => g.id == game.id);
614 newGame.type = this.classifyObject(game);
615 newGame.vname = this.getVname(game.vid);
617 //if new game from Hall
619 newGame.rids = [game.rid];
620 delete newGame["rid"];
621 this.games.push(newGame);
623 (newGame.type == "live" && this.gdisplay == "corr") ||
624 (newGame.type == "corr" && this.gdisplay == "live")
627 .getElementById("btnG" + newGame.type)
628 .classList.add("somethingnew");
631 // Append rid (if not already in list)
632 if (!locGame.rids.includes(game.rid)) locGame.rids.push(game.rid);
638 let g = this.games.find(g => g.id == data.gid);
639 if (g) g.score = data.score;
643 // New game just started: data contain all information
644 const gameInfo = data.data;
645 if (this.classifyObject(gameInfo) == "live")
646 this.startNewGame(gameInfo);
649 this.st.tr["New correspondance game:"] +
650 " <a href='#/game/" +
656 let modalBox = document.getElementById("modalInfo");
657 modalBox.checked = true;
662 this.newChat = data.data;
663 if (!document.getElementById("modalPeople").checked)
664 document.getElementById("peopleBtn").classList.add("somethingnew");
668 socketCloseListener: function() {
669 if (!this.conn) return;
670 this.conn = new WebSocket(this.connexionString);
671 this.conn.addEventListener("message", this.socketMessageListener);
672 this.conn.addEventListener("close", this.socketCloseListener);
674 // Challenge lifecycle:
675 loadNewchallVariant: async function(cb) {
676 const vname = this.getVname(this.newchallenge.vid);
677 const vModule = await import("@/variants/" + vname + ".js");
678 this.newchallenge.V = vModule.VariantRules;
679 this.newchallenge.vname = vname;
683 trySetNewchallDiag: function() {
684 if (!this.newchallenge.fen) {
685 this.newchallenge.diag = "";
688 // If vid > 0 then the variant is loaded (function above):
689 window.V = this.newchallenge.V;
691 this.newchallenge.vid > 0 &&
692 this.newchallenge.fen &&
693 V.IsGoodFen(this.newchallenge.fen)
695 const parsedFen = V.ParseFen(this.newchallenge.fen);
696 this.newchallenge.diag = getDiagram({
697 position: parsedFen.position,
698 orientation: V.GetOppCol(parsedFen.turn)
702 newChallenge: async function() {
703 if (this.newchallenge.cadence.match(/^[0-9]+$/))
704 this.newchallenge.cadence += "+0"; //assume minutes, no increment
705 const ctype = this.classifyObject(this.newchallenge);
706 // TODO: cadence still unchecked so ctype could be wrong...
708 if (!this.newchallenge.vid)
709 error = this.st.tr["Please select a variant"];
710 else if (ctype == "corr" && this.st.user.id <= 0)
711 error = this.st.tr["Please log in to play correspondance games"];
712 else if (this.newchallenge.to) {
713 if (this.newchallenge.to == this.st.user.name)
714 error = this.st.tr["Self-challenge is forbidden"];
717 Object.values(this.people).every(p => p.name != this.newchallenge.to)
719 error = this.newchallenge.to + " " + this.st.tr["is not online"];
725 window.V = this.newchallenge.V;
726 error = checkChallenge(this.newchallenge);
731 // NOTE: "from" information is not required here
732 let chall = Object.assign({}, this.newchallenge);
734 delete chall["diag"];
735 const finishAddChallenge = cid => {
736 chall.id = cid || "c" + getRandString();
737 // Remove old challenge if any (only one at a time of a given type):
738 const cIdx = this.challenges.findIndex(
740 (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id) &&
744 // Delete current challenge (will be replaced now)
745 this.send("deletechallenge", { data: this.challenges[cIdx].id });
746 if (ctype == "corr") {
747 ajax("/challenges", "DELETE", { id: this.challenges[cIdx].id });
749 this.challenges.splice(cIdx, 1);
751 this.send("newchallenge", {
752 data: Object.assign({ from: this.st.user.sid }, chall)
754 // Add new challenge:
756 // Decompose to avoid revealing email
757 sid: this.st.user.sid,
759 name: this.st.user.name
761 chall.added = Date.now();
762 // NOTE: vname and type are redundant (can be deduced from cadence + vid)
764 chall.vname = this.newchallenge.vname;
765 this.challenges.push(chall);
766 // Remember cadence + vid for quicker further challenges:
767 localStorage.setItem("cadence", chall.cadence);
768 localStorage.setItem("vid", chall.vid);
769 localStorage.setItem("randomness", chall.randomness);
770 document.getElementById("modalNewgame").checked = false;
771 // Show the challenge if not on current display
773 (ctype == "live" && this.cdisplay == "corr") ||
774 (ctype == "corr" && this.cdisplay == "live")
776 this.setDisplay('c', ctype);
779 if (ctype == "live") {
780 // Live challenges have a random ID
781 finishAddChallenge(null);
783 // Correspondance game: send challenge to server
784 ajax("/challenges", "POST", { chall: chall }, response => {
785 finishAddChallenge(response.cid);
789 // Callback function after a diagram was showed to accept
790 // or refuse targetted challenge:
791 decisionChallenge: function(accepted) {
792 this.curChallToAccept.accepted = accepted;
793 this.finishProcessingChallenge(this.curChallToAccept);
794 document.getElementById("modalAccept").checked = false;
796 finishProcessingChallenge: function(c) {
799 // Again, avoid c.seat = st.user to not reveal email
800 sid: this.st.user.sid,
802 name: this.st.user.name
806 this.send("refusechallenge", { data: c.id, target: c.from.sid });
808 this.send("deletechallenge", { data: c.id });
810 clickChallenge: async function(c) {
812 c.from.sid == this.st.user.sid || //live
813 (this.st.user.id > 0 && c.from.id == this.st.user.id); //corr
815 if (c.type == "corr" && this.st.user.id <= 0) {
816 alert(this.st.tr["Please log in to accept corr challenges"]);
820 const vModule = await import("@/variants/" + c.vname + ".js");
821 window.V = vModule.VariantRules;
823 // c.to == this.st.user.name (connected)
825 const parsedFen = V.ParseFen(c.fen);
826 c.mycolor = V.GetOppCol(parsedFen.turn);
827 this.tchallDiag = getDiagram({
828 position: parsedFen.position,
829 orientation: c.mycolor
831 this.curChallToAccept = c;
832 document.getElementById("modalAccept").checked = true;
835 if (!confirm(this.st.tr["Accept challenge?"]))
837 this.finishProcessingChallenge(c);
841 this.finishProcessingChallenge(c);
845 if (c.type == "corr") {
846 ajax("/challenges", "DELETE", { id: c.id });
848 this.send("deletechallenge", { data: c.id });
850 // In all cases, the challenge is consumed:
851 ArrayFun.remove(this.challenges, ch => ch.id == c.id);
853 // NOTE: when launching game, the challenge is already being deleted
854 launchGame: function(c) {
855 // These game informations will be shared
858 fen: c.fen || V.GenRandInitFen(c.randomness),
859 // White player index 0, black player index 1:
861 ? (c.mycolor == "w" ? [c.seat, c.from] : [c.from, c.seat])
862 : shuffle([c.from, c.seat]),
866 let oppsid = c.from.sid; //may not be defined if corr + offline opp
868 oppsid = Object.keys(this.people).find(
869 sid => this.people[sid].id == c.from.id
872 const notifyNewgame = () => {
875 this.send("startgame", { data: gameInfo, target: oppsid });
876 // Send game info (only if live) to everyone except me in this tab
877 this.send("newgame", { data: gameInfo });
879 if (c.type == "live") {
881 this.startNewGame(gameInfo);
882 } //corr: game only on server
887 { gameInfo: gameInfo, cid: c.id }, //cid useful to delete challenge
889 gameInfo.id = response.gameId;
891 this.$router.push("/game/" + response.gameId);
896 // NOTE: for live games only (corr games start on the server)
897 startNewGame: function(gameInfo) {
898 const game = Object.assign({}, gameInfo, {
899 // (other) Game infos: constant
900 fenStart: gameInfo.fen,
901 vname: this.getVname(gameInfo.vid),
903 // Game state (including FEN): will be updated
905 clocks: [-1, -1], //-1 = unstarted
906 initime: [0, 0], //initialized later
909 GameStorage.add(game, (err) => {
910 // If an error occurred, game is not added: abort
912 if (this.st.settings.sound)
913 new Audio("/sounds/newgame.flac").play().catch(() => {});
914 this.$router.push("/game/" + gameInfo.id);
922 <style lang="sass" scoped>
930 #newgameDiv > .card, #acceptDiv > .card
934 div#peopleWrap > .card
937 @media screen and (min-width: 1281px)
938 div#peopleWrap > .card
941 @media screen and (max-width: 1280px)
942 div#peopleWrap > .card
945 @media screen and (max-width: 767px)
946 div#peopleWrap > .card
959 @media screen and (max-width: 767px)
978 background-color: #c5fefe !important
981 background-color: #f9faee
984 background-color: lightgreen
986 background-color: red
1003 @media screen and (max-width: 767px)