Mercurial > lada > lada-client
comparison app/model/Messwert.js @ 1054:7e801af49eeb
Use exponential notation for messwerte and zusatzwerte.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 02 Mar 2016 12:59:15 +0100 |
parents | 23bfcbdb4527 |
children | 7fa853864d9b |
comparison
equal
deleted
inserted
replaced
1052:d2165ba7e8f1 | 1054:7e801af49eeb |
---|---|
25 name: 'messungsId' | 25 name: 'messungsId' |
26 }, { | 26 }, { |
27 name: 'messgroesseId' | 27 name: 'messgroesseId' |
28 }, { | 28 }, { |
29 name: 'messwert', | 29 name: 'messwert', |
30 type: 'float' | 30 serialize: function(v) { |
31 if (!v || v === '') { | |
32 return v; | |
33 } | |
34 if (v.indexOf(',') > 0) { | |
35 v = v.replace(',', '.'); | |
36 return v; | |
37 } | |
38 return v; | |
39 }, | |
40 convert: function(value) { | |
41 if (!value || value === '') { | |
42 return value; | |
43 } | |
44 var valueString = value.toString(); | |
45 if (valueString.indexOf('E') > 0) { | |
46 valueString = valueString.replace('E', 'e'); | |
47 } | |
48 var tmp; | |
49 if (valueString.indexOf('e') > 0) { | |
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 parts[0] = floatPart.toLocaleString(); | |
63 } | |
64 return parts[0] + 'e' + parts[1]; | |
65 } | |
31 }, { | 66 }, { |
32 name: 'messwertNwg', | 67 name: 'messwertNwg', |
33 convert: function(v) { | 68 convert: function(v) { |
34 if (!v) { | 69 if (!v) { |
35 return null; | 70 return null; |
40 }, { | 75 }, { |
41 name: 'messfehler', | 76 name: 'messfehler', |
42 type: 'float' | 77 type: 'float' |
43 }, { | 78 }, { |
44 name: 'nwgZuMesswert', | 79 name: 'nwgZuMesswert', |
45 type: 'float' | 80 serialize: function(v) { |
81 if (!v || v === '') { | |
82 return v; | |
83 } | |
84 if (v.indexOf(',') > 0) { | |
85 v = v.replace(',', '.'); | |
86 return v; | |
87 } | |
88 return v; | |
89 }, | |
90 convert: function(value) { | |
91 if (!value || value === '') { | |
92 return value; | |
93 } | |
94 var valueString = value.toString(); | |
95 if (valueString.indexOf('E') > 0) { | |
96 valueString = valueString.replace('E', 'e'); | |
97 } | |
98 var tmp; | |
99 if (valueString.indexOf('e') > 0) { | |
100 tmp = valueString; | |
101 } | |
102 else { | |
103 // Currently not locale friendly... | |
104 if (valueString.indexOf(',') > 0) { | |
105 valueString = valueString.replace(',', '.'); | |
106 } | |
107 tmp = parseFloat(valueString).toExponential(); | |
108 } | |
109 var parts = tmp.split('e'); | |
110 if (parts[0].indexOf('.') > 0) { | |
111 var floatPart = parseFloat(parts[0]); | |
112 parts[0] = floatPart.toLocaleString(); | |
113 } | |
114 return parts[0] + 'e' + parts[1]; | |
115 } | |
46 }, { | 116 }, { |
47 name: 'mehId' | 117 name: 'mehId' |
48 }, { | 118 }, { |
49 name: 'grenzwertueberschreitung', | 119 name: 'grenzwertueberschreitung', |
50 type: 'boolean' | 120 type: 'boolean' |