|
|
@ -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":{"all":[]}}; |
|
|
|
const defaultSettings = {"isReloadEnabled":true, "isAutoLoginEnabled":false, "minSecondsBetweenReloads": 60, "maxSecondsBetweenReloads":300, "bidCap":500, "oversight":[]}; |
|
|
|
const defaultSettingsString = JSON.stringify(defaultSettings); |
|
|
|
localStorage.setItem('alwayswin_settings',defaultSettingsString); |
|
|
|
alwaysWinSettingsString = defaultSettingsString; |
|
|
@ -73,8 +73,7 @@ function saveSettings() { |
|
|
|
let maxSecondsBetweenReloadsValue = document.querySelector("[name='maxSecondsBetweenReloads']").value; |
|
|
|
let bidCap = document.querySelector("[name='bidCap']").value; |
|
|
|
|
|
|
|
let oversight = {}; |
|
|
|
oversight.all = []; |
|
|
|
let oversight = []; |
|
|
|
|
|
|
|
var latestSettings = alwaysWinSettings; |
|
|
|
latestSettings.isReloadEnabled = isReloadEnabledValue; |
|
|
@ -139,11 +138,11 @@ function autoLoginIsEnabled(){ |
|
|
|
function getBidCap(countyId) { |
|
|
|
//Get the default bidcap from settings
|
|
|
|
var bidCap = alwaysWinSettings.bidCap; |
|
|
|
const countyOversight = alwaysWinSettings.oversight.all.find(({ id }) => id === countyId); |
|
|
|
const countyOversight = alwaysWinSettings.oversight.find(({ id }) => id === countyId); |
|
|
|
if(countyFound(countyOversight)) { |
|
|
|
bidCap = countyOversight.bidCap; |
|
|
|
} |
|
|
|
return bidCap; |
|
|
|
return Number(bidCap); |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
@ -235,10 +234,14 @@ function winCounty(countyJson, saveChanges) { |
|
|
|
|
|
|
|
function tieCounty(countyJson, saveChanges) { |
|
|
|
//TODO: implemnt me
|
|
|
|
let countyInfo = countyJson.id + " "+ countyJson.name; |
|
|
|
awLog(countyInfo +" tieCounty code not yet implemented"); |
|
|
|
} |
|
|
|
|
|
|
|
function watchCounty(countyJson, saveChanges) { |
|
|
|
//TODO: implemnt me
|
|
|
|
let countyInfo = countyJson.id + " "+ countyJson.name; |
|
|
|
awLog(countyInfo +" watchCounty code not yet implemented"); |
|
|
|
} |
|
|
|
|
|
|
|
function awLog(message) { |
|
|
@ -331,10 +334,10 @@ function countyFound(countyValue) { |
|
|
|
function upsertOversight(countyOversightJson) { |
|
|
|
//console.log(countyOversightJson);
|
|
|
|
const countyId = countyOversightJson.id; |
|
|
|
var countyFoundAt = alwaysWinSettings.oversight.all.findIndex(({ id }) => id === countyId); |
|
|
|
var countyFoundAt = alwaysWinSettings.oversight.findIndex(({ id }) => id === countyId); |
|
|
|
if(countyFoundAt == -1) { |
|
|
|
alwaysWinSettings.oversight.all.push(countyOversightJson); |
|
|
|
countyFoundAt = alwaysWinSettings.oversight.all.length; |
|
|
|
alwaysWinSettings.oversight.push(countyOversightJson); |
|
|
|
countyFoundAt = alwaysWinSettings.oversight.length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -358,7 +361,7 @@ function injectOversight(countyId, action) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//// BEGIN TempCode TODO: figure out if I want this code to live here
|
|
|
|
//// BEGIN TempCode TODO: figure out if upsert Code should live in injectOversight
|
|
|
|
const isBidCapEnabled = false; |
|
|
|
const countyOversightJson = convertToOversightJson(countyJson, action, isBidCapEnabled); |
|
|
|
upsertOversight(countyOversightJson); |
|
|
@ -448,18 +451,21 @@ jQuery(window).on('load',function() { |
|
|
|
} |
|
|
|
|
|
|
|
//Inject our bits into the page for oversight
|
|
|
|
injectOversight("84035","win"); //washington, OR
|
|
|
|
injectOversight("87833","win"); //marion, OR
|
|
|
|
injectOversight("84034","tie"); //cascade, MT
|
|
|
|
injectOversight("84037","watch"); //clackamas, OR
|
|
|
|
injectOversight("84038","watch"); //benton, OR
|
|
|
|
//TODO: Get rid of these calls and only read injections from settings (possible when apply button is coded)
|
|
|
|
// For now they will be commented out unless it's a first run of the script
|
|
|
|
//injectOversight("84035","win"); //washington, OR
|
|
|
|
//injectOversight("87833","win"); //marion, OR
|
|
|
|
//injectOversight("84034","tie"); //cascade, MT
|
|
|
|
//injectOversight("84037","watch"); //clackamas, OR
|
|
|
|
//injectOversight("84038","watch"); //benton, OR
|
|
|
|
|
|
|
|
//// Now do the work
|
|
|
|
let newStats = []; |
|
|
|
let countiesToWinCount = alwaysWinSettings.oversight.all.length; |
|
|
|
awLog("Checking "+ countiesToWinCount +" counties"); |
|
|
|
for(let i = 0; i < countiesToWinCount; i++) { |
|
|
|
let currentEntity = alwaysWinSettings.oversight.all[i]; |
|
|
|
let oversightCount = alwaysWinSettings.oversight.length; |
|
|
|
awLog("Checking "+ oversightCount +" counties"); |
|
|
|
for(let i = 0; i < oversightCount; i++) { |
|
|
|
let currentEntity = alwaysWinSettings.oversight[i]; |
|
|
|
injectOversight(currentEntity.id, currentEntity.action); |
|
|
|
const countyInfoJson = getCountyInfo(currentEntity.id); |
|
|
|
//console.log(currentEntity);
|
|
|
|
switch (currentEntity.action) { |
|
|
|