PageSourceSearch

https://whale-app-6m5a4.ondigitalocean.app/currency.js

js whale-app-6m5a4.ondigitalocean.app collected 2026-10-03 14:54:24 UTC 2,006 bytes, 68 lines download raw bytes

1function easyNumberSeparator(config) {
2    // Currency Separator
3    let commaCounter = 10;
4  
5    const obj = {
6      selector: config.selector || ".number-separator",
7      separator: config.separator || ",",
8      decimalSeparator: config.decimalSeparator || ".",
9      resultInput: config.resultInput
10    }
11  
12    function numberSeparator(num) {
13      for (let i = 0; i < commaCounter; i++) {
14        num = num.replace(obj.separator, "");
15      }
16  
17      x = num.split(obj.decimalSeparator);
18      y = x[0];
19      z = x.length > 1 ? obj.decimalSeparator + x[1] : "";
20      let rgx = /(\d+)(\d{3})/;
21  
22      while (rgx.test(y)) {
23        y = y.replace(rgx, "$1" + obj.separator + "$2");
24      }
25      commaCounter++;
26  
27      if (obj.resultInput) {
28        const resInput = document.querySelector(obj.resultInput)
29  
30        if (resInput) {
31          resInput.value = num.replace(obj.separator, "")
32          resInput.value = num.replace(obj.decimalSeparator, ".")
33        }
34      }
35  
36      return y + z;
37    }
38  
39    function listenFields() {
40      document.querySelectorAll(obj.selector).forEach(function (el) {
41        el.addEventListener("input", function (e) {
42          const reg = new RegExp(
43            `^-?\\d*[${obj.separator}${obj.decimalSeparator}]?(\\d{0,3}${obj.separator})*(\\d{3}${obj.separator})?\\d{0,3}$`
44          );
45  
46          const key = e.data || this.value.substr(-1)
47  
48          if (reg.test(key)) {
49            e.target.value = numberSeparator(e.target.value);
50          } else {
51            e.target.value = e.target.value.substring(0, e.target.value.length - 1);
52            e.preventDefault();
53            return false;
54          }
55        });
56        el.value = numberSeparator(el.value);
57      });
58    }
59  
60    listenFields()
61  
62    // Fire separator when every element append to page
63    document.addEventListener("DOMNodeInserted", function (e) {
64      if ((e.target).classList.contains(obj.selector.replace('.', ''))) {
65        listenFields()
66      }
67    });
68  }

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.