2021-06-02 13:37:47 +02: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 14:46:36 +02:00
|
|
|
var tblResult = document.getElementById('result');
|
2021-06-03 07:47:19 +02:00
|
|
|
var divLogs2 = document.getElementById('resultLogs2');
|
|
|
|
var olStageComments;
|
2021-06-02 14:46:36 +02:00
|
|
|
|
2021-06-04 07:01:53 +02:00
|
|
|
var worker = new Worker('worker.js');
|
2021-06-02 14:46:36 +02:00
|
|
|
|
2021-06-04 07:01:53 +02: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';
|
|
|
|
|
|
|
|
} 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') {
|
|
|
|
for (let i = 0; i < evt.data.result.length; i++) {
|
2021-06-05 15:29:31 +02:00
|
|
|
if (evt.data.result[i]) {
|
|
|
|
tblResult.rows[i].insertAdjacentHTML('beforeend', evt.data.result[i]);
|
|
|
|
|
|
|
|
// Update candidate status
|
|
|
|
if (i >= 3 && i % 2 == 1) {
|
|
|
|
if (tblResult.rows[i].lastElementChild.classList.contains('elected')) {
|
|
|
|
tblResult.rows[i].cells[0].classList.add('elected');
|
|
|
|
} else {
|
|
|
|
tblResult.rows[i].cells[0].classList.remove('elected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-04 07:01:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (evt.data.type === 'updateStageComments') {
|
|
|
|
let elLi = document.createElement('li');
|
|
|
|
elLi.innerHTML = evt.data.comment;
|
|
|
|
olStageComments.append(elLi);
|
|
|
|
|
|
|
|
} else if (evt.data.type === 'finalResultSummary') {
|
|
|
|
divLogs2.insertAdjacentHTML('beforeend', evt.data.summary);
|
2021-06-06 09:31:20 +02:00
|
|
|
document.getElementById('printPane').style.display = 'block';
|
2021-06-11 18:09:26 +02: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-06-04 07:01:53 +02:00
|
|
|
}
|
2021-06-03 07:47:19 +02:00
|
|
|
}
|
|
|
|
|
2021-06-04 10:59:50 +02: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 13:37:47 +02:00
|
|
|
async function clickCount() {
|
|
|
|
if (document.getElementById('bltFile').files.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read BLT file
|
2021-06-04 07:01:53 +02:00
|
|
|
let filePath = document.getElementById('bltFile').value;
|
|
|
|
filePath = filePath.substring(Math.max(filePath.lastIndexOf('\\'), filePath.lastIndexOf('/')) + 1);
|
|
|
|
|
2021-06-02 13:37:47 +02:00
|
|
|
let bltFile = document.getElementById('bltFile').files[0];
|
|
|
|
let electionData = await bltFile.text();
|
|
|
|
|
|
|
|
// Init STV options
|
2021-06-04 07:01:53 +02:00
|
|
|
let optsStr = [
|
2021-06-02 13:37:47 +02:00
|
|
|
document.getElementById('chkRoundTVs').checked ? parseInt(document.getElementById('txtRoundTVs').value) : null,
|
|
|
|
document.getElementById('chkRoundWeights').checked ? parseInt(document.getElementById('txtRoundWeights').value) : null,
|
|
|
|
document.getElementById('chkRoundVotes').checked ? parseInt(document.getElementById('txtRoundVotes').value) : null,
|
|
|
|
document.getElementById('chkRoundQuota').checked ? parseInt(document.getElementById('txtRoundQuota').value) : null,
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('selSumTransfers').value,
|
2021-06-12 08:03:31 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked,
|
2021-06-02 13:37:47 +02:00
|
|
|
document.getElementById('selQuota').value,
|
|
|
|
document.getElementById('selQuotaCriterion').value,
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selQuotaMode').value,
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value.split(','),
|
2021-06-12 19:15:15 +02:00
|
|
|
document.getElementById('txtSeed').value,
|
2021-06-02 13:37:47 +02:00
|
|
|
document.getElementById('selTransfers').value,
|
|
|
|
document.getElementById('selSurplus').value,
|
|
|
|
document.getElementById('selPapers').value == 'transferable',
|
|
|
|
document.getElementById('selExclusion').value,
|
2021-06-09 04:42:47 +02:00
|
|
|
document.getElementById('chkBulkExclusion').checked,
|
|
|
|
document.getElementById('chkDeferSurpluses').checked,
|
2021-06-02 13:37:47 +02:00
|
|
|
parseInt(document.getElementById('txtPPDP').value),
|
2021-06-04 07:01:53 +02:00
|
|
|
];
|
2021-06-03 07:47:19 +02:00
|
|
|
|
2021-06-04 07:01:53 +02:00
|
|
|
// Dispatch to worker
|
|
|
|
worker.postMessage({
|
|
|
|
'type': 'countElection',
|
|
|
|
'electionData': electionData,
|
|
|
|
'optsStr': optsStr,
|
2021-06-04 10:59:50 +02:00
|
|
|
'filePath': filePath,
|
|
|
|
'numbers': document.getElementById('selNumbers').value,
|
2021-06-04 14:05:48 +02:00
|
|
|
'decimals': document.getElementById('txtDP').value,
|
2021-06-11 13:23:08 +02:00
|
|
|
'normaliseBallots': document.getElementById('chkNormaliseBallots').checked,
|
2021-06-04 07:01:53 +02:00
|
|
|
});
|
2021-06-02 13:37:47 +02:00
|
|
|
}
|
2021-06-05 16:38:25 +02:00
|
|
|
|
2021-06-12 19:15:15 +02: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 09:31:20 +02:00
|
|
|
// Print logic
|
|
|
|
|
|
|
|
async function printResult() {
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Parse table, accounting for rowspan
|
|
|
|
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);
|
|
|
|
|
|
|
|
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;
|
|
|
|
elTd2.setAttribute('rowspan', elTd1.getAttribute('rowspan'));
|
|
|
|
elTd2.setAttribute('style', elTd1.getAttribute('style'));
|
|
|
|
elTrs2[r].appendChild(elTd2);
|
|
|
|
tdsAdded.push(elTd2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tdsAdded;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function copyTableColumns(startCol) {
|
|
|
|
// 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?
|
|
|
|
let totalWidth = rows[0][0].clientWidth;
|
|
|
|
let endCol;
|
|
|
|
for (endCol = startCol; endCol < rows[0].length; endCol++) {
|
|
|
|
if (totalWidth + rows[0][endCol].clientWidth > printableWidth) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
totalWidth += rows[0][endCol].clientWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy columns
|
|
|
|
for (let c = startCol; c < endCol; c++) {
|
|
|
|
copyColumn(c, elTrs2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy stage comments
|
|
|
|
elContainer.insertAdjacentHTML('beforeend', '<p>Stage comments:</p>');
|
|
|
|
let olStageComments2 = wprint.document.createElement('ol');
|
|
|
|
olStageComments2.start = startCol;
|
|
|
|
elContainer.append(olStageComments2);
|
|
|
|
for (let c = startCol; c < endCol && c < rows[0].length - 1; c++) {
|
|
|
|
olStageComments2.insertAdjacentHTML('beforeend', olStageComments.children[c-1].outerHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endCol < rows[0].length) {
|
|
|
|
// 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-05 16:38:25 +02:00
|
|
|
// Presets
|
|
|
|
|
|
|
|
function changePreset() {
|
2021-06-11 13:22:28 +02:00
|
|
|
if (document.getElementById('selPreset').value === 'wigm') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'gt';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
|
|
|
document.getElementById('selNumbers').value = 'rational';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
2021-06-11 13:23:08 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('chkRoundQuota').checked = false;
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
|
|
|
document.getElementById('chkRoundTVs').checked = false;
|
|
|
|
document.getElementById('chkRoundWeights').checked = false;
|
|
|
|
document.getElementById('selSumTransfers').value = 'single_step';
|
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
|
|
|
document.getElementById('selTransfers').value = 'wig';
|
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-11 13:22:28 +02:00
|
|
|
} else if (document.getElementById('selPreset').value === 'scottish') {
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-09 04:42:47 +02:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('txtPPDP').value = '5';
|
2021-06-11 13:23:08 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = true;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = false;
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('chkRoundTVs').checked = true;
|
|
|
|
document.getElementById('txtRoundTVs').value = '5';
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('chkRoundWeights').checked = false;
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('selSumTransfers').value = 'per_ballot';
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
|
|
|
document.getElementById('selTransfers').value = 'wig';
|
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-16 05:00:54 +02:00
|
|
|
} else if (document.getElementById('selPreset').value === 'meek') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'gt';
|
|
|
|
document.getElementById('selQuota').value = 'droop_exact';
|
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
|
|
|
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;
|
|
|
|
document.getElementById('chkRoundTVs').checked = false;
|
|
|
|
document.getElementById('chkRoundWeights').checked = false;
|
|
|
|
document.getElementById('selSumTransfers').value = 'single_step';
|
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
|
|
|
document.getElementById('selTransfers').value = 'meek';
|
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'single_stage';
|
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-05 16:38:25 +02:00
|
|
|
} else if (document.getElementById('selPreset').value === 'senate') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-09 04:42:47 +02:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = false;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '0';
|
2021-06-11 13:23:08 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '0';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '0';
|
|
|
|
document.getElementById('chkRoundTVs').checked = false;
|
|
|
|
document.getElementById('chkRoundWeights').checked = false;
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('selSumTransfers').value = 'single_step';
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
|
|
|
document.getElementById('selTransfers').value = 'uig';
|
|
|
|
document.getElementById('selPapers').value = 'both';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-05 16:38:25 +02:00
|
|
|
} else if (document.getElementById('selPreset').value === 'prsa77') {
|
|
|
|
document.getElementById('selQuotaCriterion').value = 'geq';
|
|
|
|
document.getElementById('selQuota').value = 'droop';
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selQuotaMode').value = 'static';
|
2021-06-09 04:42:47 +02:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = false;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '3';
|
2021-06-11 13:23:08 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '3';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '3';
|
|
|
|
document.getElementById('chkRoundTVs').checked = true;
|
|
|
|
document.getElementById('txtRoundTVs').value = '3';
|
|
|
|
document.getElementById('chkRoundWeights').checked = true;
|
|
|
|
document.getElementById('txtRoundWeights').value = '3';
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('selSumTransfers').value = 'single_step';
|
2021-06-05 16:38:25 +02:00
|
|
|
document.getElementById('selSurplus').value = 'by_order';
|
|
|
|
document.getElementById('selTransfers').value = 'eg';
|
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'parcels_by_order';
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value = 'backwards,random';
|
2021-06-07 12:52:18 +02: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-09 04:42:47 +02:00
|
|
|
document.getElementById('chkBulkElection').checked = true;
|
|
|
|
document.getElementById('chkBulkExclusion').checked = true;
|
|
|
|
document.getElementById('chkDeferSurpluses').checked = true;
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selNumbers').value = 'fixed';
|
|
|
|
document.getElementById('txtDP').value = '5';
|
|
|
|
document.getElementById('txtPPDP').value = '2';
|
2021-06-11 13:23:08 +02:00
|
|
|
document.getElementById('chkNormaliseBallots').checked = false;
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('chkRoundQuota').checked = true;
|
|
|
|
document.getElementById('txtRoundQuota').value = '2';
|
|
|
|
document.getElementById('chkRoundVotes').checked = true;
|
|
|
|
document.getElementById('txtRoundVotes').value = '2';
|
|
|
|
document.getElementById('chkRoundTVs').checked = true;
|
|
|
|
document.getElementById('txtRoundTVs').value = '2';
|
|
|
|
document.getElementById('chkRoundWeights').checked = true;
|
|
|
|
document.getElementById('txtRoundWeights').value = '2';
|
2021-06-11 13:22:28 +02:00
|
|
|
document.getElementById('selSumTransfers').value = 'single_step';
|
2021-06-07 12:52:18 +02:00
|
|
|
document.getElementById('selSurplus').value = 'by_size';
|
|
|
|
document.getElementById('selTransfers').value = 'eg';
|
|
|
|
document.getElementById('selPapers').value = 'transferable';
|
|
|
|
document.getElementById('selExclusion').value = 'by_value';
|
2021-06-12 16:39:49 +02:00
|
|
|
document.getElementById('selTies').value = 'forwards,random';
|
2021-06-05 16:38:25 +02:00
|
|
|
}
|
|
|
|
}
|