PageSourceSearch

https://cleverbp.ru/templates/1c-franchise-start/js/cookie_form.js

js cleverbp.ru collected 2026-10-07 23:48:17 UTC 3,653 bytes, 114 lines download raw bytes

1$('document').ready(function(){
2
3	// Поля
4	var cookieNamePrefix = 'franch-unika-';
5	var cookieExpire = 30;
6	var cookiePath = '/';
7
8	// Загрузка существующих значений куки
9	loadCookies();
10
11	function loadCookies() {
12		// Текстовые инпуты
13		$('.cookie-form input, .cookie-form textarea').each(function() {
14			if ($.cookie(cookieNamePrefix + $(this).attr('name'))
15				&& !$(this).hasClass('captcha')
16				&& $.cookie(cookieNamePrefix + $(this).attr('name')) != 'null'
17				&& $(this).attr('type') != 'radio'
18				&& $(this).attr('type') != 'submit'
19				&& $(this).attr('type') != 'reset') {
20					$(this).val($.cookie(cookieNamePrefix + $(this).attr('name')));
21			};
22		});
23
24		// Селекты
25		$('.cookie-form select').each(function() {
26			var selectedName = $.cookie(cookieNamePrefix + $(this).attr('name'));
27
28			if (selectedName != 'null') {
29				$(this).find('option').each(function() {
30					if (selectedName === $(this).val()) {
31						$(this).attr('selected', 'selected');
32					} else {
33						$(this).removeAttr('selected');
34					};
35				});
36			};
37
38			// Проверка селекта Способа доставки
39			if( $(this).attr('name') == 'delivery-select' ) {
40
41				$(this).find('option').each(function() {
42					if($(this).attr('selected') == 'selected' && $(this).val() != ''){
43						var value = $(this).val();
44
45						// Убираем форму ввода адреса
46						if ($('div').is('#address-form-wrapper')) window.addressForm = $('#address-form-wrapper').detach();
47
48						// Выделяем соответствующий скрытый input
49						$(this).closest('div').find('input').each(function(){
50							if($(this).attr('value') == value){
51								$(this).attr('checked', 'checked');
52							}else{
53								$(this).removeAttr('checked');
54							}
55						});
56
57					}
58				});
59			}
60		});
61
62
63		setCookie();
64	}
65
66	// Установка куки при событии change
67	function setCookie() {
68		// Текстовые инпуты
69		$('.cookie-form input, .cookie-form textarea').change(function() {
70			if ($(this).attr('type')!= 'radio' && $(this).attr('type')!= 'reset' && $(this).attr('type')!= 'submit') {
71				$.cookie(cookieNamePrefix + $(this).attr('name'), $(this).val(), { expires: cookieExpire, path: cookiePath });
72				console.log(cookieNamePrefix + $(this).attr('name'));
73			};
74		});
75
76		// Селекты
77		$('.cookie-form select').change(function() {
78			$.cookie(cookieNamePrefix + $(this).attr('name'), $(this).val(), { expires: cookieExpire, path: cookiePath });
79			console.log(cookieNamePrefix + $(this).attr('name'));
80		});
81	}
82
83	// Сброс куки селекта при изменении способа доставки
84	$('.cookie-form input:radio').change(function() {
85		if($(this).attr('name') == 'delivery-id' && $(this).attr('data-type') != 'self') $.cookie('franch-unika-delivery-select', null, { path: cookiePath });
86	});
87
88	// Сброс значений куки
89	$(':reset').click(function() {
90		if (confirm("Вы подтверждаете очистку формы?")) {
91			cookieCleaner();
92		}
93	});
94
95	function cookieCleaner() {
96		var i = 0;
97		$('.cookie-form input, .cookie-form textarea').each(function() {
98			if($(this).attr('type') != 'submit' && $(this).attr('type') != 'reset') {
99				console.log(i++)
100				$.removeCookie(cookieNamePrefix + $(this).attr('name'), { path: cookiePath });
101				$(this).val('');
102			}
103		});
104
105
106		$('.cookie-form select').each(function() {
107			// if($(this).attr('name').search('data') != -1) {
108				console.log(i++)
109				$.cookie(cookieNamePrefix + $(this).attr('name'), null, { path: cookiePath });
110			// }
111		});
112	}
113
114});

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.