Additional pretty-print tidying

This commit is contained in:
RunasSudo 2021-01-03 02:10:36 +11:00
parent 891f82e148
commit 6d3e283d1d
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 15 additions and 27 deletions

View File

@ -223,11 +223,7 @@ async function clickCount() {
elTd.classList.add('elected');
}
elTd.style.borderTop = '1px solid black';
if (countCard.transfers != '0.00') {
elTd.innerText = ppVotes(countCard.transfers);
} else {
elTd.innerHTML = ' ';
}
elTd.innerHTML = ppVotes(countCard.transfers);
elTr1.appendChild(elTd);
elTd = document.createElement('td');
@ -235,7 +231,7 @@ async function clickCount() {
if (countCard.state === py.pyRCV2.model.CandidateState.ELECTED || countCard.state === py.pyRCV2.model.CandidateState.PROVISIONALLY_ELECTED || countCard.state === py.pyRCV2.model.CandidateState.DISTRIBUTING_SURPLUS) {
elTd.classList.add('elected');
elTd.innerText = ppVotes(countCard.votes);
elTd.innerHTML = ppVotes(countCard.votes);
elTr1.querySelector('td:first-child').classList.add('elected');
} else {
elTr1.querySelector('td:first-child').classList.remove('elected');
@ -248,9 +244,9 @@ async function clickCount() {
elTd.innerText = 'Ex';
} else if (countCard.state === py.pyRCV2.model.CandidateState.EXCLUDING) {
elTd.classList.add('excluded');
elTd.innerText = ppVotes(countCard.votes);
elTd.innerHTML = ppVotes(countCard.votes);
} else {
elTd.innerText = ppVotes(countCard.votes);
elTd.innerHTML = ppVotes(countCard.votes);
}
}
@ -261,43 +257,31 @@ async function clickCount() {
elTd = document.createElement('td');
elTd.classList.add('count');
elTd.style.borderTop = '1px solid black';
if (result.exhausted.transfers != '0.00') {
elTd.innerText = ppVotes(result.exhausted.transfers);
} else {
elTd.innerHTML = ' ';
}
elTd.innerHTML = ppVotes(result.exhausted.transfers);
elExhausted1.appendChild(elTd);
elTd = document.createElement('td');
elTd.classList.add('count');
elTd.innerText = ppVotes(result.exhausted.votes);
elTd.innerHTML = ppVotes(result.exhausted.votes);
elExhausted2.appendChild(elTd);
// Display loss to fraction
elTd = document.createElement('td');
elTd.classList.add('count');
elTd.style.borderTop = '1px solid black';
if (result.loss_fraction.transfers != '0.00' && result.loss_fraction.transfers != '-0.00') {
elTd.innerText = ppVotes(result.loss_fraction.transfers);
} else {
elTd.innerHTML = ' ';
}
elTd.innerHTML = ppVotes(result.loss_fraction.transfers);
elLTF1.appendChild(elTd);
elTd = document.createElement('td');
elTd.classList.add('count');
if (result.loss_fraction.votes == '-0.00') {
elTd.innerText = ppVotes('0.00');
} else {
elTd.innerText = ppVotes(result.loss_fraction.votes);
}
elTd.innerHTML = ppVotes(result.loss_fraction.votes);
elLTF2.appendChild(elTd);
// Display total
elTd = document.createElement('td');
elTd.classList.add('count');
elTd.style.borderTop = '1px solid black';
elTd.innerText = ppVotes(result.total);
elTd.innerHTML = ppVotes(result.total);
elTotal.appendChild(elTd);
// Display quota
@ -305,7 +289,7 @@ async function clickCount() {
elTd.classList.add('count');
elTd.style.borderTop = '1px solid black';
elTd.style.borderBottom = '1px solid black';
elTd.innerText = ppVotes(result.quota);
elTd.innerHTML = ppVotes(result.quota);
elQuota.appendChild(elTd);
}
}
@ -354,7 +338,11 @@ async function clickCount() {
}
}
function ppVotes(v) {
return parseFloat(v).toFixed(ppDPs);
result = parseFloat(v).toFixed(ppDPs);
if (parseFloat(result) == 0) {
return ' '
}
return result;
}
}