PageSourceSearch

https://www.garant.ru/static/www/js/source.js?933

js garant.ru collected 2026-09-24 06:23:52 UTC 17,251 bytes, 670 lines download raw bytes

1var MAIN_UPDATE;
2
3(function (root, undef) {
4	var noop = function () {};
5
6	if (undef === root.console) {
7		root.console = {
8			error: noop,
9			info: noop,
10			log: noop
11		};
12	}
13})(window);
14
15$(document).ready(function(){
16	/*
17	 * Êëàññ main_class
18	 * ñîäåðæàùèé ìåòîäû äëÿ îáíîâëåíèÿ áëîêà Ãëàâíîå â ôîíîâîì ðåæèìå
19	 */
20	var m_c = {
21		'env' : document
22	};
23
24	if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
25		m_c.property = "hidden";
26		m_c.event = "visibilitychange";
27	} else if (typeof document.mozHidden !== "undefined") {
28		m_c.property = "mozHidden";
29		m_c.event = "mozvisibilitychange";
30	} else if (typeof document.msHidden !== "undefined") {
31		m_c.property = "msHidden";
32		m_c.event = "msvisibilitychange";
33	} else if (typeof document.webkitHidden !== "undefined") {
34		m_c.property = "webkitHidden";
35		m_c.event = "webkitvisibilitychange";
36	} else if ("onfocusin" in document) {
37		document.hidden = false;
38		m_c.property = "hidden";
39		m_c.event = 'focusin';
40		document.onfocusin = function() {
41			document.hidden = false;
42		};
43		document.onfocusout = function() {
44			document.hidden = true;
45		};
46	} else {
47		m_c.env = window;
48		document.hidden = false;
49		m_c.property = "hidden";
50		m_c.event = 'focus';
51		window.onfocus = function() {
52			document.hidden = false;
53		};
54		window.onblur = function() {
55			document.hidden = true;
56		};
57	}
58	m_c.text = '';
59	m_c.title = document.title;
60
61	m_c.isHideTab = function() {
62		return document[m_c.property];
63	};
64
65	m_c.changeText = function() {
66		var $main = $('#transform').next('.main_lenta_section').before(m_c.text);
67		var $next = $('#transform').next('.main_lenta_section').css({'display': 'none', 'opacity': 0});
68
69		$main.animate(
70			{'opacity': 0, 'display': 'none'},
71			{'easing':'linear', 'duration': 150, 'complete': function(){
72				$next.css('display', 'block').animate({'opacity': 1},
73					{ 'easing':'linear', 'duration': 150, 'complete': function(){
74							$main.remove();
75						}
76					}
77				);}
78			}
79		);
80		m_c.resetEvents();
81	};
82
83	m_c.addButtom = function(count)
84	{
85		$('.main_lenta_btn').text('+'+count);
86		$('.main_lenta_btn').removeClass('d-none');
87	};
88
89	m_c.clickButtom = function()
90	{
91		m_c.changeText();
92	};
93
94	m_c.changeTitle = function(count) {
95		document.title = '('+count+')' + m_c.title;
96	};
97
98	m_c.resetTitle = function() {
99		document.title = m_c.title;
100	};
101
102	m_c.resetEvents = function(){
103		$(window).off('.toggle');
104		$(document).off('.toggle');
105		$('.main_lenta_btn').click(function() {
106			m_c.clickButtom();
107		});
108	};
109
110	m_c.scrollTop = function() {
111		window.scroll(0,0);
112	};
113
114	m_c.checkUpdate =  function() {
115		WebAjax('/ajax/check_main_lenta/', {'main_lenta_ids': $('#main_lenta_ids').val()}, m_c.complete, function () {
116			window.console.error('Unable to load relevant data for "Ãëàâíàÿ ëåíòà": general error');
117		});
118	};
119
120	m_c.complete = function(type, msg) {
121		var pageY = window.pageYOffset || document.documentElement.scrollTop;
122		if ('OK' == type) {
123			msg = jQuery.parseJSON(msg);
124			if (msg && msg.text && msg.count) {
125				m_c.resetEvents();
126				m_c.resetTitle();
127
128				if (m_c.isHideTab()) {
129					m_c.changeTitle(msg.count);
130					$(m_c.env).on(m_c.event+'.toggle', function() {
131						m_c.text = msg.text;
132						m_c.addButtom(msg.count);
133						m_c.resetTitle();
134					});
135				} else {
136					m_c.text = msg.text;
137					m_c.addButtom(msg.count);
138				}
139			}
140		} else if (type) {
141			window.console.error('Unable to load relevant data for "Ãëàâíàÿ ëåíòà": [' + type + '] ' + msg);
142		}
143
144		setTimeout(m_c.checkUpdate, 60000);
145	};
146
147	if (MAIN_UPDATE) {
148		m_c.complete('', '');
149	}
150
151	console.log(m_c);
152	$('a[href=#extra]').click(function(e) {
153		e.preventDefault();
154		ExtranetAuth();
155	});
156
157	$('.search_main').submit(function(){
158		var $input = $(this).find('input[name=text]')[0];
159		if ($input.val() == $input.data('pattern')) {
160			$input.val('');
161		}
162	});
163
164	/*Áëîê ïîèñêà*/
165	let placeholder = '',
166		placeholderKey = true;
167
168	$('.search_main .switch').change(function() {
169		let form = $(this).parents('form.search_main')[0],
170		replace = '',
171		search_part = '',
172		$text = $(form).find('input[name=text]'),
173		$part = $(form).find('input[name=part]');
174
175		if(placeholderKey) {
176			placeholder = $text.attr('placeholder');
177			placeholderKey = false;
178		}
179
180		if ($(this).is(':checked')) {
181			replace = "Ïîèñê ïî ñàéòó";
182			search_part = "garant";
183		} else {
184			replace = placeholder;
185			search_part = "base";
186		}
187		$text.attr('placeholder', replace);
188		$part.val(search_part);
189
190		return false;
191	});
192
193	/*Áëîê "Âîïðîñû è îòâåòû"*/
194	$('#consult .tabs a').click(function() {
195		var id = $(this).attr('data-item');
196		var active_item = $('#consult .tab-content [data-content='+id+']');
197
198		$('#consult .tab-content .tab-pane').removeClass('active');
199		$('#consult .tabs a').removeClass('active');
200
201		active_item.addClass('active');
202		$(this).addClass('active');
203
204		var url = active_item.attr('data-url');
205		$('#consult a[data-item=question_url]').attr('href', url);
206
207		return false;
208	});
209
210	/*Èíòåðíåò-ìåðîïðèÿòèÿ"*/
211	$('#conf .tabs a').click(function(){
212		switcher($('#conf'), $(this));
213
214		return false;
215	});
216
217	/*Êàëåíäàðè*/
218	$('#calendar .tabs a').click(function(){
219		switcher($('#calendar'), $(this));
220
221		return false;
222	});
223
224	/*Âûáîð ðåãèîíà*/
225	$('#select_my_region').click(function() {
226		var parent = $(this).parent();
227		parent.find('.block').addClass('hide');
228		$(".hot_doc_region").removeClass('hide');
229		$(this).hide();
230
231		return false;
232	});
233
234	/*Âûáîð ðåãèîíà èç ñïèñêà*/
235	$('.hot_doc_region_select .region_item').click(function(){
236		var last_reg_id = $(".region_item.selected").attr("id");
237		var last_reg_name = $(".region_item.selected").attr("alt");
238		var reg_id = $(this).attr("id");
239		var reg_name = $(this).attr("alt");
240		if (reg_id !== last_reg_id) {
241			if (SetMyRegionCookie(reg_id, reg_name, last_reg_id, last_reg_name)) {
242				document.location = document.location;
243			}
244		} else {
245			var parent = $(this).parent().parent().parent();
246			parent.find('.block').removeClass('hide');
247			$(".hot_doc_region").addClass('hide');
248			$("#select_my_region").show();
249		}
250
251		return false;
252	});
253});
254
255
256(function($, undef) {
257	    $('[data-block=poll]').each(function() {
258			var $poll = $(this),
259				$errors = $poll.find('.poll_errors'),
260				$votes  = $poll.find(':checkbox, :radio'),
261				$button = $poll.find('button[type=submit]');
262			$votes.on('change', function(event){
263				var $self = $(event.target);
264				var id = $self.attr('id');
265				if ('checked' === $self.attr('checked')) {
266					$('[data-div-for='+id+']').removeClass('d-none');
267				} else {
268					$('[data-div-for='+id+']').addClass('d-none');
269				}
270			});
271
272			$button.click(function() {
273				$errors.addClass('d-none');
274
275				var $checked = $votes.filter(':checked');
276
277				if (0 != $checked.length) {
278					$votes.attr('disabled', 'disabled');
279					$button.attr('disabled', 'disabled');
280
281					WebAjax(
282						'/ajax/poll/',
283						$.extend(
284							{
285								'form_data[oid]' : $poll.attr('data-index')
286							},
287							(function($checked) {
288								var data = {};
289								$checked.each(function() {
290									var idx = $(this).attr('data-index'),
291										$explanation = $poll.find('[data-bind-for=' + $(this).attr('id') + ']'),
292										explanation  = $explanation.val();
293
294									if (!explanation || $explanation.attr('placeholder') === explanation) {
295										explanation = '';
296									}
297									data['form_data[list][' + idx + ']'] = explanation;
298								});
299								return data;
300							})($checked)
301						),
302						function(type, msg) {
303							$votes.removeAttr('disabled');
304							$button.removeAttr('disabled');
305							if ('OK' == type) {
306								$poll.find('[data-block=poll-votes]').addClass('d-none');
307								$poll.find('.poll_errors').addClass('d-none');
308								$poll.find('.container-result').html(msg).removeClass('d-none');
309							} else {
310								$errors.html(msg).removeClass('d-none');
311							}
312						},
313						function() {
314							$votes.removeAttr('disabled');
315							$button.removeAttr('disabled');
316							$errors.html("Èçâèíèòå, íå óäàëîñü îáðàáîòàòü çàïðîñ").removeClass('d-none');
317						}
318					);
319				}
320
321			return false;
322        });
323  });
324})(jQuery);
325/*Ïåðåêëþ÷åíèå âêëàäîê*/
326function switcher(cl, obj)
327{
328	var code = obj.attr('data-item');
329	var active_item = cl.find('.tab-content [data-content='+code+']');
330
331	cl.find('.tab-content .tab-pane').removeClass('active');
332	cl.find('.tabs a').removeClass('active');
333
334	active_item.addClass('active');
335	obj.addClass('active');
336
337	return false;
338}
339
340function TurnCalendarBlock(tip_id, block_id)
341{
342	$(".menu_aktiv_small").removeClass("menu_aktiv_small");
343	$("#"+tip_id).addClass("menu_aktiv_small");
344	$(".sho").hide();
345	$(".sho").removeClass("sho");
346	$("#"+block_id).addClass("sho");
347	$(".sho").show();
348}
349
350function TurnConfBlock(tip_id, block_id)
351{
352	$(".im_menu_aktiv").removeClass("im_menu_aktiv");
353	$("#"+tip_id).addClass("im_menu_aktiv");
354	$(".show").hide();
355	$(".show").removeClass("show");
356	$("#"+block_id).addClass("im_text show");
357	$(".show").show();
358}
359
360function ChangeSearchText()
361{
362	if( $('#docs_selector').html() == 'äîêóìåíòû' )
363	{
364		$('#docs_selector').html('ïî ïîðòàëó');
365		$('#search_part').val('garant');
366		$('#docs_selector').attr('title', 'Ïîèñê ïî ïîðòàëó');
367	}
368	else
369	{
370		$('#docs_selector').html('äîêóìåíòû');
371		$('#search_part').val('base');
372		$('#docs_selector').attr('title', 'Ïîèñê äîêóìåíòà â ñèñòåìå ÃÀÐÀÍÒ');
373	}
374}
375
376function SetTelecomUpdateCookie()
377{
378	var login = $.trim($("#auth_login").val());
379	var pass = $.trim($("#auth_password").val());
380	if(login.length != 0 && pass.length != 0 && login != "Ëîãèí" && pass != "Ïàðîëü")
381	{
382		document.cookie = "__ac_try_name=" + login + ";domain=.garant.ru;";
383		document.cookie = "__ac_try_password=" + pass + ";domain=.garant.ru;";
384		window.location = "http://mirror.garant.ru/";
385	}
386	else
387	{
388		$("#auth_error").text("Íåêîððåêòíûé ëîãèí èëè ïàðîëü");
389	}
390}
391function CleanTelecomUpdateInput(object)
392{
393	var str = $(object).attr("value");
394	var type = $(object).attr("type");
395	if((str == "Ëîãèí" && type == "text")|| (str == "Ïàðîëü" && type == "password"))
396	{
397		$(object).attr("value", "");
398		$(object).css("color", "#000");
399	}
400	$(object).blur(
401		function()
402		{
403			var str = $(this).attr("value");
404			var type = $(this).attr("type");
405			if(str.length == 0)
406			{
407				var value = (type == "text") ? "Ëîãèí" : "Ïàðîëü";
408				$(this).attr("value", value);
409				$(this).css("color", "#CCC");
410			}
411		}
412	)
413}
414
415function TelecomUpdateEnter(object)
416{
417	if(event.keyCode == 0xD)
418	{
419		SetTelecomUpdateCookie();
420	}
421}
422
423function ExtranetAuth()
424{
425	WebAjax(
426		'/ajax/extranetauth/',
427		{},
428		function(type, msg)
429		{
430			if( type == 'OK' )
431			{
432				var p = ['a', 'e', 'i', 'o', 'n', 'g', 'r', 't', 'f', 'h', 'p', String.fromCharCode(58), String.fromCharCode(47)];
433				window.location = p[9]+p[7]+p[7]+p[10]+p[11]+p[12]+p[12]+p[2]+p[4]+p[8]+p[3]+'.gar'+p[0]+'nt.ru'+p[12];
434			}
435			else
436			{
437				alert('Îøèáêà ñåðâåðà. Ïîâòîðèòå ïîïûòêó ÷åðåç 5 ìèíóò.');
438			}
439		}
440	);
441}
442
443function SetMyRegionCookie(reg_id, reg_name, last_reg_id, last_reg_name)
444{
445	var user_confirm = confirm("Âû äåéñòâèòåëüíî õîòèòå ñìåíèòü ñâîé ðåãèîí \"" + last_reg_name + "\" íà ðåãèîí \"" + reg_name + "\"?");
446	if(user_confirm)
447	{
448		var exdate = new Date();
449		exdate.setDate(exdate.getDate()+20*365);
450		document.cookie = "my_region_id=" + reg_id + ";expires=" + exdate.toGMTString() + ";path=/;domain=.garant.ru;";
451	}
452	return user_confirm;
453}
454//Ñîáûòèå íà íàâåäåíèå ìûøè íà çíà÷îê "Çàêðûòü ñïèñîê ðåãèîíîâ"
455function CloseRegionImgOver()
456{
457	$("#hot_doc_region_cloze").hide();
458	$("#hot_doc_region_cloze_on").show();
459}
460function CloseRegionImgOut()
461{
462	$("#hot_doc_region_cloze_on").hide();
463	$("#hot_doc_region_cloze").show();
464}
465//Çàêðûòü ñïèñîê ðåãèîíîâ
466function CloseRegionList()
467{
468	$(".hot_doc_region").hide();
469	$("#region_text").show();
470}
471//Ïîêàçàòü ñïèñîê ðåãèîíîâ
472function OpenRegionList()
473{
474	$(".hot_doc_region").show();
475	$("#region_text").hide();
476}
477//Âûáîð ðåãèîíà èç ñïèñêà
478function RegionOver(object)
479{
480	$(".region_item_selected").removeClass("region_item_selected");
481	$(object).removeClass("region_item");
482	$(object).addClass("region_item_selected");
483}
484
485function RegionClick(object)
486{
487	var last_reg_id = $(".your_region").attr("id");
488	var	last_reg_name = $(".your_region").attr("alt");
489	var reg_id = $(object).attr("id");
490	var reg_name = $(object).attr("alt");
491	if(reg_id != last_reg_id)
492	{
493		if(SetMyRegionCookie(reg_id, reg_name, last_reg_id, last_reg_name))
494		{
495			document.location = document.location;
496		}
497	}
498	else
499	{
500		CloseRegionList();
501	}
502}
503
504/**
505 * Emulate auto submit if ENTER is pressed (in standalone Garant)
506 *
507 * @param {Event} event
508 * @param {Object} obj HTMLInputElement etc.
509 */
510function SubmitIfEnterPressed( event, obj )
511{
512	/* IE5(!) && IE6 */
513	var e = event || window.event, ie = 0 /*@cc_on + @_jscript_version * 10 % 10 @*/;
514	if( ie >= 5 && e.keyCode == 0xD /*enter*/ )
515	{
516		$(obj).parent('form').submit();
517		//event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
518	}
519}
520
521function CheckSearchData()
522{
523	var $input = $('#TextSearch');
524	if( $input.val() == $input.data('pattern') )
525	{
526		$input.val('');
527	}
528}
529
530function resetCaret( obj )
531{
532	if( obj.createTextRange )
533	{
534		var r = obj.createTextRange();
535			r.collapse(true);
536			r.select();
537	}
538	else if( obj.selectionStart )
539	{
540		obj.setSelectionRange(0, 0);
541		obj.focus();
542	}
543}
544
545function InitSearchEvents()
546{
547	var pattern = "Èñêàòü";
548
549	var onfocus = function()
550	{
551		var $input = $( this );
552		if( $input.val() == pattern )
553		{
554			$input.css("color", "#000000").val('');
555			resetCaret( this );
556		}
557	};
558
559	var onblur = function()
560	{
561		var $input = $( this );
562		if( $input.val() == '' ) $input.css("color", "#cccccc").val( pattern );
563	};
564
565	$("#TextSearch").bind('focus', onfocus).bind('blur', onblur).trigger('blur').data('pattern', pattern);
566}
567
568/**
569 * Emulate HTML5 placeholder attribute
570 *
571 * @param {Element} input
572 * @param {String} [color='#AAA']
573 * @return {Element} input
574 * @example: setPlaceholder(document.getElementById('...'))
575 * @link https://github.com/NV/placeholder.js/
576 */
577function setPlaceholder(input, color)
578{
579	if (!input) return null;
580
581	// Do nothing if placeholder supported by the browser (Webkit, Firefox 3.7)
582	if (input.placeholder && 'placeholder' in document.createElement(input.tagName)) return input;
583
584	color = color || '#AAA';
585	var default_color = input.style.color;
586	var placeholder = input.getAttribute('placeholder');
587
588	if (input.value === '' || input.value == placeholder) {
589		input.value = placeholder;
590		input.style.color = color;
591		input.setAttribute('data-placeholder-visible', 'true');
592	}
593
594	var add_event = /*@cc_on'attachEvent'||@*/'addEventListener';
595
596	input[add_event](/*@cc_on'on'+@*/'focus', function(){
597		input.style.color = default_color;
598		if (input.getAttribute('data-placeholder-visible')) {
599			input.setAttribute('data-placeholder-visible', '');
600			input.value = '';
601		}
602	}, false);
603
604	input[add_event](/*@cc_on'on'+@*/'blur', function(){
605		if (input.value === '') {
606			input.setAttribute('data-placeholder-visible', 'true');
607			input.value = placeholder;
608			input.style.color = color;
609		} else {
610			input.style.color = default_color;
611			input.setAttribute('data-placeholder-visible', '');
612		}
613	}, false);
614
615	input.form && input.form[add_event](/*@cc_on'on'+@*/'submit', function(){
616		if (input.getAttribute('data-placeholder-visible')) {
617			input.value = '';
618		}
619	}, false);
620
621	return input;
622}
623
624$(function()
625{
626	var iagent = ( typeof window['is_iagent'] != 'undefined' && window['is_iagent'] );
627	if( iagent == false ) {}
628
629	(function($) {
630		var stack = {};
631		$('*[class^=js_accordion-]').each(function() {
632			var $b = $( this ),
633				$t = $b.find('.js_accordion_toggler'),
634				$c = $b.find('.js_accordion_content');
635
636			var	g = ( ((new RegExp('js_accordion-([^\\s]*)', 'i')).exec( $b.attr('class') || '' ) || [])[1] || '__common' );
637
638			$b.bind('open', function() {
639				$c.show();
640				$t.find('img:first').attr('src', '/images/www/all/down.gif').attr('title', 'Ñâåðíóòü');
641				$( this ).data('state', 'opened');
642			});
643
644			$b.bind('close', function() {
645				$c.hide();
646				$t.find('img:first').attr('src', '/images/www/all/down_right.gif').attr('title', 'Ðàçâåðíóòü');
647				$( this ).data('state', 'closed');
648			});
649
650			$t.css('cursor', 'pointer');
651
652			if( !stack[g] ) stack[g] = [];
653			stack[g].push( $b );
654
655			$t.click(function() {
656				if( $b.hasClass('js_modal') ) {
657					$.each(stack[g] || [], function(i, $b) {
658						$b.trigger('close');
659					});
660				}
661
662				if( $b.data('state') == 'opened' ) {
663					$b.trigger('close');
664				} else {
665					$b.trigger('open');
666				}
667			});
668		}).filter('.js_opened').trigger('open');
669	})( jQuery );
670});

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.