PageSourceSearch

https://www.21.by/pub/img/sIndex.js?3

js 21.by collected 2026-09-27 21:43:32 UTC 14,730 bytes, 602 lines download raw bytes

1$(function(){
2  if (!sWIDGET_EDIT_MODE){
3    document.getElementById('sSearchField').focus();
4  }
5
6  $('.btns input').each(function(){
7    $(this).removeAttr('disabled');
8  })
9//	alert(document.getElementById('sSearchSelect'));
10})	
11$(function(){
12    $("#rec").hide();
13 //   setTimeout(function(){$("#rec").show(); setInterval(function(){$("#rec").toggle();},1000)},2000);			
14});
15
16/*
17 *	Блок избранное на главной
18 */
19var sFavShowEdit = function(obj){
20	$(obj).children('.edit').css({visibility : 'visible'});
21}
22
23var sFavHideEdit = function(obj){
24	$(obj).children('.edit').css({visibility : 'hidden'});
25}
26
27var sFavEdit = function(obj, id, widgetId){
28	var 
29		box = $('#sFavWidget'+widgetId),
30		pos = box.sAbsPosition(), 
31		offset = (box.width() - 274) / 2,
32		form = $('#sFavEditFrom' + widgetId),
33		name = $('input[name="xx_name"]', form),
34		url = $('input[name="xx_url"]', form),
35		list = $('#sFavItemList' + widgetId);
36
37	$('#sFavEditErr' + widgetId).text('');
38
39	if (obj){
40		var	
41			itm = $(obj).parent();
42			lnk = $('a', itm);
43
44		$('input[name="xx_delete"]', form).css({
45			display : ''
46		});
47
48		name.attr('value',lnk.text());
49		url.attr('value',lnk.attr('href'));
50
51		$('input[name="xx_save"]', form).click(function(){
52			if (sFavValidate(widgetId, name.attr('value'), url.attr('value')) === false){
53				return false;
54			}
55
56			lnk.text(name.attr('value'));
57			lnk.attr('href', url.attr('value'));
58                        $.ajax({
59				type : "POST", 
60				url : sHTTP, 
61				dataType : "json",
62				data : {
63					cmd:'GetFavicon',
64					url :url.attr('value'),
65                                        ajax:1
66				},
67				widgetId:widgetId,
68				success : function(a){                                        
69				        $('img', itm).attr('src', a.favicon);
70                                        sFavUpdateState (widgetId, list);
71			                                
72
73				}
74			});
75			
76			$(this).unbind('click');
77			form.css({
78				display : 'none'
79			});
80		});
81		
82		$('input[name="xx_delete"]', form).one('click', function(){
83			if (!confirm('Вы действительно хотите удалить эту ссылку?')){
84				return;
85			}
86			itm.remove();
87			sFavUpdateState (widgetId, list);			
88			form.css({
89				display : 'none'
90			});			
91		});			
92	}else{
93		name.attr('value','');
94		url.attr('value','http://');
95		
96		$('input[name="xx_delete"]', form).css({
97			display : 'none'
98		});
99		
100		$('input[name="xx_save"]', form).click(function(){
101			if (sFavValidate(widgetId, name.attr('value'), url.attr('value')) === false){
102				return false;
103			}				
104                        
105			$.ajax({
106				type : "POST", 
107				url : sHTTP, 
108				dataType : "json",
109				data : {
110					cmd:'GetFavicon',
111					url :url.attr('value'),
112                                        ajax:1
113				},
114				widgetId:widgetId,
115				success : function(a){                                        
116					
117                                        favicon = '<span class="favicon"><img src="'+ a.favicon +'"> </span>';
118                                        list.append('<li>' +favicon + '<a href="' + url.attr('value') + '">' + name.attr('value') + '</a></li>');
119                                        sFavUpdateState (widgetId, list);
120			                
121
122				}
123			});
124                       $(this).unbind('click');
125                        
126			
127			form.css({
128				display : 'none'
129			});
130		});			
131	}
132	pos = box.sAbsPosition(), 
133	offset = (offset > 0) ? offset : 0;
134	form.css({
135		top : pos.top + 'px',
136		left : (pos.left + offset) + 'px',
137		display : ''
138	});
139}
140
141var sFavValidate = function(widgetId, name, url){
142	if (!name){
143		$('#sFavEditErr' + widgetId).text('Вы не указали название');
144		return false;
145	}
146
147	if (name.length > 30){
148		$('#sFavEditErr' + widgetId).text('Длина названия не должна превышать 30 символов');
149		return false;
150	}
151
152	if (!url){
153		$('#sFavEditErr' + widgetId).text('Вы не указали адрес');
154		return false;
155	}
156
157	if (url.length > 200){
158		$('#sFavEditErr' + widgetId).text('Длина адреса не должна превышать 200 символов');
159		return false;
160	}
161	
162	return true;
163}
164
165var sFavUpdateState = function(widgetId, list){
166	var	ws = {Update : {}}, i = 0;
167	ws.Update[widgetId] = {config : {data : []}};
168
169	$('li', list).each(function (a) { 
170                var fav = $('img', $(this));
171                
172		var lnk = $('a', $(this));
173
174		ws.Update[widgetId].config.data[i] = {
175			id : i,
176			name : lnk.text(),
177			url : lnk.attr('href'),
178                        favicon:fav.attr('src')
179		};
180		i++;
181	});
182
183	if (window.sWidgetState){
184		window.sWidgetState.Update[widgetId] = ws.Update[widgetId];
185		return;
186	}
187
188	$('#sWidget' + widgetId).animate({opacity: 0.3}, "fast");
189
190	$.ajax({
191		type : "POST", 
192		url : sHTTP, 
193		dataType : "html",
194		data : {
195			cmd:'SaveWidgets',
196			singleWidgetMod :1, 
197			widgetState:JSON.stringify(ws)
198		},
199		widgetId:widgetId,
200		success : function(a){
201			$('#sWidget' + this.widgetId).replaceWith(a);
202		}
203	});
204}
205
206var sFavHideEditForm = function(obj){
207	$(obj).parent().css({display : 'none'});
208}
209
210
211var sMailClass = function(){ 
212return {
213		current : -1,
214		currentData : false,
215		isOpen : false,
216		isMouseOver : false,
217		closing : false,
218
219		init : function(widgetId){
220			this.widgetId = widgetId;
221			this.widget = $('#sWidget' + widgetId);
222			this.content = $('#sMailContent' + widgetId);
223			this.list = $('#sMailList' + widgetId);
224			this.settings = $('#sMailSettings' + widgetId);
225			this.loading = $('#sMailLoading' + widgetId);
226			this.host = $('#sMailHost' + widgetId);
227		},
228		
229		/*
230		* открывает соответсвующий почтовый ящик
231		*/	
232		show : function(num, check){
233			if (this.current == num){
234				this.hide();
235				return;
236			}
237			
238			if ( !this.isOpen ){
239				this.isOpen = true;
240				this.content.show(200);
241			}
242			
243			this.current = num;
244			$('.box', this.content).hide();
245			$('.selected', this.widget).attr('class','');
246			$('#sMailLink' + this.widgetId + '_' + num).attr('class','selected');
247
248			if (check){
249				this.settings.hide();			
250				this.list.empty();
251				this.loading.show();
252				$.ajax({
253					type : "POST", 
254					url : sHTTP, 
255					dataType : "json",
256					data : {cmd : 'list',	box : num, hm : 402, id : this.widgetId, ajax : 1},
257					parent : this,
258					num : num,						
259					success : function(a){
260						if (this.num != this.parent.current){
261							return;
262						}
263
264						this.parent.loading.hide();
265						this.parent.currentData = a.data;
266						if (a.data.err){
267							this.parent.showSettingsForm('',a.data.err,a.data.login);
268						}else{
269							this.parent.list.empty();
270							this.parent.list.attr('class','box');
271							var html = '';
272							if (a.data.count > 0){
273								for (var i = 0, len = a.data.count; i < len; i++){
274									html+= [
275										'<div class="from">', a.data.list[i].from, '</div>',
276										'<div class="date">', (a.data.list[i].date) ? sDateTime(a.data.list[i].date) : '', '</div>',
277										'<div class="subject"><a href=',a.data.list[i].url,' target="_blank">', a.data.list[i].subject, '</a></div>'
278									].join('');
279								}
280							}else{
281								html = '<div class="empty">Список пуст</div>';
282							}
283
284							html += '<div class="edit"><input type="button" onclick="sMailBox' + this.parent.widgetId + '.showSettings();" value="Изменить настройки"/></div>';
285							this.parent.list.append(html);
286							this.parent.list.show();
287						}
288					}
289				});		
290			}else{
291				this.loading.hide();
292				this.showSettingsForm();
293			}
294		},
295		/*
296		* отображет форму настроек для текущего почтовика
297		*/	
298		showSettings : function(){
299			this.list.hide();		
300			this.showSettingsForm('','',this.currentData.login);
301		},
302		/*
303		* отображет форму настроек и подставляет в нее нужные значения
304		*/	
305		showSettingsForm : function(comments, errors, login){
306	
307			if (this.current == 0){
308//				alert(sIsLogged);
309			}else if(this.current == 1){
310				this.host.text('@tut.by');
311			}else if(this.current == 2){
312				this.host.html('@&nbsp;<select><option value="mail.ru">mail.ru</option>' + 
313											 '<option value="inbox.ru">inbox.ru</option>'+
314											 '<option value="bk.ru">bk.ru</option>'+
315											 '<option value="list.ru">list.ru</option></select>');
316				$('select', this.host).attr('value', this.currentData.host);
317			}else if(this.current == 3){
318				this.host.text('@gmail.com');
319			}else if(this.current == 4){
320				this.host.text('@yandex.ru');
321			}
322
323			if (comments){
324				$('.comments', this.settings).text(comments);
325				$('.comments', this.settings).show();
326			}else{
327				$('.comments', this.settings).hide();
328			}
329			
330			if (errors){
331				$('.errors', this.settings).text(errors);
332				$('.text', this.settings).hide();
333				$('.errors', this.settings).show();
334			}else{
335				$('.errors', this.settings).hide();
336				$('.text', this.settings).show();
337			}
338						
339			if (login){
340				$('input[name="login"]', this.settings).attr('value', login);
341				$('input[name="pass"]', this.settings).attr('value', '******');
342				$('input[name="pass"]', this.settings).one('focus', function(){
343					this.value = '';
344				});
345			}else{
346				$('input[name="login"]', this.settings).attr('value', '');
347				$('input[name="pass"]', this.settings).attr('value', '');
348			}
349			
350			if (!errors && login){
351				$('input[name="cancel"]', this.settings).show();
352			}else{
353				$('input[name="cancel"]', this.settings).hide();
354			}
355			
356			this.settings.show();		
357		},
358		/*
359		* прячет выпадающую часть
360		*/	
361		hide : function(){
362			var parent = this;
363			this.current = -1;
364			$('.selected', this.widget).attr('class','');
365
366			this.content.hide(200, function(){
367				parent.isOpen = false;
368			});
369		},
370/*		
371		out : function(){
372			this.isMouseOver = false;	
373			this.closing = setTimeout('sMailBox' + this.widgetId + '.hide()', 5000);
374		},
375	
376		over : function(){
377			this.isMouseOver = true;
378			if (this.closing){
379				clearTimeout(this.closing);
380			}
381		},
382*/
383		/*
384		* сохраняет авторизационные данные
385		*/	
386		saveBox : function(){
387			var 
388				login = $('input[name="login"]', this.settings).attr('value'),
389				pass = $('input[name="pass"]', this.settings).attr('value'),
390				host;
391			
392			if (!login){
393				$('.errors', this.settings).text('Вы не указали логин');
394				$('.errors', this.settings).show();
395				$('.text', this.settings).hide();
396				return false;				
397			}
398			
399			if (!pass || pass == '******'){
400				$('.errors', this.settings).text('Вы не указали пароль');
401				$('.errors', this.settings).show();
402				$('.text', this.settings).hide();
403				return false;				
404			}
405			
406			this.settings.hide();			
407			this.loading.show();			
408			
409			if (this.current == 2){
410				host = $('select', this.host).attr('value');
411			}
412
413			$.ajax({
414				type : "POST", 
415				url : sHTTP, 
416				dataType : "html",
417				data : {
418					cmd : 'SaveData',	box : this.current, hm : 402, id : this.widgetId,
419					login : login,
420					pass : pass,
421					host : host
422				},
423				parent : this,
424				success : function(a){
425					this.parent.widget.replaceWith(a);
426				}
427			});
428		},
429		
430		cancelBox : function(){
431			this.settings.hide();
432			this.list.show();
433		},
434		
435		dropBox : function(){
436			$.ajax({
437				type : "POST", 
438				url : sHTTP, 
439				dataType : "html",
440				data : {
441					cmd : 'DropData',	box : this.current, hm : 402, id : this.widgetId
442				},
443				parent : this,
444				success : function(a){
445					this.parent.widget.replaceWith(a);
446				}
447			});
448		}
449	};
450};
451
452/*
453 *	Управление всплювающим блочком "в закладки в блог"
454 */
455var sShowFavTools = function(obj){
456	var 
457		lnk = $(obj),
458		box = $('#sFavBox'),
459		pos = lnk.sAbsPosition();
460
461	box.css({
462		display:'', 
463		top : (pos.top - 7) + 'px',
464		left : (pos.left + lnk.width() - 138) + 'px'
465	});
466}
467
468var sHideFavTools = function(obj){
469	$(obj).parent().parent().css({display:'none'});
470}
471
472var changeSrc = function(widgetId, hnd, data){
473	var ws = {Update : {}};
474	ws.Update[widgetId] = {config : data};
475	
476		$('#sWidget' + widgetId).animate({opacity: 0.3}, "fast");
477	
478		$.ajax({
479			type : "POST", 
480			url : sHTTP, 
481			dataType : "html",
482			data : {
483				cmd:'changeSrc',
484				singleWidgetMod :1, 
485				id:widgetId,
486				widgetState:JSON.stringify(ws)
487			},
488			widgetId:widgetId,
489			success : function(a){
490				$('#sWidget' + this.widgetId).replaceWith(a);
491			}
492		});
493	
494}
495
496
497
498/*
499 *	Переключение режима списка с аносом или без на главной
500 */
501var sSetWidgetSettings = function(widgetId, hnd, data){
502	if (sWIDGET_EDIT_MODE){
503		sUpdateWidget($('#sWidget' + widgetId), widgetId, hnd, data);
504	}else{
505		var ws = {Update : {}};
506		
507		ws.Update[widgetId] = {config : data};
508	
509		$('#sWidget' + widgetId).animate({opacity: 0.3}, "fast");
510	
511		$.ajax({
512			type : "POST", 
513			url : sHTTP, 
514			dataType : "html",
515			data : {
516				cmd:'SaveWidgets',
517				singleWidgetMod :1, 
518				widgetState:JSON.stringify(ws)
519			},
520			widgetId:widgetId,
521			success : function(a){
522				$('#sWidget' + this.widgetId).replaceWith(a);
523			}
524		});
525	}
526}
527
528var sHideNewWidgetsBlock = function(obj){
529  $(obj).parent().remove();
530  $.ajax({
531    type:'POST',
532    url: sHTTP,
533    dataType : 'json',
534    data : {
535      cmd : 'HideNewWidgets',
536      ajax : 1
537    }
538  })
539}
540
541var sVote = function(el){
542    $(el).attr('disabled', 'disabled');
543    answer_id = $('#poller input:checked').val();
544    poll_id   = $('#poll_id').val();
545    own_answer = $('#own_answer').val();
546    $.ajax({
547		type : "POST", 
548		cache: false,
549		url : sHTTP, 
550		dataType : "html",
551		data : {
552			cmd : 'DoVote',
553			answerId: answer_id,
554			pollId: poll_id,
555			ownAnswer:own_answer
556                        
557		},
558		
559		success : function(a){
560			$('#poll_injection').replaceWith(a);
561		}
562	});
563}
564
565function sShowPollResult()
566{
567    poll_id   = $('#poll_id').val();
568    
569    $.ajax({
570		type : "POST", 
571		cache: false,
572		url : sHTTP, 
573		dataType : "html",
574		data : {
575			cmd : 'showPollResult',
576			pollId: poll_id
577                        
578		},
579		
580		success : function(a){
581			$('#poll_injection').replaceWith(a);
582		}
583	});
584}
585
586function checkRegion(rId)
587{
588    $('#region-wrapper-'+rId + ' .region-towns-list :checkbox').removeAttr('checked');
589    $('.news-menu .towns-row :checkbox').removeAttr('checked');
590}
591
592function checkTown(rId)
593{
594    $('#region-wrapper-'+rId + ' .region-title :checkbox').removeAttr('checked');
595    $('.news-menu .towns-row :checkbox').removeAttr('checked');
596}
597
598function checkActiveTown(rId)
599{
600    $('#region-wrapper-'+rId + ' .region-title :checkbox').removeAttr('checked');
601    $('#region-wrapper-'+rId + ' .region-towns-list :checkbox').removeAttr('checked');
602}

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.