1(function (window, document, $, tcg) { 2 tcg.ac.easyNumberSeparator = (config) => { 3 // Currency Separator 4 const obj = { 5 selector: config.selector || ".number-separator", 6 separator: config.separator || ",", 7 decimalSeparator: config.decimalSeparator || ".", 8 resultInput: config.resultInput, 9 decimal: config.decimal || true, 10 }; 11 function numberSeparator(val) { 12 if (!val) { 13 return ""; 14 } 15 let num = val; 16 const dot = tcg.ac.getDecimalSeparator(); 17 const endWithDecimal = num && num.endsWith(dot); 18 const parseNum = tcg.ac.parseFormatNumber(num); 19 const decimalLength = Math.min(2, `${num}`.split(dot)[1]?.length) || 0; 20 const decimal = obj.decimal ? decimalLength : 0; 21 const value = tcg.ac.currencyFormat(parseNum, decimal); 22 const regex = /^([^,]*,){2}[^,]*$/; 23 const singleComma = !regex.test(val); 24 num = val === "-" ? null : value + (endWithDecimal && singleComma ? dot : ""); 25 26 return num; 27 } 28 29 function listenFields() { 30 $(obj.selector).on("input", function (e) { 31 this.value = numberSeparator(this.value);
32 this.setAttribute("formatAmount", tcg.ac.parseFormatNumber(this.value)); 33 }); 34 } 35 36 listenFields(); 37 }; 38})(window, document, jQuery, window.tcg || {});
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.