MediaWiki:Gadget-fa-bid-calculator.js: Difference between revisions

Show component points beside each input
Drop add-a-year, 35 or older, copy on new-topic click
Line 68: Line 68:
link.target = '_blank';
link.target = '_blank';
link.rel = 'noopener';
link.rel = 'noopener';
link.textContent = 'Start a new topic in NBA: Free Agency';
link.textContent = 'Copy and start a new topic in NBA: Free Agency';
// IPB has no parameter for seeding the post body, so the next best thing
// is to put it on the clipboard on the way out.
link.addEventListener( 'click', function () {
if ( navigator.clipboard && navigator.clipboard.writeText ) {
navigator.clipboard.writeText( text );
}
} );
actions.appendChild( link );
actions.appendChild( link );


Line 147: Line 154:
salaryPts.className = 'tc-calc-inline';
salaryPts.className = 'tc-calc-inline';
row( 'Salary', salary ).appendChild( salaryPts );
row( 'Salary', salary ).appendChild( salaryPts );
var ageRow = row( 'Player is 35 or over', age35 );
var ageRow = row( 'Player is 35 or older', age35 );
ageRow.querySelector( 'label' ).style.fontWeight = 'normal';
ageRow.querySelector( 'label' ).style.fontWeight = 'normal';
row( 'Bid to beat (optional)', beat );
row( 'Bid to beat (optional)', beat );
Line 191: Line 198:
if ( y > max ) {
if ( y > max ) {
problems.push( 'Maximum length is ' + max + ' years' +
problems.push( 'Maximum length is ' + max + ' years' +
( age35.checked ? ' for a player 35 or over' : '' ) + '.' );
( age35.checked ? ' for a player 35 or older' : '' ) + '.' );
}
}
if ( problems.length ) {
if ( problems.length ) {
Line 216: Line 223:
newSalary += MIN_RAISE;
newSalary += MIN_RAISE;
}
}
var lines = [
box.textContent = 'To beat ' + pts( target ) + ' points at ' + y +
'To beat ' + pts( target ) + ' points at ' + y +
( y === 1 ? ' year' : ' years' ) + ': ' + money( newSalary ) +
( y === 1 ? ' year' : ' years' ) + ': ' + money( newSalary ) +
' (' + pts( points( y, newSalary ) ) + ' points).'
' (' + pts( points( y, newSalary ) ) + ' points).';
];
if ( y < max ) {
var extraYear = points( y + 1, s );
lines.push( 'Or add a year: ' + ( y + 1 ) + ' years at ' + money( s ) +
' = ' + pts( extraYear ) + ' points' +
( extraYear > target ? '.' : ' — still short.' ) );
}
box.textContent = lines.join( ' ' );
}
}
out.appendChild( box );
out.appendChild( box );