Skip to content

Instantly share code, notes, and snippets.

@hzlzh
Created December 2, 2011 02:52
Show Gist options
  • Save hzlzh/1421494 to your computer and use it in GitHub Desktop.
Save hzlzh/1421494 to your computer and use it in GitHub Desktop.
Discount function of TextMate
pluralise_licenses: function() {
var qty = Math.abs($("input_quantity").value);
if (qty == 1) {
$("license_pluralism").innerHTML = 'license (' + this.price(39) + ')'
} else if (qty > 1) {
var discount = 0;
if (qty >= 15) { discount = 30 }
else if (qty >= 10) { discount = 25 }
else if (qty >= 4) { discount = 20 }
var eur = Math.round(qty * 39 * (100 - discount) / 100);
$("license_pluralism").innerHTML = 'licenses (' + this.price(eur) + ')'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment