comparison app/model/Messwert.js @ 1095:14c130767e44

Backout accidentally commited changes from rev 9a0f7712f366.
author Tom Gottfried <tom@intevation.de>
date Tue, 10 May 2016 15:30:11 +0200
parents 9a0f7712f366
children b73f9a976c82
comparison
equal deleted inserted replaced
1094:677fc5e62055 1095:14c130767e44
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(',') > 0) { 45 if (valueString.indexOf('E') > 0) {
46 valueString.replace(',', '.'); 46 valueString = valueString.replace('E', 'e');
47 } 47 }
48 return parseFloat(valueString).toExponential(2).toString() 48 var tmp;
49 .replace('.', ','); 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 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];
50 } 76 }
51 }, { 77 }, {
52 name: 'messwertNwg', 78 name: 'messwertNwg',
53 convert: function(v) { 79 convert: function(v) {
54 if (!v) { 80 if (!v) {

http://lada.wald.intevation.org