From c34a2b5b05919829efff2ae3e6d6a4a5051dace4 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 23 Dec 2022 22:23:01 +0100 Subject: put colors into array --- index.html | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index 4ac437c..0d169ec 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ let cursor_column = 1; let puzzle = ''; const cell_style = 'text-align: center; vertical-align: middle; width:2em; border: 1px'; + const colors = ['#ffffff','#ffff80','#80ff80']; createPuzzle = function() { var request = new XMLHttpRequest(); request.onreadystatechange = function() { @@ -123,23 +124,10 @@ return; } for (i=1; i<=5; i++) { - switch (response.colors[i-1]) { - case 0: - color = '#ffffff'; - break; - case 1: - color = '#ffff80'; - break; - case 2: - color = '#80ff80'; - break; - default: - color = '#ff80ff'; - } table .querySelector("#row_" + row_count) .querySelector("#column_" + i) - .setAttribute('bgcolor', color); + .setAttribute('bgcolor', colors[response.colors[i-1]]); } addNewRow(); } -- cgit v1.2.3-54-g00ecf