Skip to content

Instantly share code, notes, and snippets.

@cwise
Created October 20, 2011 19:18
Show Gist options
  • Save cwise/1302030 to your computer and use it in GitHub Desktop.
Save cwise/1302030 to your computer and use it in GitHub Desktop.
Calculate for recommendation
var calculate = function ($) {
var revenue=$('#revenue').val();
var margin = 0.3;
var profit1=(revenue * margin) - (revenue * 0.15);
var profit2=(revenue * margin) - (revenue * 0.05 + 100);
var profit3=(revenue * margin) - (revenue * 0.01 + 250);
$('#profit1').text(profit1);
$('#fee1').text(revenue * 0.15);
$('#profit2').text(profit2);
$('#fee2').text(revenue * 0.05 + 100);
$('#profit3').text(profit3);
$('#fee3').text(revenue * 0.01 + 250);
$('#profit1, #fee1, #profit2, #fee2, #profit3, #fee3').formatCurrency();
$('#rec1, #rec2, #rec3, #rec4').removeClass('winner');
bestValue=(profit1 > profit2) ? (profit1 > profit3 ? '#rec1' : '#rec3') : (profit2 > profit3 ? '#rec2' : '#rec3')
if(revenue >= 10000)
bestValue='#rec4';
$(bestValue).addClass('winner');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment