From: Benjamin Auder Date: Fri, 31 May 2019 08:21:53 +0000 (+0200) Subject: Small fixes X-Git-Url: https://git.auder.net/doc/html/scripts/current/pieces/cn.svg?a=commitdiff_plain;h=e64c6f67185b45b3b1205069532362c1bf9680db;p=vchess.git Small fixes --- diff --git a/client/src/components/ChallengeList.vue b/client/src/components/ChallengeList.vue index 85005157..c7df2dde 100644 --- a/client/src/components/ChallengeList.vue +++ b/client/src/components/ChallengeList.vue @@ -10,7 +10,7 @@ table td {{ c.from.name }} td(v-if="!!c.to[0]") span(v-for="pname in c.to") {{ pname }} - td(v-else) {{ c.to.length - 1 }} player{{ c.to.length >= 3 ? 's' : '' }} + td(v-else) {{ c.to.length }} player{{ c.to.length >= 2 ? 's' : '' }} td {{ c.timeControl }} diff --git a/client/src/utils/ajax.js b/client/src/utils/ajax.js index c0ebbffc..01ea8493 100644 --- a/client/src/utils/ajax.js +++ b/client/src/utils/ajax.js @@ -1,5 +1,8 @@ import params from "../parameters"; //for server URL +// TODO: replace by fetch API ? +// https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/ + // From JSON (encoded string values!) to "arg1=...&arg2=..." function toQueryString(data) { diff --git a/client/src/utils/timeControl.js b/client/src/utils/timeControl.js index 89f7f31d..194deaf6 100644 --- a/client/src/utils/timeControl.js +++ b/client/src/utils/timeControl.js @@ -22,8 +22,11 @@ function isLargerUnit(unit1, unit2) export function extractTime(timeControl) { - const tcParts = timeControl.replace(/ /g,"").split('+'); - const mainTimeArray = tcParts[0].match(/([0-9]+)([smhd])/); + let tcParts = timeControl.replace(/ /g,"").split('+'); + // Concatenate usual time control suffixes, in case of none is provided + tcParts[0] += "m"; + tcParts[1] += "s"; + const mainTimeArray = tcParts[0].match(/([0-9]+)([smhd]+)/); if (!mainTimeArray) return null; const mainTimeValue = parseInt(mainTimeArray[1]); @@ -32,7 +35,7 @@ export function extractTime(timeControl) let increment = 0; if (tcParts.length >= 2) { - const incrementArray = tcParts[1].match(/([0-9]+)([smhd])/); + const incrementArray = tcParts[1].match(/([0-9]+)([smhd]+)/); if (!incrementArray) return null; const incrementValue = parseInt(incrementArray[1]); diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 94e49a11..e76139a1 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -81,6 +81,7 @@ import { ajax } from "@/utils/ajax"; import { getRandString } from "@/utils/alea"; import GameList from "@/components/GameList.vue"; import ChallengeList from "@/components/ChallengeList.vue"; +import { GameStorage } from "@/utils/storage"; export default { name: "my-hall", components: {