Added spacing between values and units in the inventory

closes #44 closes #60
This commit is contained in:
Stefan Zermatten
2017-04-25 17:12:34 +02:00
parent b4649d8c87
commit 2a9d170647
4 changed files with 13 additions and 13 deletions

View File

@@ -10,13 +10,13 @@ Template.registerHelper("valueString", function(value) {
var resultArray = [];
if (gp > 0) {
resultArray.push(gp + "gp");
resultArray.push(gp + " gp");
}
if (sp > 0) {
resultArray.push(sp + "sp");
resultArray.push(sp + " sp");
}
if (cp > 0) {
resultArray.push(cp + "cp");
resultArray.push(cp + " cp");
}
//build string with correct spacing
@@ -36,18 +36,18 @@ Template.registerHelper("longValueString", function(value) {
//sp
var gp = Math.floor(value);
if (gp > 0) {
resultArray.push(gp + "gp");
resultArray.push(gp + " gp");
}
//sp
var sp = Math.floor(10 * (value % 1));
if (sp > 0 || resultArray.length) {
resultArray.push(sp + "sp");
resultArray.push(sp + " sp");
}
//cp
var cp = 10 * ((value * 10) % 1);
cp = Math.round(cp * 1000) / 1000;
if (cp > 0 || resultArray.length) {
resultArray.push(cp + "cp");
resultArray.push(cp + " cp");
}
//build string with correct spacing