|
|
@ -72,6 +72,19 @@ function saveSettings() { |
|
|
|
return latestSettings; |
|
|
|
} |
|
|
|
|
|
|
|
function saveCountyInfoStats(newStats) { |
|
|
|
let existingStats = []; |
|
|
|
//get existing stats if they exist
|
|
|
|
let existingStatsString = localStorage.getItem('alwayswin_stats'); |
|
|
|
if(existingStatsString != null && existingStatsString !== undefined) { |
|
|
|
existingStats = JSON.parse(existingStatsString); |
|
|
|
} |
|
|
|
const combinedStats = existingStats.concat(newStats) |
|
|
|
const updatedStatsString = JSON.stringify(combinedStats); |
|
|
|
localStorage.setItem('alwayswin_stats',updatedStatsString); |
|
|
|
//console.log(combinedStats);
|
|
|
|
} |
|
|
|
|
|
|
|
function reload() { |
|
|
|
console.log("Saving settings..."); |
|
|
|
let alwaysWinSettings = saveSettings(); |
|
|
@ -129,6 +142,7 @@ function getCountyInfo(countyId){ |
|
|
|
num_clicksToMinWin = (winGap + bidIncriment) / bidIncriment; |
|
|
|
} |
|
|
|
|
|
|
|
bidController.readTimestamp = new Date(); |
|
|
|
bidController.isEnabled = county.checked; |
|
|
|
bidController.id = county.dataset.subscription_id; |
|
|
|
bidController.name = county.closest("div").getElementsByTagName('a')[0].innerText; |
|
|
@ -181,6 +195,11 @@ function winCounty(countyJson, saveChanges) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function tieCounty(countyJson, saveChanges) { |
|
|
|
//TODO: implemnt me
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
jQuery(window).on('load',function() { |
|
|
|
console.log("Page loaded at: "+ new Date()); |
|
|
|
|
|
|
@ -202,23 +221,47 @@ jQuery(window).on('load',function() { |
|
|
|
var countiesToWin = []; |
|
|
|
countiesToWin.push("84035"); //washington, OR
|
|
|
|
countiesToWin.push("87833"); //marion, OR
|
|
|
|
//countiesToWin.push("84038"); //benton, OR
|
|
|
|
//countiesToWin.push("84037"); //clackamas, OR
|
|
|
|
|
|
|
|
//var countiesToTie = [];
|
|
|
|
//countiesToTie.push("84034"); //cascade, MT
|
|
|
|
//countiesToTie.push("84038"); //benton, OR
|
|
|
|
//countiesToTie.push("84037"); //clackamas, OR
|
|
|
|
//tieCounty(getCountyInfo(countiesToTie[0].id);
|
|
|
|
var countiesToTie = []; |
|
|
|
countiesToTie.push("84034"); //cascade, MT
|
|
|
|
|
|
|
|
var countiesToWatch = []; |
|
|
|
//countiesToWatch.push("84038"); //benton, OR
|
|
|
|
countiesToWatch.push("84037"); //clackamas, OR
|
|
|
|
|
|
|
|
let newStats = []; |
|
|
|
|
|
|
|
let okToSaveChanges = true; |
|
|
|
let countiesToWinCount = countiesToWin.length; |
|
|
|
for(var i = 0; i < countiesToWinCount; i++) { |
|
|
|
for(let i = 0; i < countiesToWinCount; i++) { |
|
|
|
let currentEntity = getCountyInfo(countiesToWin[i]) |
|
|
|
winCounty(currentEntity,okToSaveChanges); |
|
|
|
newStats.push(currentEntity); |
|
|
|
} |
|
|
|
|
|
|
|
okToSaveChanges = true; |
|
|
|
let countiesToTieCount = countiesToTie.length; |
|
|
|
for(let i = 0; i < countiesToTieCount; i++) { |
|
|
|
let currentEntity = getCountyInfo(countiesToTie[i]) |
|
|
|
tieCounty(currentEntity,okToSaveChanges); |
|
|
|
newStats.push(currentEntity); |
|
|
|
} |
|
|
|
|
|
|
|
okToSaveChanges = false; |
|
|
|
let countiesToWatchCount = countiesToWatch.length; |
|
|
|
for(let i = 0; i < countiesToWatchCount; i++) { |
|
|
|
let currentEntity = getCountyInfo(countiesToWatch[i]) |
|
|
|
tieCounty(currentEntity,okToSaveChanges); |
|
|
|
newStats.push(currentEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//console.log("Saving county info stats");
|
|
|
|
const countyInfoStats = saveCountyInfoStats(newStats); |
|
|
|
|
|
|
|
//Refresh the page when we are suposed to
|
|
|
|
let interval = setInterval(reload, secondsBetweenReloads*1000); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|