From: Mischa POSLAWSKY Date: Thu, 30 Dec 2021 07:05:35 +0000 (+0100) Subject: word/memory: pick cards to fit grid dimensions X-Git-Tag: v1.13~55 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/a3c116952bbc2bfc1b77d8814637a36ed76883c3 word/memory: pick cards to fit grid dimensions --- diff --git a/word/memory.js b/word/memory.js index 94836c2..24feead 100644 --- a/word/memory.js +++ b/word/memory.js @@ -58,7 +58,11 @@ class WordMemory extends WordQuiz { let cards; if (this.words) { - cards = this.words.splice(0, 6).map(row => row[2]); + const formstyle = window.getComputedStyle(this.form) + const gridsize = [ + formstyle['grid-template-rows'], formstyle['grid-template-columns'] + ].map(val => val.match(/ /g).length + 1).reduce((x, y) => x * y) / 2; + cards = this.words.splice(0, gridsize || 6).map(row => row[2]); cards.push(...cards.map(val => -val)); } else {