diff --git a/README.md b/README.md
index 2a0f2d6..f55448d 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ To load the Tampermonkey script:
### Functionality For Release
- [ ] Read from /app/subscriptions to get list of initial counties - if county is missing it automatically gets added.
-- [ ] Sitewide bidcap (if any county bid exceeds X only bid up to X for that county)
+- [x] Expose Sitewide bidcap (if any county bid exceeds X only bid up to X for that county)
- [x] Save button to persist changes (instead of waiting for refresh code to run)
- [x] Save settings to local storage
- [x] Retrieve settings from local storage
@@ -20,11 +20,12 @@ To load the Tampermonkey script:
- [ ] use bidcap when processing each oversight
- [ ] Implement tieCounty code
- [ ] Implement watchCounty code
-- [ ] Add cap presidence setting.
+- [x] Add cap presidence setting.
+- [ ] Add General Cap Applies to option
*If a row and settings cap are enabled then [options🔽] takes presidence.*
```Options
- S - SettingsBidCap
+ G - GeneralBidCap
R - RowCap
H - The highest cap
L - The lowest cap
diff --git a/tampermonkey.js b/tampermonkey.js
index 951b7e7..4baf374 100644
--- a/tampermonkey.js
+++ b/tampermonkey.js
@@ -21,7 +21,7 @@ var alwaysWinSettingsString = localStorage.getItem('alwayswin_settings');
//console.log(alwaysWinSettingsString);
if(alwaysWinSettingsString == null || alwaysWinSettingsString == undefined) {
- const defaultSettings = {"isReloadEnabled":true, "isAutoLoginEnabled":false, "minSecondsBetweenReloads": 60, "maxSecondsBetweenReloads":300, "bidCap":500, "oversight":[]};
+ const defaultSettings = {"isReloadEnabled":true, "isAutoLoginEnabled":false, "minSecondsBetweenReloads": 60, "maxSecondsBetweenReloads":300, "isGeneralCapEnabled":false, "generalCap":500, "oversight":[]};
const defaultSettingsString = JSON.stringify(defaultSettings);
localStorage.setItem('alwayswin_settings',defaultSettingsString);
alwaysWinSettingsString = defaultSettingsString;
@@ -45,6 +45,8 @@ function getCheckedValue(fieldName) {
return reloadIsEnabled() ? "checked": "";
case "isAutoLoginEnabled":
return autoLoginIsEnabled() ? "checked": "";
+ case "isGeneralCapEnabled":
+ return generalCapIsEnabled() ? "checked" :"";
default:
return "";
}
@@ -71,7 +73,10 @@ function saveSettings() {
let isAutoLoginEnabledValue = document.querySelector("[name='isAutoLoginEnabled']").checked;
let minSecondsBetweenReloadsValue = document.querySelector("[name='minSecondsBetweenReloads']").value;
let maxSecondsBetweenReloadsValue = document.querySelector("[name='maxSecondsBetweenReloads']").value;
- let bidCap = document.querySelector("[name='bidCap']").value;
+ let isGeneralCapEnabledValue = document.querySelector("[name='isGeneralCapEnabled']").checked;
+ let generalCap = document.querySelector("[name='generalCap']").value;
+ let capPresidence = document.querySelector("[name='capPresidence']").value;
+
let oversight = [];
@@ -80,7 +85,9 @@ function saveSettings() {
latestSettings.isAutoLoginEnabled = isAutoLoginEnabledValue;
latestSettings.minSecondsBetweenReloads = minSecondsBetweenReloadsValue;
latestSettings.maxSecondsBetweenReloads = maxSecondsBetweenReloadsValue;
- latestSettings.bidCap = bidCap;
+ latestSettings.isGeneralCapEnabled = isGeneralCapEnabledValue;
+ latestSettings.generalCap = generalCap;
+ latestSettings.capPresidence = capPresidence;
if(latestSettings.oversight == null || latestSettings == undefined) {
latestSettings.oversight = oversight;
}
@@ -135,9 +142,15 @@ function autoLoginIsEnabled(){
return retVal;
}
+function generalCapIsEnabled () {
+ var checkedValue = alwaysWinSettings.isGeneralCapEnabled ?? false;
+ var retVal = (checkedValue == true);
+ return retVal;
+}
+
function getBidCap(countyId) {
//Get the default bidcap from settings
- var bidCap = alwaysWinSettings.bidCap;
+ var bidCap = alwaysWinSettings.generalCap;
const countyOversight = alwaysWinSettings.oversight.find(({ id }) => id === countyId);
if(countyFound(countyOversight)) {
bidCap = countyOversight.bidCap;
@@ -195,6 +208,10 @@ function getCountyInfo(countyId){
}
function winCounty(countyJson, saveChanges) {
+ if(countyJson?.id == undefined) {
+ awLog("Unable to find county. So no way to win it.");
+ return;
+ }
let countyInfo = countyJson.id + " "+ countyJson.name;
//console.log(countyJson.isWinning +" = "+ countyJson.tieBid +" > "+ countyJson.bid);
//console.log(countyJson.isWinningByTooMuch +" = "+ countyJson.bid +" > "+ countyJson.winningBid);
@@ -315,15 +332,27 @@ function loginIfNeeded(){
return loginIsNeeded;
}
-function renderOption(value, selectedValue) {
+function renderOption(value, selectedValue, displayValue) {
+ if(displayValue == null || displayValue===undefined) {
+ displayValue = value;
+ }
var optionHtml = '';
+ optionHtml += '>'+ displayValue +'';
return optionHtml;
}
+function getCapPresidenceOptions(selectedAction) {
+ var optionsHtml = "";
+ optionsHtml += renderOption("row", selectedAction, "Row Cap");
+ optionsHtml += renderOption("general", selectedAction, "General Cap");
+ optionsHtml += renderOption("highest", selectedAction, "Highest Cap");
+ optionsHtml += renderOption("lowest", selectedAction, "Lowest Cap");
+ return optionsHtml;
+}
+
function getOversightOptions(countyId, selectedAction) {
var optionsHtml = "";
optionsHtml += renderOption("win", selectedAction);
@@ -392,11 +421,65 @@ function injectOversight(countyId, action) {
oversightPriceDiv.id = "oversight-price-"+countyId;
oversightPriceDiv.style = "border: 1px dotted gray; padding: 0; margin: 0; font-size: 12px; overflow-x: visible";
+//Begin TODO: move this code block elsewhere IT IS WIP
+ const settingsCapPresidence = alwaysWinSettings.capPresidence;
+ const settings_Presidence_RowCap = (settingsCapPresidence == "row");
+ const settings_Presidence_GeneralCap = (settingsCapPresidence == "generl");
+ const settings_Presidence_HighestCap = (settingsCapPresidence == "highest");
+ const settings_Presidence_LowestCap = (settingsCapPresidence == "lowest");
+
+ const settingsGeneralCapAppliesTo = "capped" //[n,a,c,u]
+ const settings_GeneralCapAppliesTo_None = (settingsGeneralCapAppliesTo == "none")//None of the
+ const settings_GeneralCapAppliesTo_All = (settingsGeneralCapAppliesTo == "all")//All
+ const settings_GeneralCapAppliesTo_Capped = (settingsGeneralCapAppliesTo == "capped")//Capped Only
+ const settings_GeneralCapAppliesTo_Uncapped = (settingsGeneralCapAppliesTo == "uncapped")//UnCapped Only
+
+ const rowCapControlsShouldBeVisible = (action == "win" || action == "tie"); //TODO write logic to determine if the enable Bidcap checkbox and words should be visible
+ const rowCapCheckboxShouldBeVisible = (action == "win" || action == "tie"); //TODO: write logic
+ const rowCapCheckboxShouldBeDisabled = false; //TODO: write logic
+ const rowCapCheckboxShouldBeChecked = false; //TODO: write logic
+
+ const rowCapInputShouldBeVisible = (action == "win"); //TODO: run thru rules to determine showCapInfo value
+ const rowCapInputIsBeingOverridden = settings_Presidence_GeneralCap; //TODO: write logic
+ const rowCapInputShouldBeDisabled = (rowCapInputIsBeingOverridden || !rowCapCheckboxShouldBeChecked); //TODO: write logic
+
+ const trueCap = alwaysWinSettings.generalCap; //countyJson.bidCap; //TODO actually calcuate instead of reading from settings
+ const capIsCurrentlyBeingAppliedToBid = countyJson.bid > Number(trueCap);
+//End TODO
+
+
var priceDivHtml ='';
//priceDivHtml += ''+ countyJson.id +'';
- priceDivHtml += '';
- priceDivHtml += ' | ';
- priceDivHtml += '';
+ priceDivHtml += '';
+ if(rowCapControlsShouldBeVisible) {
+ priceDivHtml += ' | ';
+ }
+ if(rowCapInputIsBeingOverridden) {
+ priceDivHtml += ''+ countyJson.bidCap +' ->'+ alwaysWinSettings.bidCap;//TODO render override html
+ }
+ }
+
+ if(capIsCurrentlyBeingAppliedToBid) {
+ priceDivHtml += '🔀 bid is capped at '+ trueCap;
+ }
+
+
+ //priceDivHtml += '';
oversightPriceDiv.innerHTML = priceDivHtml;
var targetContainer = countyRow.lastElementChild;
@@ -412,19 +495,25 @@ jQuery(window).on('load',function() {
let maxSecondsBetweenReloads = alwaysWinSettings.maxSecondsBetweenReloads ?? 180;
let isReloadEnabled = alwaysWinSettings.isReloadEnabled ?? false;
let isAutoLoginEnabled = alwaysWinSettings.isAutoLoginEnabled ?? false;
- let bidCap = alwaysWinSettings.bidCap ?? 500;
+ let isGeneralCapEnabled = alwaysWinSettings.isGeneralCapEnabled ?? false;
+ let capPresidence = alwaysWinSettings.capPresidence ?? "row";
+ let generalCap = alwaysWinSettings.generalCap ?? 500;
let secondsBetweenReloads = getRandomNumberBetween(minSecondsBetweenReloads, maxSecondsBetweenReloads);
- console.log("Next reload should occur in "+ secondsBetweenReloads +" seconds");
+ //console.log("Next reload should occur in "+ secondsBetweenReloads +" seconds");
//Inject our controls
var newDiv = document.createElement ('div');
var newHtml = '