PageSourceSearch

https://dizel55.ru/engine/public/templates/default/validate/script.js

js dizel55.ru collected 2026-10-09 22:43:41 UTC 3,604 bytes, 94 lines download raw bytes

1var phoneValid = {};
2
3/**
4 * @returns {*|jQuery|string}
5 */
6phoneValid.getPhoneValues = function () {
7    let item = $('body').find("input[name=phone]");
8    if ($("form[data-form-name=admin-settings]").length === 0) {
9        return item;
10    }
11    return '';
12}
13
14
15phoneValid.set = function () {
16    if (typeof window.$jscomp === "undefined") {
17        phoneValid.setHead();
18    }
19    //let mask = '+7 (999) 999-99-99';
20    let status = window.statusPhone;
21    if (status !== '1') {
22        return;
23    }
24    mask = window.pMask;
25    $(phoneValid.getPhoneValues()).mask(mask.toString());
26    //для удаления первой 8 или 7 если пытаються вводить телефон с кодом страны
27    //Больше нен нужно
28    /*$(phoneValid.getPhoneValues()).keydown(function (event) {
29        let val = phoneValid.getPhoneValues().val().replace(/_|-|\)| |\(|\+7 |/g, '');
30        let key = event.key;
31        if ((val === '8' && (key === '9' || key === '8')) || (val === '7' && key === '9')) {
32            $(phoneValid.getPhoneValues()).mask(mask.toString());
33            //phoneValid.getPhoneValues().setCursorPosition(4);
34        }
35    })*/
36    //Если вводится 12-я цифра, и цифра после +7 указана 7 или 8, то нужно всю последовательность просто сдвинуть влево и вписать последнюю цифру 11-й
37    $(phoneValid.getPhoneValues()).keydown(function (event) {
38        let val = phoneValid.getPhoneValues().val().replace(/_|-|\)| |\(|\+7 |/g, '');
39        if(val.length === 10 && (val[0] === '7' || val[0] === '8')){
40            let key = event.key;
41            if($.isNumeric(key)){
42                $('body').find("input[name=phone]").val(window.pMask.substring(0, 2) + ' (' +  val.substring(1, 4) + ') ' + val.substring(4,7) + '-' + val.substring(7,9) + '-' + val.substring(9,10) + key)
43            }
44        }
45    });
46
47    //Возвращение курсора в начало
48    $(phoneValid.getPhoneValues()).click(function () {
49        if($(this).val().replace(/_|-|\)| |\(|\+7 |/g, '') === ''){
50            $(this).setCursorPosition(4);
51        }
52
53    });
54    $(phoneValid.getPhoneValues()).attr('placeholder', mask.substring(0, 2) + ' (___) ___-__-__');
55    $(phoneValid.getPhoneValues()).attr("minlength", 18);
56    //Обработка при вводе из буфера
57    phoneValid.getPhoneValues().on('paste', function (event) {
58        event.preventDefault();
59        var data = event.originalEvent.clipboardData.getData('text');
60        data = data.replace(/\+/g, '');
61        data = data.replace(/[^+\d]/g, '');
62        if (data.length > 10) {
63            data = data.substring(1, 11);
64            //добавляем в начало 7 которую сьест маска
65            data = '7' + data;
66        }
67        phoneValid.getPhoneValues().val(data)
68    })
69
70}
71
72phoneValid.setHead = function () {
73}
74
75//выставить курсор в нужоную позицию в строке
76$.fn.setCursorPosition = function (pos) {
77    if ($(this).get(0).setSelectionRange) {
78        $(this).get(0).setSelectionRange(pos, pos);
79    } else if ($(this).get(0).createTextRange) {
80        var range = $(this).get(0).createTextRange();
81        range.collapse(true);
82        range.moveEnd('character', pos);
83        range.moveStart('character', pos);
84        range.select();
85    }
86};
87
88$(document).ready(function ($) {
89    if (phoneValid.getPhoneValues().length !== 0) {
90        phoneValid.set();
91    }
92});
93
94window.phoneValid = phoneValid;

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.