PageSourceSearch

https://www.rgc-trade.com/bitrix/components/altop/forms.enext/templates/feedback/script.js

js rgc-trade.com collected 2026-10-06 06:09:40 UTC 9,319 bytes, 289 lines download raw bytes

1(function() {
2	'use strict';
3
4	if(!!window.JCFormsFeedbackComponent)
5		return;
6
7	window.JCFormsFeedbackComponent = function(params) {
8		this.componentPath = params.componentPath || '';
9		this.props = params.jsProps || '';
10		this.defaultCountry = params.defaultCountry || '';
11		this.userConsent = params.userConsent || '';
12		this.useCaptcha = params.useCaptcha || '';
13		this.container = BX(params.container);
14		
15		BX.ready(BX.delegate(this.init, this));
16	};
17
18	window.JCFormsFeedbackComponent.prototype =	{		
19		init: function() {
20			this.form = this.container.querySelector('form');
21			this.alert = this.container.querySelector('.alert');
22
23			var inputSourceUrl = this.form.querySelector('[name="SOURCE_URL"]');
24			if(!!inputSourceUrl)
25				inputSourceUrl.value = window.location.href;
26			
27			if(!!this.userConsent) {
28				var inputUserConsent = this.form.querySelector('[name="USER_CONSENT"]'),
29					inputUserConsentUrl = this.form.querySelector('[name="USER_CONSENT_URL"]');
30				
31				if(!!inputUserConsentUrl)
32					inputUserConsentUrl.value = window.location.href;
33
34				BX.UserConsent.load(this.form);
35			}
36
37			if(!!this.useCaptcha) {
38				var captchaImg = this.form.querySelector('[alt="CAPTCHA"]'),
39					captchaWord = this.form.querySelector('[name="CAPTCHA_WORD"]'),
40					captchaSid = this.form.querySelector('[name="CAPTCHA_SID"]');
41			}
42
43
44			if(!!this.props || !!this.useCaptcha) {
45				BX.ajax({
46					url: this.componentPath + '/ajax.php',
47					method: 'POST',
48					dataType: 'json',
49					timeout: 60,
50					data: {							
51						action: 'getData',
52						getCaptcha: !!this.useCaptcha ? true : false,
53						props: !!this.props ? this.props : false,
54						siteServerName: BX.message('SITE_SERVER_NAME'),
55						languageId: BX.message('LANGUAGE_ID')
56					},
57					onsuccess: BX.delegate(function(result) {
58						if(!!this.props) {
59							for(var i in this.props) {
60								if(this.props.hasOwnProperty(i)) {
61									var formInput = this.form.querySelector('[name="' + this.props[i].CODE + '"]');
62									if(!!formInput) {
63										if(formInput.name == 'PHONE') {
64											this.inputPhone = formInput;
65											this.iti = window.intlTelInput(this.inputPhone, {
66												autoHideDialCode: false,
67												autoPlaceholder : 'aggressive',
68												customContainer: 'iti--dark',
69												customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) {
70													return selectedCountryPlaceholder.replace(/[0-9]/g, '_');
71												},
72												initialCountry: !!result.COUNTRY ? result.COUNTRY : this.defaultCountry,
73												nationalMode: false,
74												preferredCountries: ['ru', 'by', 'ua', 'kz'],
75												separateDialCode: true,
76												utilsScript: '/bitrix/js/altop.enext/intlTelInput/utils.js'
77											});
78											this.iti.promise.then(BX.delegate(function() {
79												Inputmask(this.inputPhone.placeholder.replace(/_/g, '9')).mask(this.inputPhone);
80											}, this));
81											this.inputPhone.addEventListener('countrychange', BX.delegate(function(e) {
82												var target = e.currentTarget;
83												$(this.form).formValidation('resetField', target.name, true);
84												Inputmask(target.placeholder.replace(/_/g, '9')).mask(target);
85												target.blur();
86												target.focus();
87											}, this));
88										}
89									
90										if(this.props[i].CODE == 'EMAIL')
91										{
92											fields[this.props[i].CODE].validators.emailAddress =
93											{
94												message: 'Заполните поле верным Email адресом'
95											}
96										}
97
98
99										if(!!result[this.props[i].CODE] && result[this.props[i].CODE].length > 0)
100											formInput.value = result[this.props[i].CODE];
101									}
102								}
103							}
104						}
105						
106						if(!!this.useCaptcha && !!result.captcha) {
107							if(!!captchaImg) {
108								if(captchaImg.hasAttribute('data-lazyload-src'))
109									BX.adjust(captchaImg, {attrs: {'data-lazyload-src': '/bitrix/tools/captcha.php?captcha_sid=' + result.captcha}});
110								else
111									BX.adjust(captchaImg, {props: {src: '/bitrix/tools/captcha.php?captcha_sid=' + result.captcha}});
112								captchaImg.parentNode.style.display = '';
113							}
114							if(!!captchaWord)
115								captchaWord.value = '';
116							if(!!captchaSid)
117								captchaSid.value = result.captcha;
118						}
119					}, this)
120				});
121			}
122			
123			var fields = {};
124			
125			if(!!this.props) {
126				for(var i in this.props) {
127					if(this.props.hasOwnProperty(i)) {
128						var formInput = this.form.querySelector('[name="' + this.props[i].CODE + '"]');
129						if(!!formInput) {
130							fields[this.props[i].CODE] = {
131								row: '.form-group',
132								validators: {}
133							};
134
135							if(this.props[i].REQUIRED == 'Y') {
136								fields[this.props[i].CODE].validators.notEmpty = {
137									message: BX.message('FORMS_NOT_EMPTY_INVALID')
138								};
139							}
140							
141							if(this.props[i].CODE == 'PHONE') {
142								fields[this.props[i].CODE].validators.callback = {
143									message: BX.message('FORMS_PHONE_WRONG'),
144									callback: BX.delegate(function(value, validator, $field) {
145										if(!this.iti.isValidNumber()) {
146											return false;
147										} else {
148											return true;
149										}
150									}, this)
151								};
152							}
153						}
154					}
155				}
156			}
157			
158			if(!!this.userConsent && !!inputUserConsent) {
159				fields.USER_CONSENT = {
160					row: '.form-group',
161					validators: {
162						notEmpty: {
163							message: BX.message('FORMS_USER_CONSENT_NOT_EMPTY_INVALID')
164						}
165					}
166				};
167			}
168
169			if(!!this.useCaptcha && !!captchaWord) {
170				fields.CAPTCHA_WORD = {
171					row: '.form-group',
172					validators: {
173						notEmpty: {
174							message: BX.message('FORMS_NOT_EMPTY_INVALID')
175						},
176						remote: {
177							type: 'POST',
178							url: this.componentPath + '/ajax.php',
179							message: BX.message('FORMS_CAPTCHA_WRONG'),
180							data: function() {
181								return {
182									action: 'checkCaptcha',
183									CAPTCHA_SID: !!captchaSid ? captchaSid.value : ''
184								};
185							},
186							delay: 1000
187						}
188					}
189				};
190			}
191			
192			$(this.form).formValidation({
193				framework: 'bootstrap',
194				icon: {
195					valid: 'icon-ok-b',
196					invalid: 'icon-close-b',
197					validating: 'icon-repeat-b'
198				},
199				fields: fields				
200			});
201				
202			if(!!this.userConsent && !!inputUserConsent) {
203				BX.addCustomEvent(this.form, 'OnFormInputUserConsentChange', BX.delegate(function() {
204					$(this.form).formValidation('revalidateField', inputUserConsent.name);
205				}, this));
206			}
207			
208			$(this.form).on('success.form.fv', BX.delegate(function() {
209				if (this.rgcSending) return false;
210				this.rgcSending = true;
211				var data = {
212					action: 'sendForm',
213					siteId: BX.message('SITE_ID'),
214					siteCharset: BX.message('SITE_CHARSET'),
215					siteServerName: BX.message('SITE_SERVER_NAME'),
216					languageId: BX.message('LANGUAGE_ID')
217				};
218				
219				var propCollection = this.form.querySelectorAll('input, textarea, select');
220				if(!!propCollection) {
221					for(var i in propCollection) {
222						if(propCollection.hasOwnProperty(i) && BX.type.isDomNode(propCollection[i])) {
223							if(propCollection[i].name == 'PHONE') {
224								data[propCollection[i].name] = {};
225								data[propCollection[i].name]['COUNTRY'] = this.iti.getSelectedCountryData();
226								data[propCollection[i].name]['VALUE'] = propCollection[i].value;
227								data[propCollection[i].name]['FULL_VALUE'] = this.iti.getNumber(intlTelInputUtils.numberFormat.INTERNATIONAL);
228							} else {
229								data[propCollection[i].name] = propCollection[i].value;
230							}
231						}
232					}
233				}
234				
235				if (window.RgcAnalytics) Object.assign(data, window.RgcAnalytics.fields(this.form));
236				BX.ajax({
237					url: this.componentPath + '/ajax.php',
238					method: 'POST',
239					dataType: 'json',
240					timeout: 60,
241					data: data,
242					onsuccess: BX.delegate(function(result) {
243						this.rgcSending = false;
244						$(this.form).formValidation('resetForm', false);
245
246						if(result.status === true) {
247							if (window.RgcAnalytics) window.RgcAnalytics.accepted(this.form, result);
248							BX.remove(this.form);
249
250							if(!!this.alert) {
251								BX.adjust(this.alert, {
252									props: {
253										className: 'alert alert-success alert-show'
254									},
255									html: BX.message('FORMS_ALERT_SUCCESS')
256								});
257							}
258						} else {
259							if (window.RgcAnalytics) window.RgcAnalytics.error(this.form, 'server');
260							if(!!this.alert) {
261								BX.adjust(this.alert, {
262									props: {
263										className: 'alert alert-error alert-show'
264									},
265									html: BX.message('FORMS_ALERT_ERROR')
266								});
267							}
268						}
269
270						if(!!this.useCaptcha && !!result.captcha_code) {
271							if(!!captchaImg)
272								BX.adjust(captchaImg, {attrs: {src: '/bitrix/tools/captcha.php?captcha_sid=' + result.captcha_code}});
273							if(!!captchaWord)
274								captchaWord.value = '';
275							if(!!captchaSid)
276								captchaSid.value = result.captcha_code;
277						}
278					}, this),
279					onfailure: BX.delegate(function () {
280						this.rgcSending = false;
281						$(this.form).formValidation('resetForm', false);
282						if (window.RgcAnalytics) window.RgcAnalytics.error(this.form, 'network');
283						if (this.alert) BX.adjust(this.alert, {props: {className: 'alert alert-error alert-show'}, html: BX.message('FORMS_ALERT_ERROR')});
284					}, this)
285				});
286			}, this));
287		}
288	}
289})();

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.