2021-06-02 21:37:47 +10:00
|
|
|
/* OpenTally: Open-source election vote counting
|
|
|
|
* Copyright © 2021 Lee Yingtong Li (RunasSudo)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function clickAdvancedOptions() {
|
|
|
|
if (document.getElementById('divAdvancedOptions').style.display === 'none') {
|
|
|
|
document.getElementById('divAdvancedOptions').style.display = 'grid';
|
|
|
|
document.getElementById('btnAdvancedOptions').innerHTML = 'Hide advanced options';
|
|
|
|
} else {
|
|
|
|
document.getElementById('divAdvancedOptions').style.display = 'none';
|
|
|
|
document.getElementById('btnAdvancedOptions').innerHTML = 'Show advanced options';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-02 22:46:36 +10:00
|
|
|
var tblResult = document.getElementById('result');
|
2021-06-03 15:47:19 +10:00
|
|
|
var divLogs2 = document.getElementById('resultLogs2');
|
|
|
|
var olStageComments;
|
2021-06-02 22:46:36 +10:00
|
|
|
|
2021-09-11 21:08:36 +10:00
|
|
|
var detailedTransfers = {};
|
|
|
|
|
2021-09-04 02:26:30 +10:00
|
|
|
var worker = new Worker('worker.js?v=GITVERSION');
|
2021-06-02 22:46:36 +10:00
|
|
|
|
2021-06-04 15:01:53 +10:00
|
|
|
worker.onmessage = function(evt) {
|
|
|
|
if (evt.data.type === 'init') {
|
|
|
|
document.getElementById('spanRevNum').innerText = evt.data.version;
|
|
|
|
document.getElementById('divLoading').style.display = 'none';
|
|
|
|
document.getElementById('divUI').style.display = 'block';
|
|
|
|
|
2021-07-20 13:41:38 +10:00
|
|
|
// Init dropdowns
|
|
|
|
// Can't compute correct width until #divUI, etc. is display: block
|
|
|
|
//document.getElementById('divAdvancedOptions').style.display = 'grid';
|
|
|
|
//for (let elSel of document.querySelectorAll('select')) {
|
|
|
|
let elSel = document.getElementById('selPreset'); {
|
|
|
|
var sel = new CustomSelect({elem: elSel});
|
|
|
|
sel.open();
|
|
|
|
document.getElementById('custom-' + elSel.id).style.width = (document.getElementById('custom-' + elSel.id).querySelector('.js-Dropdown-list').clientWidth + 32) + 'px';
|
|
|
|
sel.close();
|
|
|
|
}
|
|
|
|
//document.getElementById('divAdvancedOptions').style.display = 'none';
|
2021-06-04 15:01:53 +10:00
|
|
|
} else if (evt.data.type === 'initResultsTable') {
|
|
|
|
tblResult.innerHTML = evt.data.content;
|
|
|
|
divLogs2.innerHTML = '<p>Stage comments:</p>';
|
|
|
|
olStageComments = document.createElement('ol');
|
|
|
|
divLogs2.append(olStageComments);
|
|
|
|
|
|
|
|
} else if (evt.data.type === 'describeCount') {
|
|
|
|
document.getElementById('resultLogs1').innerHTML = evt.data.content;
|
|
|
|
|
|
|
|
} else if (evt.data.type === 'updateResultsTable') {
|
2021-08-16 18:48:49 +10:00
|
|
|
for (let row = 0; row < evt.data.result.length; row++) {
|
|
|
|
if (evt.data.result[row]) {
|
|
|
|
tblResult.rows[row].insertAdjacentHTML('beforeend', evt.data.result[row]);
|
2021-06-05 23:29:31 +10:00
|
|
|
|
|
|
|
// Update candidate status
|
2021-08-16 18:48:49 +10:00
|
|
|
if (
|
|
|
|
(document.getElementById('selReport').value == 'votes' && row >= 3 && row % 2 == 1) ||
|
|
|
|
(document.getElementById('selReport').value == 'ballots_votes' && row >= 4 && row % 2 == 0)
|
|
|
|
) {
|
|
|
|
if (tblResult.rows[row].lastElementChild.classList.contains('elected')) {
|
|
|
|
tblResult.rows[row].cells[0].classList.add('elected');
|
2021-06-05 23:29:31 +10:00
|
|
|
} else {
|
2021-08-16 18:48:49 +10:00
|
|
|
tblResult.rows[row].cells[0].classList.remove('elected');
|
2021-06-05 23:29:31 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-04 15:01:53 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (evt.data.type === 'updateStageComments') {
|
|
|
|
let elLi = document.createElement('li');
|
2021-09-11 21:08:36 +10:00
|
|
|
elLi.id = 'stage' + evt.data.stageNum;
|
2021-06-04 15:01:53 +10:00
|
|
|
elLi.innerHTML = evt.data.comment;
|
|
|
|
olStageComments.append(elLi);
|
|
|
|
|
2021-09-11 21:08:36 +10:00
|
|
|
} else if (evt.data.type === 'updateDetailedTransfers') {
|
|
|
|
detailedTransfers[evt.data.stageNum] = evt.data.table;
|
|
|
|
|
2021-06-04 15:01:53 +10:00
|
|
|
} else if (evt.data.type === 'finalResultSummary') {
|
|
|
|
divLogs2.insertAdjacentHTML('beforeend', evt.data.summary);
|
2021-06-06 17:31:20 +10:00
|
|
|
document.getElementById('printPane').style.display = 'block';
|
2021-06-12 02:09:26 +10:00
|
|
|
|
2021-07-23 00:04:43 +10:00
|
|
|
// Linkify stage numbers
|
|
|
|
document.querySelectorAll('tr.stage-no a').forEach(function(elA) {
|
|
|
|
elA.onclick = function() {
|
|
|
|
olStageComments.childNodes.forEach(function(elLi) { elLi.classList.remove('highlight'); });
|
|
|
|
document.getElementById(elA.href.substring(elA.href.indexOf('#') + 1)).classList.add('highlight');
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2021-06-12 02:09:26 +10:00
|
|
|
} else if (evt.data.type === 'requireInput') {
|
|
|
|
let response = window.prompt(evt.data.message);
|
|
|
|
while (response === null) {
|
|
|
|
response = window.prompt(evt.data.message);
|
|
|
|
}
|
|
|
|
worker.postMessage({'type': 'userInput', 'response': response});
|
2021-07-31 15:24:23 +10:00
|
|
|
|
|
|
|
} else if (evt.data.type === 'errorMessage') {
|
|
|
|
divLogs2.insertAdjacentHTML('beforeend', evt.data.message);
|
2021-06-04 15:01:53 +10:00
|
|
|
}
|
2021-06-03 15:47:19 +10:00
|
|
|
}
|
|
|
|
|
2021-06-04 18:59:50 +10:00
|
|
|
worker.onerror = function(evt) {
|
|
|
|
alert('An unknown error occurred while counting the votes. More details may be available in the browser\'s developer console.');
|
|
|
|
}
|
|
|
|
|
2021-06-02 21:37:47 +10:00
|
|
|
async function clickCount() {
|
|
|
|
if (document.getElementById('bltFile').files.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read BLT file
|
2021-06-27 22:09:34 +10:00
|
|
|
let bltPath = document.getElementById('bltFile').value;
|
|
|
|
bltPath = bltPath.substring(Math.max(bltPath.lastIndexOf('\\'), bltPath.lastIndexOf('/')) + 1);
|
2021-06-04 15:01:53 +10:00
|
|
|
|
2021-06-02 21:37:47 +10:00
|
|
|
let bltFile = document.getElementById('bltFile').files[0];
|
2021-06-27 22:09:34 +10:00
|
|
|
let bltData = await bltFile.text();
|
|
|
|
|
|
|
|
// Read CON file (if applicable)
|
|
|
|
let conPath = null;
|
|
|
|
let conData = null;
|
|
|
|
if (document.getElementById('conFile').files.length > 0) {
|
|
|
|
conPath = document.getElementById('conFile').value;
|
|
|
|
conPath = conPath.substring(Math.max(conPath.lastIndexOf('\\'), conPath.lastIndexOf('/')) + 1);
|
|
|
|
|
|
|
|
let conFile = document.getElementById('conFile').files[0];
|
|
|
|
conData = await conFile.text();
|
|
|
|
}
|
2021-06-02 21:37:47 +10:00
|
|
|
|
|
|
|
// Init STV options
|
2021-06-04 15:01:53 +10:00
|
|
|
let optsStr = [
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked ? parseInt(document.getElementById('txtRoundSFs').value) : null,
|
|
|
|
document.getElementById('chkRoundValues').checked ? parseInt(document.getElementById('txtRoundValues').value) : null,
|
2021-06-02 21:37:47 +10:00
|
|
|
document.getElementById('chkRoundVotes').checked ? parseInt(document.getElementById('txtRoundVotes').value) : null,
|
|
|
|
document.getElementById('chkRoundQuota').checked ? parseInt(document.getElementById('txtRoundQuota').value) : null,
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selSumTransfers').value,
|
2021-06-18 18:48:12 +10:00
|
|
|
document.getElementById('txtMeekSurplusTolerance').value,
|
2021-06-12 16:03:31 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked,
|
2021-06-02 21:37:47 +10:00
|
|
|
document.getElementById('selQuota').value,
|
|
|
|
document.getElementById('selQuotaCriterion').value,
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selQuotaMode').value,
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value.split(','),
|
2021-06-13 03:15:15 +10:00
|
|
|
document.getElementById('txtSeed').value,
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value,
|
2021-06-02 21:37:47 +10:00
|
|
|
document.getElementById('selSurplus').value,
|
|
|
|
document.getElementById('selPapers').value == 'transferable',
|
|
|
|
document.getElementById('selExclusion').value,
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('chkMeekNZExclusion').checked,
|
2021-08-05 18:41:39 +10:00
|
|
|
document.getElementById('selSample').value,
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('chkSamplePerBallot').checked,
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked,
|
2021-06-09 12:42:47 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked,
|
|
|
|
document.getElementById('chkDeferSurpluses').checked,
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked,
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value,
|
2021-06-27 22:24:25 +10:00
|
|
|
conPath,
|
2021-06-27 21:57:24 +10:00
|
|
|
"guard_doom",
|
2021-06-02 21:37:47 +10:00
|
|
|
parseInt(document.getElementById('txtPPDP').value),
|
2021-06-04 15:01:53 +10:00
|
|
|
];
|
2021-06-03 15:47:19 +10:00
|
|
|
|
2021-07-31 15:24:23 +10:00
|
|
|
// Reset UI
|
|
|
|
document.getElementById('printPane').style.display = 'none';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('resultLogs1').innerHTML = '';
|
|
|
|
tblResult.innerHTML = '';
|
|
|
|
divLogs2.innerHTML = '';
|
2021-06-18 18:48:12 +10:00
|
|
|
|
2021-09-11 21:08:36 +10:00
|
|
|
detailedTransfers = {};
|
|
|
|
|
2021-06-04 15:01:53 +10:00
|
|
|
// Dispatch to worker
|
|
|
|
worker.postMessage({
|
|
|
|
'type': 'countElection',
|
2021-08-16 18:48:49 +10:00
|
|
|
// Data
|
2021-06-27 22:09:34 +10:00
|
|
|
'bltData': bltData,
|
|
|
|
'conData': conData,
|
|
|
|
'bltPath': bltPath,
|
|
|
|
'conPath': conPath,
|
2021-08-16 18:48:49 +10:00
|
|
|
// Options
|
|
|
|
'optsStr': optsStr,
|
2021-06-04 18:59:50 +10:00
|
|
|
'numbers': document.getElementById('selNumbers').value,
|
2021-06-04 22:05:48 +10:00
|
|
|
'decimals': document.getElementById('txtDP').value,
|
2021-06-11 21:23:08 +10:00
|
|
|
'normaliseBallots': document.getElementById('chkNormaliseBallots').checked,
|
2021-08-16 18:48:49 +10:00
|
|
|
'reportStyle': document.getElementById('selReport').value,
|
2021-06-04 15:01:53 +10:00
|
|
|
});
|
2021-06-02 21:37:47 +10:00
|
|
|
}
|
2021-06-06 00:38:25 +10:00
|
|
|
|
2021-09-11 21:08:36 +10:00
|
|
|
function viewDetailedTransfers(stageNum) {
|
|
|
|
let wtransfers = window.open('', '', 'location=0,width=800,height=600');
|
|
|
|
wtransfers.document.title = 'OpenTally Detailed Transfers: Stage ' + stageNum;
|
|
|
|
|
|
|
|
// Add stylesheets
|
|
|
|
for (let elCSSBase of document.querySelectorAll('head link')) {
|
|
|
|
let elCSS = wtransfers.document.createElement('link');
|
|
|
|
elCSS.rel = elCSSBase.rel;
|
|
|
|
elCSS.type = elCSSBase.type;
|
|
|
|
if (elCSSBase.href.endsWith('?v=GITVERSION')) {
|
|
|
|
elCSS.href = elCSSBase.href.replace('?v=GITVERSION', '?v=' + Math.random());
|
|
|
|
} else {
|
|
|
|
elCSS.href = elCSSBase.href;
|
|
|
|
}
|
|
|
|
wtransfers.document.head.appendChild(elCSS);
|
|
|
|
}
|
|
|
|
|
|
|
|
wtransfers.document.body.innerHTML = detailedTransfers[stageNum];
|
|
|
|
}
|
|
|
|
|
2021-06-13 03:15:15 +10:00
|
|
|
// Provide a default seed
|
|
|
|
if (document.getElementById('txtSeed').value === '') {
|
|
|
|
function pad(x) { if (x < 10) { return '0' + x; } return '' + x; }
|
|
|
|
let d = new Date();
|
|
|
|
document.getElementById('txtSeed').value = d.getFullYear() + pad(d.getMonth() + 1) + pad(d.getDate());
|
|
|
|
}
|
|
|
|
|
2021-06-06 17:31:20 +10:00
|
|
|
// Print logic
|
|
|
|
|
|
|
|
async function printResult() {
|
2021-07-23 00:04:43 +10:00
|
|
|
olStageComments.childNodes.forEach(function(elLi) { elLi.classList.remove('highlight'); });
|
|
|
|
|
2021-06-06 17:31:20 +10:00
|
|
|
let printableWidth; // Printable width in CSS pixels
|
|
|
|
let paperSize = document.getElementById('selPaperSize').value;
|
|
|
|
if (paperSize === 'A4') {
|
|
|
|
printableWidth = (29.7 - 2) * 96 / 2.54;
|
|
|
|
} else if (paperSize === 'A3') {
|
|
|
|
printableWidth = (42.0 - 2) * 96 / 2.54;
|
|
|
|
} else if (paperSize === 'letter') {
|
|
|
|
printableWidth = (27.9 - 2) * 96 / 2.54;
|
|
|
|
}
|
|
|
|
printableWidth = Math.round(printableWidth);
|
|
|
|
|
|
|
|
let wprint = window.open('');
|
|
|
|
wprint.document.title = 'OpenTally Report';
|
|
|
|
|
|
|
|
// Add stylesheets
|
|
|
|
let numToLoad = 0;
|
|
|
|
let numLoaded = -1;
|
|
|
|
|
|
|
|
function onLoadStylesheet() {
|
|
|
|
numLoaded++;
|
|
|
|
if (numLoaded == numToLoad) {
|
|
|
|
wprint.print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let elCSSBase of document.querySelectorAll('head link')) {
|
|
|
|
numToLoad++;
|
|
|
|
let elCSS = wprint.document.createElement('link');
|
|
|
|
elCSS.rel = elCSSBase.rel;
|
|
|
|
elCSS.type = elCSSBase.type;
|
|
|
|
if (elCSSBase.href.endsWith('?v=GITVERSION')) {
|
|
|
|
elCSS.href = elCSSBase.href.replace('?v=GITVERSION', '?v=' + Math.random());
|
|
|
|
} else {
|
|
|
|
elCSS.href = elCSSBase.href;
|
|
|
|
}
|
|
|
|
|
|
|
|
elCSS.onload = onLoadStylesheet;
|
|
|
|
wprint.document.head.appendChild(elCSS);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Configure printing
|
|
|
|
let elStyle = wprint.document.createElement('style');
|
|
|
|
elStyle.innerHTML = '@page { size: ' + paperSize + ' landscape; margin: 1cm; } @media print { body { padding: 0; } }';
|
|
|
|
wprint.document.head.appendChild(elStyle);
|
|
|
|
|
|
|
|
let elContainer = wprint.document.createElement('div');
|
|
|
|
elContainer.id = 'printContainer';
|
|
|
|
elContainer.style.width = printableWidth + 'px';
|
|
|
|
wprint.document.body.appendChild(elContainer);
|
|
|
|
|
|
|
|
// Copy result logs 1
|
|
|
|
let divResultLogs1 = document.getElementById('resultLogs1');
|
|
|
|
let divResultLogs2 = wprint.document.createElement('div');
|
|
|
|
divResultLogs2.innerHTML = divResultLogs1.innerHTML;
|
|
|
|
elContainer.appendChild(divResultLogs2);
|
|
|
|
|
2021-08-17 01:37:40 +10:00
|
|
|
// Parse table, accounting for colspan/rowspan
|
2021-06-06 17:31:20 +10:00
|
|
|
let elTrs1 = document.querySelector('#result').rows;
|
|
|
|
let rows = [];
|
|
|
|
for (let elTr1 of elTrs1) {
|
|
|
|
rows.push([]);
|
|
|
|
}
|
|
|
|
for (let r = 0; r < elTrs1.length; r++) {
|
|
|
|
for (let c = 0; c < elTrs1[r].cells.length; c++) {
|
|
|
|
let elTd1 = elTrs1[r].cells[c];
|
|
|
|
rows[r].push(elTd1);
|
|
|
|
|
2021-08-17 01:37:40 +10:00
|
|
|
let colspan = elTd1.getAttribute('colspan');
|
|
|
|
if (colspan !== null) {
|
|
|
|
colspan = parseInt(colspan);
|
|
|
|
// Add ghost cells
|
|
|
|
for (let i = 1; i < colspan; i++) {
|
|
|
|
rows[r].push(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-06 17:31:20 +10:00
|
|
|
let rowspan = elTd1.getAttribute('rowspan');
|
|
|
|
// NB: Only works for rowspan in first column
|
|
|
|
if (rowspan !== null && c == 0) {
|
|
|
|
rowspan = parseInt(rowspan);
|
|
|
|
// Add ghost cells
|
|
|
|
for (let i = 1; i < rowspan; i++) {
|
|
|
|
rows[r + i].push(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyColumn(c, elTrs2) {
|
|
|
|
let tdsAdded = [];
|
|
|
|
for (let r = 0; r < rows.length; r++) {
|
|
|
|
if (c < rows[r].length) {
|
|
|
|
let elTd1 = rows[r][c];
|
|
|
|
if (elTd1 !== null) {
|
|
|
|
let elTd2 = wprint.document.createElement('td');
|
|
|
|
elTd2.innerHTML = elTd1.innerHTML;
|
|
|
|
elTd2.className = elTd1.className;
|
2021-07-23 00:04:43 +10:00
|
|
|
if (elTd1.getAttribute('rowspan') !== null) { elTd2.setAttribute('rowspan', elTd1.getAttribute('rowspan')); }
|
2021-08-17 01:37:40 +10:00
|
|
|
if (elTd1.getAttribute('colspan') !== null) { elTd2.setAttribute('colspan', elTd1.getAttribute('colspan')); }
|
2021-07-23 00:04:43 +10:00
|
|
|
if (elTd1.getAttribute('style') !== null) { elTd2.setAttribute('style', elTd1.getAttribute('style')); }
|
2021-06-06 17:31:20 +10:00
|
|
|
elTrs2[r].appendChild(elTd2);
|
|
|
|
tdsAdded.push(elTd2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tdsAdded;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function copyTableColumns(startCol) {
|
2021-08-17 01:37:40 +10:00
|
|
|
let modelRow = document.getElementById('selReport').value === 'ballots_votes' ? rows[4] : rows[3];
|
|
|
|
|
2021-06-06 17:31:20 +10:00
|
|
|
// Add table
|
|
|
|
let elTable2 = wprint.document.createElement('table');
|
|
|
|
elTable2.className = 'result';
|
|
|
|
if (startCol > 1) {
|
|
|
|
elTable2.style.pageBreakBefore = 'always';
|
|
|
|
}
|
|
|
|
elContainer.appendChild(elTable2);
|
|
|
|
|
|
|
|
// Add rows
|
|
|
|
let elTrs2 = [];
|
|
|
|
for (let elTr1 of elTrs1) {
|
|
|
|
let elTr2 = wprint.document.createElement('tr');
|
|
|
|
elTr2.className = elTr1.className;
|
|
|
|
elTrs2.push(elTr2);
|
|
|
|
elTable2.appendChild(elTr2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy first column
|
|
|
|
copyColumn(0, elTrs2);
|
|
|
|
|
|
|
|
// How many columns to copy?
|
2021-08-17 01:37:40 +10:00
|
|
|
let totalWidth = modelRow[0].clientWidth;
|
2021-06-06 17:31:20 +10:00
|
|
|
let endCol;
|
2021-08-17 01:37:40 +10:00
|
|
|
for (endCol = startCol; endCol < modelRow.length; ) {
|
|
|
|
// Check first column
|
|
|
|
if (totalWidth + modelRow[endCol].clientWidth > printableWidth) {
|
2021-06-06 17:31:20 +10:00
|
|
|
break;
|
|
|
|
}
|
2021-08-17 01:37:40 +10:00
|
|
|
|
2021-09-26 02:25:44 +10:00
|
|
|
if (
|
|
|
|
(document.getElementById('selReport').value === 'ballots_votes' && endCol + 1 < modelRow.length) ||
|
|
|
|
(document.getElementById('selReport').value === 'votes_transposed' && endCol != 1 && endCol + 1 < modelRow.length)
|
|
|
|
) {
|
2021-08-17 01:37:40 +10:00
|
|
|
// Check second column
|
|
|
|
if (totalWidth + modelRow[endCol].clientWidth + modelRow[endCol + 1].clientWidth > printableWidth) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok!
|
|
|
|
totalWidth += modelRow[endCol].clientWidth;
|
|
|
|
endCol++;
|
|
|
|
|
2021-09-26 02:25:44 +10:00
|
|
|
if (
|
|
|
|
(document.getElementById('selReport').value === 'ballots_votes' && endCol < modelRow.length) ||
|
|
|
|
(document.getElementById('selReport').value === 'votes_transposed' && endCol != 2 && endCol + 1 < modelRow.length)
|
|
|
|
) {
|
2021-08-17 01:37:40 +10:00
|
|
|
// Second column
|
|
|
|
totalWidth += modelRow[endCol].clientWidth;
|
|
|
|
endCol++;
|
|
|
|
}
|
2021-06-06 17:31:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
// Copy columns
|
2021-08-17 01:37:40 +10:00
|
|
|
let stages = [];
|
2021-06-06 17:31:20 +10:00
|
|
|
for (let c = startCol; c < endCol; c++) {
|
2021-08-17 01:37:40 +10:00
|
|
|
if (rows[0][c] !== null && rows[0][c].querySelector('a')) {
|
|
|
|
// Track stage headings copied
|
|
|
|
stages.push(parseInt(rows[0][c].querySelector('a').innerHTML));
|
|
|
|
}
|
2021-06-06 17:31:20 +10:00
|
|
|
copyColumn(c, elTrs2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy stage comments
|
|
|
|
elContainer.insertAdjacentHTML('beforeend', '<p>Stage comments:</p>');
|
|
|
|
let olStageComments2 = wprint.document.createElement('ol');
|
2021-08-17 01:37:40 +10:00
|
|
|
olStageComments2.start = stages[0];
|
2021-06-06 17:31:20 +10:00
|
|
|
elContainer.append(olStageComments2);
|
2021-08-17 01:37:40 +10:00
|
|
|
for (let stage of stages) {
|
|
|
|
olStageComments2.insertAdjacentHTML('beforeend', olStageComments.children[stage-1].outerHTML);
|
2021-06-06 17:31:20 +10:00
|
|
|
}
|
|
|
|
|
2021-08-17 01:37:40 +10:00
|
|
|
if (endCol < modelRow.length) {
|
2021-06-06 17:31:20 +10:00
|
|
|
// Start new table if columns remain
|
|
|
|
copyTableColumns(endCol);
|
|
|
|
} else {
|
|
|
|
// Copy winning candidates
|
|
|
|
elContainer.insertAdjacentHTML('beforeend', '<p>Count complete. The winning candidates are, in order of election:</p>');
|
|
|
|
elContainer.insertAdjacentHTML('beforeend', divLogs2.lastElementChild.outerHTML);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust results table to width
|
|
|
|
document.getElementById('resultsDiv').style.width = printableWidth + 'px';
|
|
|
|
await new Promise(window.requestAnimationFrame); // Allow DOM to update
|
|
|
|
|
|
|
|
// Copy table
|
|
|
|
await copyTableColumns(1);
|
|
|
|
|
|
|
|
// Restore original view
|
|
|
|
document.getElementById('resultsDiv').style.width = 'auto';
|
|
|
|
|
|
|
|
// Trigger print when ready
|
|
|
|
onLoadStylesheet();
|
|
|
|
}
|
|
|
|
|
2021-06-06 00:38:25 +10:00
|
|
|
// Presets
|
|
|
|
|
|
|
|
function changePreset() {
|
2021-06-11 21:22:28 +10:00
|
|
|
if (document.getElementById('selPreset').value === 'wigm') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'gt';
|
2021-08-09 17:58:05 +10:00
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
2021-06-11 21:23:08 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('chkRoundQuota').checked = false;
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'wig';
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-11 21:22:28 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'scottish') {
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-09 12:42:47 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('txtPPDP').value = '5';
|
2021-08-19 18:08:24 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '5';
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-06-11 21:22:28 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'per_ballot';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'wig';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-18 18:48:12 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'meek87') {
|
2021-06-16 13:00:54 +10:00
|
|
|
document.getElementById('selQuotaCriterion').value = 'gt';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
2021-08-08 19:34:02 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'dynamic_by_total';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-16 13:00:54 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = false;
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('chkMeekNZExclusion').checked = false;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-16 13:00:54 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = false;
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-06-18 18:48:12 +10:00
|
|
|
//document.getElementById('selSumTransfers').value = 'single_step';
|
|
|
|
document.getElementById('txtMeekSurplusTolerance').value = '0.001%';
|
|
|
|
//document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'meek';
|
2021-06-22 14:34:26 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-06-18 18:48:12 +10:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
|
|
|
} else if (document.getElementById('selPreset').value === 'meek06') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-08-08 19:34:02 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'dynamic_by_total';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-18 18:48:12 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('chkMeekNZExclusion').checked = false;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '12';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '9';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '9';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '9';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '9';
|
2021-06-20 01:28:54 +10:00
|
|
|
//document.getElementById('selSumTransfers').value = 'single_step';
|
|
|
|
document.getElementById('txtMeekSurplusTolerance').value = '0.0001';
|
|
|
|
//document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'meek';
|
2021-06-22 14:34:26 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-06-20 01:28:54 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'meeknz') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-08-08 19:34:02 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'dynamic_by_total';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-06-20 01:28:54 +10:00
|
|
|
document.getElementById('chkMeekNZExclusion').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-18 18:48:12 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '12';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '9';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '9';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '9';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '9';
|
2021-06-18 18:48:12 +10:00
|
|
|
//document.getElementById('selSumTransfers').value = 'single_step';
|
|
|
|
document.getElementById('txtMeekSurplusTolerance').value = '0.0001';
|
|
|
|
//document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'meek';
|
2021-06-22 14:34:26 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-06-06 00:38:25 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'senate') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-07-23 20:30:14 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false; // Senate "bulk exclusion" does not permit quota to be exceeded
|
2021-06-09 12:42:47 +10:00
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-22 20:30:07 +10:00
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('txtPPDP').value = '0';
|
2021-06-11 21:23:08 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '0';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'uig';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-07-22 00:40:01 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'wa') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-22 20:30:07 +10:00
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('txtPPDP').value = '0';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '0';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'wig';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'by_source';
|
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-07-22 20:31:06 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'act') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-07-23 00:04:43 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-07-22 20:31:06 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-22 20:31:06 +10:00
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '6';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-07-22 20:31:06 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-07-22 20:31:06 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-08-07 18:51:48 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'minneapolis') {
|
2021-08-05 21:37:06 +10:00
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
|
|
|
document.getElementById('chkImmediateElect').checked = false;
|
2021-08-05 21:37:06 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '4';
|
|
|
|
document.getElementById('txtPPDP').value = '4';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '4';
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-08-05 21:37:06 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
|
|
|
document.getElementById('selMethod').value = 'wig';
|
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-08-06 14:31:38 +10:00
|
|
|
document.getElementById('selTies').value = 'random';
|
2021-08-07 18:51:48 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'cambridge') {
|
2021-08-03 18:38:45 +10:00
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-08-05 01:12:53 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
2021-08-03 18:38:45 +10:00
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-09-27 19:02:30 +10:00
|
|
|
document.getElementById('selSample').value = 'cincinnati';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('chkSamplePerBallot').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '49';
|
2021-08-03 18:38:45 +10:00
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
|
|
|
document.getElementById('txtPPDP').value = '0';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = true;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-09-27 19:02:30 +10:00
|
|
|
document.getElementById('selMethod').value = 'hare';
|
2021-08-03 18:38:45 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-09-14 22:47:35 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'dail') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-09-27 19:02:30 +10:00
|
|
|
document.getElementById('selSample').value = 'stratify';
|
2021-09-14 22:47:35 +10:00
|
|
|
document.getElementById('chkSamplePerBallot').checked = false;
|
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
|
|
|
document.getElementById('txtPPDP').value = '0';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = true;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
|
|
|
document.getElementById('selMethod').value = 'hare';
|
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-06-22 15:23:46 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'wright') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-22 15:23:46 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-22 15:23:46 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = false;
|
|
|
|
document.getElementById('chkRoundValues').checked = false;
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-06-22 15:23:46 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'wig';
|
2021-06-22 15:23:46 +10:00
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'wright';
|
|
|
|
document.getElementById('selTies').value = 'random';
|
2021-06-06 00:38:25 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'prsa77') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-09 12:42:47 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
2021-07-22 20:30:07 +10:00
|
|
|
document.getElementById('txtDP').value = '6';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('txtPPDP').value = '3';
|
2021-06-11 21:23:08 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '3';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '3';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '3';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '3';
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-06-06 00:38:25 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'parcels_by_order';
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-07 20:52:18 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'ers97') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
|
|
|
document.getElementById('selQuotaMode').value = 'ers97';
|
2021-06-23 00:52:25 +10:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
2021-06-09 12:42:47 +10:00
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
2021-07-16 17:04:20 +10:00
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '2';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '2';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '2';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '2';
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-07-18 20:01:35 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-07-18 20:01:35 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
|
|
|
} else if (document.getElementById('selPreset').value === 'ers76') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
|
|
|
document.getElementById('selQuotaMode').value = 'ers76';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-18 20:01:35 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '2';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '2';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '2';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '2';
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-07-16 17:04:20 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-07-16 17:04:20 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
|
|
|
} else if (document.getElementById('selPreset').value === 'ers73') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-16 17:04:20 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
2021-06-11 21:23:08 +10:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '2';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '2';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '2';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '2';
|
2021-08-16 00:46:05 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'by_value';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-06-07 20:52:18 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
2021-06-13 00:39:49 +10:00
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-07-22 00:40:01 +10:00
|
|
|
} else if (document.getElementById('selPreset').value === 'cofe') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-08-07 18:51:48 +10:00
|
|
|
document.getElementById('chkImmediateElect').checked = true;
|
2021-08-03 23:22:52 +10:00
|
|
|
document.getElementById('txtMinThreshold').value = '0';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '2';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '2';
|
2021-08-03 16:46:21 +10:00
|
|
|
document.getElementById('chkRoundSFs').checked = true;
|
|
|
|
document.getElementById('txtRoundSFs').value = '2';
|
|
|
|
document.getElementById('chkRoundValues').checked = true;
|
|
|
|
document.getElementById('txtRoundValues').value = '2';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selSumTransfers').value = 'per_ballot';
|
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
2021-08-04 13:46:32 +10:00
|
|
|
document.getElementById('selMethod').value = 'eg';
|
2021-07-22 00:40:01 +10:00
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-06-06 00:38:25 +10:00
|
|
|
}
|
|
|
|
}
|