Mercurial > lada > lada-client
comparison app/model/Messwert.js @ 1069:1d20cec263ee
Fixed exponential number format.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 31 Mar 2016 11:44:03 +0200 |
parents | 7fa853864d9b |
children | 9a0f7712f366 |
comparison
equal
deleted
inserted
replaced
1068:096d552508cd | 1069:1d20cec263ee |
---|---|
57 tmp = parseFloat(valueString).toExponential(); | 57 tmp = parseFloat(valueString).toExponential(); |
58 } | 58 } |
59 var parts = tmp.split('e'); | 59 var parts = tmp.split('e'); |
60 if (parts[0].indexOf('.') > 0) { | 60 if (parts[0].indexOf('.') > 0) { |
61 var floatPart = parseFloat(parts[0]); | 61 var floatPart = parseFloat(parts[0]); |
62 var separator = floatPart.toLocaleString().replace(/[-\d]/g, ''); | 62 var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, ''); |
63 parts[0] = floatPart.toFixed(3).replace('.', separator); | 63 parts[0] = floatPart.toFixed(2).replace('.', separator); |
64 } | |
65 else if (parts[0].indexOf(',') < 0) { | |
66 parts[0] = parts[0] + ',00'; | |
67 } | |
68 var intPart = parseInt(parts[1]); | |
69 if (intPart < 10 && intPart >= 0) { | |
70 parts[1] = '+0' + parseInt(parts[1]); | |
71 } | |
72 else if (intPart < 0 && intPart > -10) { | |
73 parts[1] = parts[1].replace('-', '-0'); | |
64 } | 74 } |
65 return parts[0] + 'e' + parts[1]; | 75 return parts[0] + 'e' + parts[1]; |
66 } | 76 } |
67 }, { | 77 }, { |
68 name: 'messwertNwg', | 78 name: 'messwertNwg', |
108 tmp = parseFloat(valueString).toExponential(); | 118 tmp = parseFloat(valueString).toExponential(); |
109 } | 119 } |
110 var parts = tmp.split('e'); | 120 var parts = tmp.split('e'); |
111 if (parts[0].indexOf('.') > 0) { | 121 if (parts[0].indexOf('.') > 0) { |
112 var floatPart = parseFloat(parts[0]); | 122 var floatPart = parseFloat(parts[0]); |
113 parts[0] = floatPart.toLocaleString(); | 123 var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, ''); |
124 parts[0] = floatPart.toFixed(2).replace('.', separator); | |
125 } | |
126 else if (parts[0].indexOf(',') < 0) { | |
127 parts[0] = parts[0] + ',00'; | |
128 } | |
129 var intPart = parseInt(parts[1]); | |
130 if (intPart < 10 && intPart >= 0) { | |
131 parts[1] = '+0' + parseInt(parts[1]); | |
132 } | |
133 else if (intPart < 0 && intPart > -10) { | |
134 parts[1] = parts[1].replace('-', '-0'); | |
114 } | 135 } |
115 return parts[0] + 'e' + parts[1]; | 136 return parts[0] + 'e' + parts[1]; |
116 } | 137 } |
117 }, { | 138 }, { |
118 name: 'mehId' | 139 name: 'mehId' |