PageSourceSearch

https://fabretti.ru/local/templates/aspro-premier/js/conditional/input_numeric.js

js fabretti.ru collected 2026-10-09 21:30:08 UTC 1,261 bytes, 45 lines download raw bytes

1function input_numeric(selector, customRegExp) {
2  if (!selector) return;
3
4  try {
5    const nodes = Array.from(
6      document.querySelectorAll(selector),
7      node => node.nodeType === node.ELEMENT_NODE && node instanceof HTMLInputElement && node
8    );
9    nodes.forEach(eventsHandler);
10  } catch (e) {
11    console.error(e);
12  }
13
14  function eventsHandler(node) {
15    ["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop", "focusout"].forEach(
16      function (event) {
17        node.addEventListener(event, eventHandler);
18      }
19    );
20  }
21
22  function eventHandler(e) {
23    if (regexp.test(this.value)) {
24      this.oldValue = this.value;
25      this.oldSelectionStart = this.selectionStart;
26      this.oldSelectionEnd = this.selectionEnd;
27    } else if (this.oldValue) {
28      this.value = this.oldValue;
29      this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
30    } else {
31      // Rejected value - nothing to restore
32      const value = parseFloat(this.value)
33      if (!Number.isNaN(value)) {
34        this.value = value;
35      } else {
36        this.value = '';
37      }
38    }
39  }
40
41  let regexp = /^-?\d*[.,]?\d*$/;
42  if (customRegExp && customRegExp instanceof RegExp) {
43    regexp = customRegExp;
44  }
45}

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.