summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2024-05-13 16:31:27 +0200
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2024-05-13 16:31:27 +0200
commitb85e8f9ad08399e22445248ffe8703e6de7fe5a2 (patch)
tree65ec535e53fcc725d45dd7d4e7e65e3447655b1c
parent823d71519cd776ece9e89729774e4132fbcd6fe0 (diff)
downloadvotes-for-women-master.tar.gz
grow cubes array dynamicallyHEADmaster
-rw-r--r--play.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/play.js b/play.js
index bb80de7..623720c 100644
--- a/play.js
+++ b/play.js
@@ -503,13 +503,6 @@ function build_user_interface() {
create_campaigner('red2', 6),
]
- for (let i = 0; i < 190; ++i) {
- elt = ui.cubes[i] = create("div", {
- className: `piece cube`,
- onmousedown: on_click_cube,
- })
- }
-
for (let i = 0; i < green_check_count; ++i) {
elt = ui.green_checks[i] = create("div", {
className: `piece yes`,
@@ -826,6 +819,12 @@ function on_update() { // eslint-disable-line no-unused-vars
function place_cubes(state_cubes, us_state, count, color) {
let others = colors.filter(c => c !== color)
for (let c = 0; c < count; ++c) {
+ if (cube_idx >= ui.cubes.length) {
+ ui.cubes[cube_idx] = create("div", {
+ className: `piece cube`,
+ onmousedown: on_click_cube,
+ })
+ }
e = ui.cubes[cube_idx++]
e.my_us_state = us_state
e.my_cube_color = color