MediaWiki:Gadget-fa-bid-calculator.js: Difference between revisions
Thousands separators in the salary field |
Bid to beat must clear the standing bid by 0.2 points |
||
| Line 11: | Line 11: | ||
var MIN_OFFER = 500000, | var MIN_OFFER = 500000, | ||
MIN_RAISE = 200000, | MIN_RAISE = 200000, | ||
MIN_RAISE_POINTS = 0.2, | |||
MAX_YEARS = 4, | MAX_YEARS = 4, | ||
MAX_YEARS_35 = 2, | MAX_YEARS_35 = 2, | ||
YEAR_POINTS = 1.5; | YEAR_POINTS = 1.5; | ||
function money( n ) { | function money( n ) { | ||
| Line 256: | Line 258: | ||
box.className = 'tc-calc-note'; | box.className = 'tc-calc-note'; | ||
if ( total > | // A bid must clear the standing one by at least MIN_RAISE_POINTS, so | ||
// the bar is target + 0.2, not merely more than target. Everything | |||
// here is counted in tenths of a point: 0.1 points is exactly | |||
// $100,000 and a year is exactly 15 tenths, so integer arithmetic | |||
// gets the answer that 0.2 + 2.0 in binary floating point does not. | |||
var requiredTenths = Math.round( target * 10 ) + ( MIN_RAISE_POINTS * 10 ); | |||
if ( Math.round( total * 10 ) >= requiredTenths ) { | |||
box.textContent = 'This already beats ' + pts( target ) + ' points.'; | box.textContent = 'This already beats ' + pts( target ) + ' points.'; | ||
} else { | } else { | ||
var salaryTenths = requiredTenths - y * ( YEAR_POINTS * 10 ), | |||
var | newSalary = Math.max( salaryTenths * 100000, MIN_OFFER ); | ||
box.textContent = 'To beat ' + pts( target ) + ' points at ' + y + | box.textContent = 'To beat ' + pts( target ) + ' points at ' + y + | ||
( y === 1 ? ' year' : ' years' ) + ': ' + money( newSalary ) + | ( y === 1 ? ' year' : ' years' ) + ': ' + money( newSalary ) + | ||