Mercurial > lada > lada-client
comparison app/model/Messwert.js @ 1091:9a0f7712f366
Fix error message.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 09 May 2016 15:35:51 +0200 |
parents | 1d20cec263ee |
children | 14c130767e44 |
comparison
equal
deleted
inserted
replaced
1090:fc17ae7e560c | 1091:9a0f7712f366 |
---|---|
40 convert: function(value) { | 40 convert: function(value) { |
41 if (!value || value === '') { | 41 if (!value || value === '') { |
42 return value; | 42 return value; |
43 } | 43 } |
44 var valueString = value.toString(); | 44 var valueString = value.toString(); |
45 if (valueString.indexOf('E') > 0) { | 45 if (valueString.indexOf(',') > 0) { |
46 valueString = valueString.replace('E', 'e'); | 46 valueString.replace(',', '.'); |
47 } | 47 } |
48 var tmp; | 48 return parseFloat(valueString).toExponential(2).toString() |
49 if (valueString.indexOf('e') > 0) { | 49 .replace('.', ','); |
50 tmp = valueString; | |
51 } | |
52 else { | |
53 // Currently not locale friendly... | |
54 if (valueString.indexOf(',') > 0) { | |
55 valueString = valueString.replace(',', '.'); | |
56 } | |
57 tmp = parseFloat(valueString).toExponential(); | |
58 } | |
59 var parts = tmp.split('e'); | |
60 if (parts[0].indexOf('.') > 0) { | |
61 var floatPart = parseFloat(parts[0]); | |
62 var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, ''); | |
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'); | |
74 } | |
75 return parts[0] + 'e' + parts[1]; | |
76 } | 50 } |
77 }, { | 51 }, { |
78 name: 'messwertNwg', | 52 name: 'messwertNwg', |
79 convert: function(v) { | 53 convert: function(v) { |
80 if (!v) { | 54 if (!v) { |