Skip to content

Commit

Permalink
Added a displayRemaining property which will show the difference betw…
Browse files Browse the repository at this point in the history
…een value and max (useful if you're more interested in how much is left, rather than how much has been used.
  • Loading branch information
doofusdavid committed Mar 2, 2017
1 parent 36a3149 commit 904654b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ JustGage = function(config) {

// pointerOptions : object
// define pointer look
pointerOptions: kvLookup('pointerOptions', config, dataset, [])
pointerOptions: kvLookup('pointerOptions', config, dataset, []),

// displayRemaining: boolean
// replace display number with the number remaining to reach max
displayRemaining: kvLookup('displayRemaining', config, dataset, false)
};

// variables
Expand Down Expand Up @@ -703,7 +707,9 @@ JustGage = function(config) {
obj.originalValue = humanFriendlyNumber(obj.originalValue, obj.config.humanFriendlyDecimal) + obj.config.symbol;
} else if (obj.config.formatNumber) {
obj.originalValue = formatNumber(obj.originalValue) + obj.config.symbol;
} else {
} else if(obj.config.displayRemaining) {
obj.originalValue = ((obj.config.max - obj.originalValue) * 1).toFixed(obj.config.decimals) + obj.config.symbol;
} else {
obj.originalValue = (obj.originalValue * 1).toFixed(obj.config.decimals) + obj.config.symbol;
}

Expand Down

0 comments on commit 904654b

Please sign in to comment.