Skip to content
Browse files

ajax

  • Loading branch information...
1 parent 96e4bb0 commit 4b9579c84dc0344ccab2a5a4118b4e00928d888a Andrew Pennebaker committed Apr 16, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 public/ajax.js
View
10 public/ajax.js
@@ -27,7 +27,7 @@ function urlLowPrice(name, edition) {
return "/api.json?name=" + name.replace(/\s/g, "+") + "&edition=" + edition;
}
-function showPrice(name, edition, trader) {
+function showPrice(name, edition, quantity, trader) {
$.ajax({
type: "GET",
timeout: timeout,
@@ -47,7 +47,7 @@ function showPrice(name, edition, trader) {
cumulativePriceA = NaN;
}
else {
- cumulativePriceA += lowPrice;
+ cumulativePriceA += quantity * lowPrice;
message = "Total: $" + cumulativePriceA.toFixed(2);
}
@@ -61,7 +61,7 @@ function showPrice(name, edition, trader) {
cumulativePriceB = NaN;
}
else {
- cumulativePriceB += lowPrice;
+ cumulativePriceB += quantity * lowPrice;
message = "Total: $" + cumulativePriceB.toFixed(2);
}
@@ -83,9 +83,7 @@ function addPrices(cards, trader) {
var name = cards[i].name;
var edition = cards[i].edition;
- for (var j = 0; j < quantity; j++) {
- showPrice(name, edition, trader);
- }
+ showPrice(name, edition, quantity, trader);
}
}

0 comments on commit 4b9579c

Please sign in to comment.
Something went wrong with that request. Please try again.