From 356509a4fe376b3e85e937ea4562896d26cea393 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Mon, 19 Oct 2020 01:39:53 +1100 Subject: [PATCH] Reset candidate green background when reset in Wright STV --- html/index.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/html/index.js b/html/index.js index c84a18a..390d149 100644 --- a/html/index.js +++ b/html/index.js @@ -185,20 +185,25 @@ async function clickCount() { elTd = document.createElement('td'); elTd.classList.add('count'); - if (countCard.state === py.pyRCV2.model.CandidateState.WITHDRAWN) { - elTd.classList.add('excluded'); - elTd.innerText = 'WD'; - } else if (countCard.state === py.pyRCV2.model.CandidateState.ELECTED || countCard.state === py.pyRCV2.model.CandidateState.PROVISIONALLY_ELECTED) { + + if (countCard.state === py.pyRCV2.model.CandidateState.ELECTED || countCard.state === py.pyRCV2.model.CandidateState.PROVISIONALLY_ELECTED) { elTd.classList.add('elected'); elTd.innerText = countCard.votes; - elTr1.querySelector('td:first-child').classList.add('elected'); - } else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDED) { - elTd.classList.add('excluded'); - elTd.innerText = 'EX'; } else { - elTd.innerText = countCard.votes; + elTr1.querySelector('td:first-child').classList.remove('elected'); + + if (countCard.state === py.pyRCV2.model.CandidateState.WITHDRAWN) { + elTd.classList.add('excluded'); + elTd.innerText = 'WD'; + } else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDED) { + elTd.classList.add('excluded'); + elTd.innerText = 'EX'; + } else { + elTd.innerText = countCard.votes; + } } + elTr2.appendChild(elTd); }