@ -386,6 +386,183 @@ function convertToOversightJson(countyInfoJson, action, isBidCapEnabled){
return countyInfo ;
}
function getBidCapReasonIcon ( reason ) {
switch ( reason ) {
case 1 :
return "🔀" ;
case 2 :
return "⏹" ;
case 3 :
return "🔼" ;
case 4 :
return "🔽" ;
default :
return "" ;
}
return "" ;
}
function getBidCapReason ( tieBid , myBid , oversightAction , rowCapIsEnabled , rowCap , generalCapIsEnabled , generalCap , capPresidence , applyPresidenceTo ) {
const Presidence_General = "general" ;
const Presidence_Row = "row" ;
const Presidence_Highest = "highest" ;
const Presidence_Lowest = "lowest" ;
const AppliesTo_All = "all" ;
const AppliesTo_None = "none" ;
const AppliesTo_Capped = "capped" ;
const AppliesTo_Uncapped = "uncapped" ;
const Oversight_Win = "win" ;
const Oversight_Tie = "tie" ;
const Oversight_Watch = "watch" ;
const Oversight_Ignore = "ignore" ;
const Capsource_Row = "row" ;
const Capsource_General = "general" ;
let tieBidNum = number ( tieBid ) ;
let winBidNum = number ( tieBid ) + 25 ;
let generalCapNum = number ( generalCap ) ;
let rowCapNum = number ( rowCap ) ;
let myBidNum = number ( myBid ) ;
//Build our response object
let bidCapData = { } ;
results . shouldApplyCap = false ; //Flag to indicate if the cap should be applied
results . reason = 0 ; //No Cap to start of with
results . trueCap = null ; //Default to no true cap
results . capSource = null ; //No caps applied
results . myBid = myBidNum ;
//WIP - LOTS of rules here - these are just the beginning.
if ( generalCapIsEnabled ) {
if ( capPresidence == Presidence_General ) {
if ( applyPresidenceTo == AppliesTo_All ) {
results . shouldApplyCap = false ;
results . capSource = Capsource_General ;
results . trueCap = generalCapNum ;
switch ( oversightAction ) {
case Oversight_Win :
if ( winBidNum > generalCapNum ) {
results . shouldApplyCap = true ;
results . reason = 1 ;
results . myBid = generalCapNum ;
return results ;
}
//winBidNum <= generalCapNum
results . reason = 2 ;
results . myBid = myBidNum ;
break ;
case Oversight_Tie :
if ( tieBidNum > generalCapNum ) {
results . shouldApplyCap = true ;
results . reason = 3 ;
results . myBid = generalCapNum ;
return results ;
}
//tieBidNum <= generalCapNum
results . reason = 4 ;
results . myBid = myBidNum ;
break ;
case Oversight_Watch :
results . reason = 5 ;
break ;
case Oversight_Ignore :
results . reason = 6 ;
break ;
default :
//We should never get here because all oversight actions have been covered.
}
return results ;
}
else if ( applyPresidenceTo == AppliesTo_None ) {
}
else if ( applyPresidenceTo == AppliesTo_Capped ) {
}
else if ( applyPresidenceTo == AppliesTo_Uncapped ) {
}
return results ;
}
else if ( capPresidence == Presidence_Row ) {
return results ;
}
else if ( capPresidence == Presidence_Highest ) {
return results ;
}
else if ( capPresidence == Presidence_Lowest ) {
return results ;
}
}
//If we made it here, generalCapIsEnabled is FALSE so no conflicts should exist
//This means rowCaps are the winners if they are enabled.
if ( rowCapIsEnabled ) {
switch ( oversightAction ) {
case Oversight_Win :
if ( winBidNum > rowCapNum ) {
results . shouldApplyCap = true ;
results . reason = 101 ;
results . trueCap = rowCapNum ;
results . capSource = Capsource_Row ;
results . myBid = rowCapNum ;
return results ;
}
//winBidNum <= rowCapNum
results . shouldApplyCap = false ;
results . reason = 102 ;
results . trueCap = rowCapNum ;
results . capSource = Capsource_Row ;
results . myBid = myBidNum ;
break ;
case Oversight_Tie :
if ( tieBidNum > rowCapNum ) {
results . shouldApplyCap = true ;
results . reason = 103 ;
results . trueCap = rowCapNum ;
results . capSource = Capsource_Row ;
results . myBid = rowCapNum ;
return results ;
}
//tieBidNum <= generalCapNum
results . shouldApplyCap = false ;
results . reason = 104 ;
results . trueCap = rowCapNum ;
results . capSource = Capsource_Row ;
results . myBid = myBidNum ;
break ;
case Oversight_Watch :
results . shouldApplyCap = false ;
results . reason = 105 ;
results . trueCap = null ;
results . capSource = Capsource_Row ;
results . myBid = myBidNum ;
break ;
case Oversight_Ignore :
results . shouldApplyCap = false ;
results . reason = 106 ;
results . trueCap = null ;
results . capSource = Capsource_Row ;
results . myBid = myBidNum ;
break ;
default :
//We should never get here because all oversight actions have been covered.
}
return results ;
}
//Caps are not enabled for this row.
return results ;
}
function injectOversight ( countyId , action ) {
countyId += "" ; //cast into string incase number was passed in
@ -475,7 +652,7 @@ function injectOversight(countyId, action) {
}
if ( capIsCurrentlyBeingAppliedToBid ) {
priceDivHtml += '🔀 bid is capped at '+ trueCap ;
priceDivHtml += getBidCapReasonIcon ( 1 ) + ' bid is capped at '+ trueCap ;
}
@ -512,7 +689,7 @@ jQuery(window).on('load',function() {
newHtml += '<label for="isGeneralCapEnabled"><input type="checkbox" name="isGeneralCapEnabled" ' + getCheckedValue ( "isGeneralCapEnabled" ) + '/>Don't bid more than</label> ' ;
newHtml += '<label for="generalCap">:</label><input id="generalCap" type="text" size="5" name="generalCap" value="' + generalCap + '"/> per county<br />' ;
newHtml += '<label for="capPresidence">If a rowCap is enabled the <select id="capPresidence" name="capPresidence" />' + getCapPresidenceOptions ( capPresidence ) + '</select> takes presidence</label><br/>' ;
newHtml += '<label for="capPresidence">If a row and general cap are enabled then <select id="capPresidence" name="capPresidence" />' + getCapPresidenceOptions ( capPresidence ) + '</select> takes presidence</label><br/>' ;
newHtml += '<div id="reloaderData"><div id="countdown"></div><progress value="0" max="100" id="progressBar" style="width: 100%;"></progress></div><div id="awLog" class="alwaysWinLog"></div>' ;
newHtml += '</div>' ;