comparison app/model/Zusatzwert.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 f73ca04d73a7
children 7fa853864d9b
comparison
equal deleted inserted replaced
1052:d2165ba7e8f1 1054:7e801af49eeb
25 name: 'probeId' 25 name: 'probeId'
26 }, { 26 }, {
27 name: 'pzsId' 27 name: 'pzsId'
28 }, { 28 }, {
29 name: 'nwgZuMesswert', 29 name: 'nwgZuMesswert',
30 type: 'float' 30 serialize: function(v) {
31 if (v.indexOf(',') > 0) {
32 v = v.replace(',', '.');
33 return v;
34 }
35 return v;
36 },
37 convert: function(value) {
38 if (!value || value === '') {
39 return value;
40 }
41 var valueString = value.toString();
42 if (valueString.indexOf('E') > 0) {
43 valueString = valueString.replace('E', 'e');
44 }
45 var tmp;
46 if (valueString.indexOf('e') > 0) {
47 tmp = valueString;
48 }
49 else {
50 // Currently not locale friendly...
51 if (valueString.indexOf(',') > 0) {
52 valueString = valueString.replace(',', '.');
53 }
54 tmp = parseFloat(valueString).toExponential();
55 }
56 var parts = tmp.split('e');
57 if (parts[0].indexOf('.') > 0) {
58 var floatPart = parseFloat(parts[0]);
59 parts[0] = floatPart.toLocaleString();
60 }
61 return parts[0] + 'e' + parts[1];
62 }
31 }, { 63 }, {
32 name: 'messwertPzs', 64 name: 'messwertPzs',
33 type: 'float' 65 serialize: function(v) {
66 if (v.indexOf(',') > 0) {
67 v = v.replace(',', '.');
68 return v;
69 }
70 return v;
71 },
72 convert: function(value) {
73 if (!value || value === '') {
74 return value;
75 }
76 var valueString = value.toString();
77 if (valueString.indexOf('E') > 0) {
78 valueString = valueString.replace('E', 'e');
79 }
80 var tmp;
81 if (valueString.indexOf('e') > 0) {
82 tmp = valueString;
83 }
84 else {
85 // Currently not locale friendly...
86 if (valueString.indexOf(',') > 0) {
87 valueString = valueString.replace(',', '.');
88 }
89 tmp = parseFloat(valueString).toExponential();
90 }
91 var parts = tmp.split('e');
92 if (parts[0].indexOf('.') > 0) {
93 var floatPart = parseFloat(parts[0]);
94 parts[0] = floatPart.toLocaleString();
95 }
96 return parts[0] + 'e' + parts[1];
97 }
34 }, { 98 }, {
35 name: 'messfehler', 99 name: 'messfehler',
36 type: 'float' 100 type: 'float'
37 }, { 101 }, {
38 name: 'letzteAenderung', 102 name: 'letzteAenderung',

http://lada.wald.intevation.org