1var rhte = function(placeToRound){ 2 var fixed = placeToRound.toString().split('.').length < 2 ? 0 : placeToRound.toString().split('.')[1].length, 3 numParts = { 4 mvDec : (this/placeToRound).toFixed(this.toString().length).toString().split('.'), 5 wholeNum: function(){return parseInt(this.mvDec[0],10);}, 6 dec: function(){return this.mvDec.length > 1 ? parseFloat('0.'+this.mvDec[1]) : 0;}, 7 oddEven: function(){return (this.wholeNum() % 2 === 1) ? 1 : 0;} 8 }; 9 10 if(numParts.dec() !== 0.5){ 11 return(numParts.dec() > 0.5) ? parseFloat(((numParts.wholeNum()+1)*placeToRound).toFixed(fixed)) : parseFloat((numParts.wholeNum()*placeToRound).toFixed(fixed)); 12 }else{ 13 if(numParts.oddEven() === 1){ 14 return parseFloat(((numParts.wholeNum()+1)*placeToRound).toFixed(fixed)); 15 }else{ 16 return parseFloat((numParts.wholeNum()*placeToRound).toFixed(fixed)); 17 } 18 } 19}; 20 21Number.prototype.rhte = rhte; 22String.prototype.rhte = rhte; 23 24// format numbers with commas and 2 decimals -> return - 25function formatDecimals(value) { 26 if (value !== undefined && value !== null) { 27 value = value.toFixed(10); 28 } 29 if (value === undefined) { 30 return 0; 31 } 32 if (value === null) { 33 return '-'; 34 }else{ 35 var absNum = Math.abs(value); 36 var rndNum = (absNum).rhte(0.01); 37 if (value < 0) { 38 return (rndNum * -1).toFixed(2).toString().replace(/(\d)(?=(\d\{3\})+\.)/g, '$1,'); 39 } 40 return (rndNum).toFixed(2).toString().replace(/(\d)(?=(\d\{3\})+\.)/g, '$1,'); 41 } 42} 43 44//set red or green class 45function alternateGreenRedClass(num) { 46 var classColor = ''; 47 if (num < 0) { 48 classColor = '--negative'; 49 } else if (num > 0) { 50 classColor = '--positive'; 51 } 52 return classColor; 53} 54 55function formatTimeDate(dateTime) { 56 moment.updateLocale('en', { 57 longDateFormat : { 58 LT: "h:mm A", 59 LLLL: "YYYY-MM-DD HH:mm a" 60 } 61 }); 62 moment.updateLocale('it', { 63 longDateFormat : { 64 LT: "h:mm A", 65 LLLL: "DD-MM-YYYY HH:mm" 66 } 67 }); 68 return moment(dateTime).locale(bit.init.lang).format('LLLL'); 69} 70 71function formatDate(dateTime) { 72 moment.updateLocale('en', { 73 longDateFormat : { 74 LLLL: "YY/MM/DD" 75 } 76 }); 77 moment.updateLocale('it', { 78 longDateFormat : { 79 LLLL: "DD/MM/YY" 80 } 81 }); 82 return moment(dateTime).locale(bit.init.lang).format('LLLL'); 83} 84 85 86function formatterNumber(value) { 87 var langFormatter = Globalize(bit.init.lang).numberFormatter(); 88 return langFormatter(value); 89} 90 91function formatNumberFourDecimals(value) { 92 if (value !== undefined && value !== null) { 93 value = value.toFixed(10); 94 } 95 if (value === undefined) { 96 return 0; 97 } 98 if (value === null) { 99 return '-'; 100 }else{ 101 var absNum = Math.abs(value); 102 var rndNum = (absNum).rhte(0.0001); 103 if (value < 0) { 104 return (rndNum * -1).toFixed(4).toString().replace(/(\d)(?=(\d\{5\})+\.)/g, '$1,'); 105 } 106 return (rndNum).toFixed(4).toString().replace(/(\d)(?=(\d\{5\})+\.)/g, '$1,'); 107 } 108} 109 110function loadGlobalizeJson() { 111 Globalize.load({ 112 "main": { 113 "en": { 114 "identity": { 115 "version": { 116 "_cldrVersion": "25", 117 "_number": "$Revision: 91 $" 118 }, 119 "generation": { 120 "_date": "$Date: 2014-03-13 22:27:12 -0500 (Thu, 13 Mar 2014) $" 121 }, 122 "language": "en" 123 }, 124 "numbers": { 125 "currencies": { 126 "USD": { 127 "symbol": "$" 128 } 129 }, 130 "defaultNumberingSystem": "latn", 131 "symbols-numberSystem-latn": { 132 "decimal": ".", 133 "exponential": "E", 134 "group": ",", 135 "infinity": "â", 136 "minusSign": "-", 137 "nan": "NaN", 138 "percentSign": "%", 139 "perMille": "â°", 140 "plusSign": "+", 141 "timeSeparator": ":" 142 }, 143 "decimalFormats-numberSystem-latn": { 144 "standard": "#,##0.###" 145 } 146 }, 147 }, 148 "it": { 149 "identity": { 150 "version": { 151 "_cldrVersion": "25", 152 "_number": "$Revision: 91 $" 153 }, 154 "language": "it" 155 }, 156 "numbers": { 157 "currencies": { 158 "USD": { 159 "symbol": "$" 160 } 161 }, 162 "defaultNumberingSystem": "latn", 163 "symbols-numberSystem-latn": { 164 "decimal": ",", 165 "exponential": "E", 166 "group": ".", 167 "infinity": "â", 168 "minusSign": "-", 169 "nan": "NaN", 170 "percentSign": "%", 171 "perMille": "â°", 172 "plusSign": "+", 173 "timeSeparator": ":" 174 }, 175 "decimalFormats-numberSystem-latn": { "standard": "#,##0.###" } 176 }, 177 } 178 }, 179 "supplemental": { 180 "version": { 181 "_cldrVersion": "25", 182 "_number": "$Revision: 91 $" 183 }, 184 "currencyData": { 185 "fractions": { 186 "DEFAULT": { 187 "_rounding": "0", 188 "_digits": "6" 189 } 190 } 191 }, 192 "likelySubtags": { 193 "en": "en-Latn-US", 194 "it": "it-Latn-I", 195 }, 196 "plurals-type-cardinal": {} 197 } 198 });
199} 200loadGlobalizeJson(); 201 202/* 203function parseGlobalize (val) { 204 loadGlobalizeJson(); 205 var formatter; 206 Globalize.locale( document.documentElement.lang ); 207 formatter = Globalize.numberFormatter(); 208 return formatter( val ); 209} 210*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.