Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ cdapp.controller('CDCtrl', ['$scope', 'ChallengeService', '$sce', function($scop
});

chglo = challenge;
//Bugfix refactored-challenge-details-40: format currency values with comma delimiters
if (typeof challenge.reliabilityBonus === 'number') {
challenge.reliabilityBonus = challenge.reliabilityBonus.format();
}
//loop over prizes and format number values
for (var i = 0; i < challenge.prize.length; i++) {
challenge.prize[i] = challenge.prize[i].format();
}

$scope.challenge = challenge;
$scope.reliabilityBonus = challenge.reliabilityBonus;
$scope.siteURL = siteURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,14 @@ app.tabNavinit = function() {
}
})
}
//This function adds number formatting to JS number prototype
/**
* Number.prototype.format(n, x)
*
* @param integer n: length of decimal
* @param integer x: length of sections
*/
Number.prototype.format = function(n, x) {
var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
};