Created
October 20, 2011 19:18
-
-
Save cwise/1302030 to your computer and use it in GitHub Desktop.
Calculate for recommendation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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