PageSourceSearch

https://barssport-factory.ru/modules/mod_feedback/feedback.js

js barssport-factory.ru collected 2026-10-08 13:57:40 UTC 8,400 bytes, 232 lines download raw bytes

1// функция проверки корректности e-mail адреса
2function isValidEmail(email, strict) {
3	if (!strict) email = email.replace(/^\s+|\s+$/g, '');
4	return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
5}
6
7function setFormActions(form) {
8
9	if ('datetimepicker' in $()) {
10		$('.input_date .datetime').datetimepicker({
11			timepicker: false,
12			lang: "ru",
13			format: "d.m.Y",
14			mask: false
15		});
16	}
17	$(".formid").removeClass("disable");
18	$('.input_file input[type="file"]').on('change', function (event, files, label) {
19		parent = $(this).closest(".input_file");
20		var file_name = this.value.replace(/\\/g, '/').replace(/.*\//, '')
21		$(parent).find('.file-name').text(file_name);
22	});
23
24	$.each($('.feedback_form input[name="url"]'), function () {
25		url = window.location.pathname;
26		$(this).val(url);
27	});
28
29	// модальные окна с формой
30	$('.form-modal').magnificPopup({
31		type: 'inline',
32		fixedContentPos: false,
33		fixedBgPos: true,
34		overflowY: 'auto',
35		closeBtnInside: true,
36		preloader: false,
37		midClick: true,
38		removalDelay: 300,
39		mainClass: 'my-mfp-slide-bottom',
40		callbacks: {
41			elementParse: function (item) {
42				$(".feedback .telefon").mask("+7(999) 999-99-99");
43				// записываем доп инфо
44				title = $(item.el).attr("data-title");
45				desc = $(item.el).attr("data-desc");
46				info = $(item.el).attr("data-info");
47				btn = $(item.el).attr("data-btn");
48				default_value = "";
49				$(item.src).find("input[name=info]").val(info);
50				if (title) {
51					$(item.src).find(".title").html(title);
52				} else {
53					// значение по умолчанию
54					default_value = $(item.src).find(".title").attr("data-default");
55					$(item.src).find(".title").html(default_value);
56				}
57
58				if (desc) {
59					$(item.src).find(".desc").html(desc);
60				} else {
61					// значение по умолчанию
62					default_value = $(item.src).find(".desc").attr("data-default");
63					$(item.src).find(".desc").html(default_value);
64				}
65
66				if (btn) {
67					$(item.src).find(".feedback_button .caption").html(btn);
68				} else {
69					// значение по умолчанию
70					default_value = $(item.src).find(".feedback_button .caption").attr("data-default");
71					$(item.src).find(".feedback_button .caption").html(default_value);
72				}
73
74				//возвращаем форму в исходное состояние
75				layer = $(item.src).closest(".feedback");
76				$(layer).find("form").css("display", "block");
77				$(layer).find(".title").css("display", "block");
78				$(layer).find(".desc").css("display", "block");
79				$(layer).find(".results .loading").css("display", "none");
80				$(layer).find(".results .result").css("display", "none");
81			}
82		}
83	});
84
85	// отправить сообщение
86	$(".feedback_button").unbind("click");
87	$('.feedback_button').on('click', function (btn) {
88		parent = $(this).closest("form");
89		$(parent).find(".err_msg").html("");
90		$(parent).find(".err_msg").css("display", "none");
91		$(parent).find(".input").removeClass("error");
92		error = 0;
93		$(parent).find(".input-box").each(function (i, elem) {
94			// проверка полей телефонов
95			if ($(this).hasClass("input_telefon")) {
96				telefon = $(this).find(".input").val();
97				if (telefon == "") {
98					$(this).find(".err_msg").html("Неверный формат телефона");
99					$(this).find(".err_msg").css("display", "table");
100					$(this).find(".input").addClass("error");
101					error = 1;
102				}
103			}			
104			// проверка полей обязательных для заполнения
105			if ($(this).hasClass("input_require")) // данное поле должно быть заполнено!
106			{
107				//console.log(elem);
108				if ($(this).find(".input").val() == "") {
109					$(this).find(".err_msg").html("Обязательно для заполнения");
110					$(this).find(".err_msg").css("display", "table");
111					$(this).find(".input").addClass("error");
112					error = 1;
113				}
114			}
115
116
117
118			// проверка полей email адресов
119			if ($(this).hasClass("input_email") && $(this).hasClass("input_require")) {
120				email = $(this).find(".input").val();
121				if (!isValidEmail(email)) {
122					$(this).find(".err_msg").html("Не верный формат E-mail");
123					$(this).find(".err_msg").css("display", "table");
124					$(this).find(".input").addClass("error");
125					error = 1;
126				}
127			}
128			// проверка поля сообщения
129			if ($(this).hasClass("input_text")) {
130				text = $(this).find("textarea").val();
131				if (text.indexOf("http:") >= 0 || text.indexOf("https:") >= 0 || text.indexOf("www") >= 0) {
132					$(this).find("label").append("<div class='err_msg'></div>");
133					$(this).find(".err_msg").html("Текст сообщения не может содержать ссылок!");
134					$(this).find(".err_msg").css("display", "table");
135					$(this).find(".input").addClass("error");
136					error = 1;
137				}
138			}
139		});
140		// if($(parent).find(".policy-checkbox").is(":not(:checked)")){
141		// 	$(parent).find(".formabout").addClass("error");
142		// 	error = 1;
143		// }		
144		//console.log("error:"+error);
145		if (!error) // отправить, если нет ошибок в заполнении формы
146		{
147			console.log("NO ERRORS");
148			//$(this).css("display","none");
149			layer = $(this).closest(".feedback");
150			$(layer).find("form").css("display", "none");
151			$(layer).find(".title").css("display", "none");
152			$(layer).find(".desc").css("display", "none");
153			$(layer).find(".results .loading").css("display", "block");
154			$(parent).find(".results .result").css("display", "none");
155			var form_action = $(parent).attr("action");
156			var formData = new FormData($(parent)[0]);
157			$(parent).find("input").each(function () {
158				if ($(this).attr('type') != 'file') {
159					if ($(this).attr('type') == 'checkbox' || $(this).attr('type') == 'radio') {
160						if ($(this).attr('checked')) formData.append($(this).attr('name'), $(this).val()); // помещаем все значения полей в объект
161					} else {
162						formData.append($(this).attr('name'), $(this).val()); // помещаем все значения полей в объект
163					}
164				}
165			});
166			//var form_data = $(parent).serialize();
167
168			if ($.cookie('feedback') == 'send') {
169				$.cookie('feedback', 'no');
170				setTimeout(()=>$.cookie('feedback', 'send'),1)
171				$.ajax({
172					type: "POST",
173					url: form_action,
174					data: formData,
175					contentType: false,
176					processData: false,
177					success: function (result) {
178						$(layer).find(".results .loading").css("display", "none");
179						$(layer).find(".results .result").css("display", "block");
180						$(layer).find(".results .result").html(result);// вывести сообщение
181						ym(41176789,'reachGoal','zayavka')
182						//yaCounter44566269.reachGoal('callbackOrder');
183					}
184				});
185				// alert('yes')
186			} else {
187				// alert('no no n o')
188				$(layer).find(".results .loading").css("display", "none");
189				$(layer).find(".results .result").css("display", "block");
190				$(layer).find(".results .result").html("Запрос отправлен!!!");// вывести сообщение
191			}
192		}
193	});
194}
195
196
197$(document).ready(function () {
198	setFormActions()
199	$.cookie('feedback', 'send');
200	count = $('.formid').length - 1;
201	$('.formid').each(function (i, e) {
202		var id = $(this).attr("data-id");
203		var page_id = $(this).attr("data-page-id");
204		var tourl = "/ajax/mod-mod_feedback";
205
206		$.ajax({
207			type: 'POST',
208			url: tourl,
209			data: "getform=" + id + "&pageid=" + page_id,
210			success: function (data) {
211				$(e).html(data);
212				// после загрузки последней формы инициализируем все события форм
213				setFormActions();
214			}
215		});
216	});
217
218
219
220	// маски
221	// телефон
222	// $(".feedback_form .input_telefon .input").mask("+7 (999) 999-99-99",
223	// {
224	// 	completed: function(){
225	// 		parent = $(this).parent();
226	// 		$(parent).find(".err_msg").css("display","none");
227	// 		$(parent).find(".err_msg").html("");
228	// 		$(parent).find(".input").removeClass("error");
229	// 	}
230	// });
231
232});

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.