Add formatting to counter updates

This commit is contained in:
Igor Babuschkin
2014-08-03 13:50:52 +02:00
parent dd683239d8
commit 2dff44d8e6
2 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -55,7 +55,7 @@
<div class="update-value" id="update-reputation"></div>
</div>
<div class="col-xs-4">
<strong class="text-center">Funding</strong>
<span class="text-center"><strong>Funding</strong></span>
<br>
{{ lc.lab.money | currency }}
<div class="update-value" id="update-funding"></div>
+11 -8
View File
@@ -33,21 +33,21 @@
getGrant: function () {
var addition = this.reputation * this.factor.rate; // TODO: adjust factor
this.money += addition;
showUpdateValue("#update-funding", addition);
showUpdateValue("#update-funding", formatNiceNumber(addition));
achievements.update('count', 'money', addition);
},
acquire: function(amount) {
this.data += amount;
achievements.update('count', 'data', amount);
showUpdateValue("#update-data", amount);
showUpdateValue("#update-data", formatNiceNumber(amount));
},
research: function(cost, reputation) {
if (this.data >= cost) {
this.data -= cost;
this.reputation += reputation;
achievements.update('count', 'reputation', reputation);
showUpdateValue("#update-data", -cost);
showUpdateValue("#update-reputation", reputation);
showUpdateValue("#update-data", formatNiceNumber(-cost));
showUpdateValue("#update-reputation", formatNiceNumber(reputation));
return true;
}
return false;
@@ -55,7 +55,7 @@
buy: function(cost) {
if (this.money >= cost) {
this.money -= cost;
showUpdateValue("#update-funding", -cost);
showUpdateValue("#update-funding", formatNiceNumber(-cost));
return true;
}
return false;
@@ -177,8 +177,8 @@
};
}]);
app.filter('niceNumber', ['$filter', function($filter) {
return function(number) {
function formatNiceNumber(number) {
var abs = Math.abs(number);
if (abs >= Math.pow(10, 12)) {
number = (number / Math.pow(10, 12)).toFixed(1) + "T";
@@ -192,7 +192,10 @@
number = number.toFixed(0);
}
return number;
};
}
app.filter('niceNumber', ['$filter', function($filter) {
return formatNiceNumber;
}]);
app.controller('DetectorController', function() {