Browse Source

update balance when buying items via javascript. fixes #10

Konrad Mohrfeldt 9 years ago
parent
commit
9b18c4508e
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      k4ever/media/js/k4ever.js

+ 9
- 1
k4ever/media/js/k4ever.js View File

@@ -25,6 +25,13 @@ jQuery(document).ready(function($) {
25 25
 		}, options), callback);
26 26
 	};
27 27
 
28
+	var updateBalance = function(newBalance) {
29
+		var balanceString = $("span.balance").text().split(": ");
30
+		balanceString[1] = parseFloat(newBalance).toFixed(2).replace(".", ",") + " €";
31
+
32
+		$("span.balance").text(balanceString.join(": "));
33
+	}
34
+
28 35
 	$.extend($.gritter.options, {
29 36
 		position: "bottom-right",
30 37
 		fade_in_speed: 250,
@@ -61,6 +68,7 @@ jQuery(document).ready(function($) {
61 68
 			});
62 69
 
63 70
 			dataContainer.children().removeClass("locked");
71
+			updateBalance(data.balance);
64 72
 		}, options);
65 73
 	});
66 74
 
@@ -121,7 +129,7 @@ jQuery(document).ready(function($) {
121 129
 
122 130
 						if(status === "success") {
123 131
 							selected_item.addClass("success");
124
-							//TODO neuer kontostand wär schnaffte
132
+							updateBalance(data.balance);
125 133
 						} else {
126 134
 							selected_item.addClass("failure");
127 135
 						}

Loading…
Cancel
Save