1 2var calc_utilities = { 3 format_currency: function (num) { 4 num = Math.round(num * 100) / 100; 5 return num; 6 }, 7 8 format_percentage: function (num) { 9 num = num * 100; 10 return num; 11 }, 12 13 format_pct2decimal: function (num) { 14 num = num.replace(/\%/, ''); 15 return num / 100; 16 }, 17 18 validate_input: function (elem, options) { 19 var inputvalue = elem.trim(); 20 inputvalue = inputvalue.replace(/\$|,|\%/g, ""); 21 if (typeof options.maxNum !== 'undefined' && parseInt(inputvalue) > options.maxNum) { 22 inputvalue = options.maxNum; 23 } 24 if (typeof options.minNum !== 'undefined' && parseInt(inputvalue) < options.minNum) { 25 inputvalue = options.minNum; 26 } 27 return this.process_input(inputvalue, options); 28 }, 29 30 process_input: function (num, options) { 31 "use strict"; 32 var sign, decimals, dec_precision = 0, missingdecplaces = 0, retVal, n, i; 33 var num = num.toString().replace(/\$|\,|\%/g, ''); 34 options = (typeof options !== 'undefined') ? options : {}; 35 dec_precision = (typeof options.precision !== 'undefined') ? options.precision : dec_precision; 36 if (isNaN(num)) { 37 num = "0.00"; 38 } 39 sign = (num == (num = Math.abs(num))); 40 num = Math.floor(num * Math.pow(10, dec_precision) + 0.50000000001); 41 decimals = num % Math.pow(10, dec_precision); 42 decimals = (decimals == '0') ? "" : decimals; 43 num = Math.floor(num / Math.pow(10, dec_precision)).toString(); 44 missingdecplaces = (dec_precision - decimals.toString().length); 45 for (n = 0; n < missingdecplaces; n++) { 46 decimals = "0" + decimals; 47 } 48 for (i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { 49 num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3)); 50 } 51 retVal = num; 52 if (typeof options.showdollarsign !== 'undefined' && true === options.showdollarsign) { 53 retVal = '$' + retVal; 54 } 55 retVal = (((sign) ? '' : '-') + retVal + ((decimals > 0 || dec_precision > 0) ? '.' + decimals : '')); 56 if (typeof options.showprecentagesign !== 'undefined' && true === options.showprecentagesign) { 57 retVal = retVal + '%'; 58 } 59 return retVal; 60 }, 61 62 check_term: function (elem) { 63 var inputvalue = elem.trim(); 64 inputvalue = inputvalue.replace(/\$|,|\%/g, ""); 65 inputvalue = parseInt(inputvalue); 66 return this.sanitize_num(inputvalue); 67 }, 68 69 sanitize_num: function (num) { 70 "use strict"; 71 num = num.toString().replace(/\$|\,|\%/g, ''); 72 if (isNaN(num)) { 73 num = 0; 74 } 75 return num; 76 }, 77 78 getChar: function (event) { 79 if (event.which === null) { 80 return String.fromCharCode(event.keyCode); 81 } else if (event.which !== 0 && event.charCode !== 0) { 82 return String.fromCharCode(event.which); 83 } else { 84 return null; 85 } 86 } 87};
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.