Skip to content

Commit

Permalink
Merge pull request #18 from bward222/fixed_calc
Browse files Browse the repository at this point in the history
add calc changes
  • Loading branch information
tobarja committed May 11, 2015
2 parents ccfbf45 + 5e41a9d commit a1ccfb1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions html/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(document).ready(function(){
var redeemed = "redeem";

$.post("/freebies/calculateAdd", {updatenum: text, customerid: custid, redeem: redeemed}, function(data){
$("#systemPoints").html(data).show();
$("#customerPoints").html(data).show();
console.log(data);
$("#summary").html($("#summary").html()+"+10 (undo)<br/>");
}) //end post
Expand All @@ -21,7 +21,7 @@ $(document).ready(function(){
if( parseInt($("#systemPoints").text()) > 9 )
{
$.post("/freebies/calculateSubtract", {updatenum: text, customerid: custid, redeem: redeemed}, function(data){
$("#systemPoints").html(data).show();
$("#customerPoints").html(data).show();
console.log(data);
$("#summary").html($("#summary").html()+"-10 (redeem)<br/>");

Expand Down Expand Up @@ -85,7 +85,7 @@ $(document).ready(function(){
currentDisplay = parseInt(currentDisplay);

// get the current points
var oldPoints = $("#systemPoints").text();
var oldPoints = $("#customerPoints").text();

// had to set this to 0 to get around NAN if no value exists
if (oldPoints == "")
Expand All @@ -105,12 +105,12 @@ $(document).ready(function(){
if ( currentDisplay > 0 )
{

$("#summary").html($("#summary").html()+"+"+points+"<br/>");
$("#summary").html($("#summary").html()+"+"+currentDisplay+"<br/>");
var custid = $("#customerid").val();
var redeemed = "not";

$.post("/freebies/calculateAdd", {updatenum: currentDisplay, customerid: custid, redeem: redeemed}, function(data){
$("#systemPoints").html(data).show();
$("#customerPoints").html(data).show();
console.log(data);
});

Expand Down Expand Up @@ -144,7 +144,7 @@ $(document).ready(function(){
// converst oldPoints to INT in case it isn't already
oldPoints = parseInt(oldPoints);

if (currentDisplay > parseInt($("#systemPoints").text()))
if (currentDisplay > parseInt($("#customerPoints").text()))
{
alert("You can't take away more points than the customer has.");
}
Expand All @@ -158,13 +158,13 @@ $(document).ready(function(){

if ( currentDisplay > 0)
{
$("#summary").html($("#summary").html()+"-"+points+"<br/>");
$("#summary").html($("#summary").html()+"-"+currentDisplay+"<br/>");

var custid = $("#customerid").val();
var redeemed = "not";

$.post("/freebies/calculateSubtract", {updatenum: currentDisplay, customerid: custid, redeem: redeemed}, function(data){
$("#systemPoints").html(data).show();
$("#customerPoints").html(data).show();
console.log(data);
});
}
Expand Down

0 comments on commit a1ccfb1

Please sign in to comment.