Add presets dropdown

This commit is contained in:
RunasSudo 2021-06-06 00:38:25 +10:00
parent baec51bd35
commit c6d8ba16dd
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 78 additions and 8 deletions

View File

@ -32,17 +32,17 @@
<div class="menudiv">
<input type="file" id="bltFile">
<button onclick="clickCount()">Count</button>
<!--<label>
<label>
Preset:
<select id="selPreset" onchange="changePreset()">
<option value="scottish" selected>Scottish STV</option>
<option value="senate">Australian Senate STV</option>
<option value="meek">Meek STV</option>
<option value="wright">Wright STV</option>
<!--<option value="meek">Meek STV</option>
<option value="wright">Wright STV</option>-->
<option value="prsa77">PRSA 1977</option>
<option value="ers97">ERS97</option>
<!--<option value="ers97">ERS97</option>-->
</select>
</label>-->
</label>
<button id="btnAdvancedOptions" onclick="clickAdvancedOptions()">Show advanced options</button>
OpenTally (revision <span id="spanRevNum"></span>)
<!--&middot; <a href="https://yingtongli.me/blog/2020/12/24/pyrcv2.html">Information and instructions</a> &middot;
@ -106,9 +106,9 @@
<label>
Exclusion:
<select id="selExclusion">
<option value="single_stage" selected>Exclude in single stage</option>
<option value="by_value">Exclude by value</option>
<option value="parcels_by_order">Exclude by parcel (by order)</option>
<option value="single_stage" selected>Single stage</option>
<option value="by_value">By value</option>
<option value="parcels_by_order">By parcel (by order)</option>
<!--<option value="wright">Wright method (re-iterate)</option>-->
</select>
</label>

View File

@ -113,3 +113,73 @@ async function clickCount() {
'decimals': document.getElementById('txtDP').value,
});
}
// Presets
function changePreset() {
if (document.getElementById('selPreset').value === 'scottish') {
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;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '2';
document.getElementById('chkRoundQuota').checked = true;
document.getElementById('txtRoundQuota').value = '0';
document.getElementById('chkRoundVotes').checked = false;
document.getElementById('chkRoundTVs').checked = false;
document.getElementById('chkRoundWeights').checked = false;
document.getElementById('selSurplus').value = 'by_size';
document.getElementById('selTransfers').value = 'wig';
document.getElementById('selPapers').value = 'both';
document.getElementById('selExclusion').value = 'single_stage';
//document.getElementById('selTies').value = 'backwards_random';
} else if (document.getElementById('selPreset').value === 'senate') {
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;
//document.getElementById('chkDeferSurpluses').checked = false;
document.getElementById('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '0';
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;
document.getElementById('selSurplus').value = 'by_order';
document.getElementById('selTransfers').value = 'uig';
document.getElementById('selPapers').value = 'both';
document.getElementById('selExclusion').value = 'by_value';
//document.getElementById('selTies').value = 'backwards_random';
} else if (document.getElementById('selPreset').value === 'prsa77') {
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('selNumbers').value = 'fixed';
document.getElementById('txtDP').value = '5';
document.getElementById('txtPPDP').value = '3';
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';
document.getElementById('selSurplus').value = 'by_order';
document.getElementById('selTransfers').value = 'eg';
document.getElementById('selPapers').value = 'transferable';
document.getElementById('selExclusion').value = 'parcels_by_order';
//document.getElementById('selTies').value = 'backwards_random';
}
}