PageSourceSearch

https://123ru.net/plugins/s29_code/js/newsteaser.js

js 123ru.net collected 2026-09-24 21:48:11 UTC 2,892 bytes, 101 lines download raw bytes

1if (typeof s29NewsTeaserDefined == 'undefined')
2{
3	$(function() {
4		
5		var teaserTypes = [ 'teaser', 'teaser_simple', 'teaser_mobile', 'banner', 'banner_simple' ];
6		
7		function adjustTeaser($teaser) {
8			if ($teaser.width() < 400)
9				$teaser.removeClass('s29_twoColumns s29_wide').addClass('s29_oneColumn');
10			else if ($teaser.width() < 780)
11				$teaser.removeClass('s29_oneColumn s29_wide').addClass('s29_twoColumns');
12			else if ($teaser.width() > 1000)
13				$teaser.removeClass('s29_oneColumn s29_twoColumns').addClass('s29_wide');
14			else
15				$teaser.removeClass('s29_oneColumn s29_twoColumns s29_wide');
16		}
17		
18		function adjustTeasers()
19		{
20			$('.s29NewsTeaser').each(function() { adjustTeaser($(this)); });
21		}
22		
23		$(window).resize(adjustTeasers);
24		
25		function activateTeasers()
26		{
27			var $inactiveTeasers = $('.s29NewsTeaser:not(.s29_active)');
28			$inactiveTeasers.each(function () {
29				var $teaser = $(this);
30				$teaser.addClass('s29_active');
31				adjustTeaser($teaser);
32			});
33		}
34		
35		function detectTeaserType($teaser)
36		{
37			for (var i = 0; i < teaserTypes.length; i++)
38				if ($teaser.hasClass('s29_' + teaserTypes[i]))
39					return teaserTypes[i];
40		}
41		
42		$(document).on('newsTeaserLoaded', activateTeasers);
43		
44		var $jsTeasers = $('.s29NewsTeaser.s29_js');
45		if ($jsTeasers.length > 0)
46		{
47			var location = window.location;
48			var topDomain = location.host.search(/\.nbk$/) != -1 ? 'nbk' : 'net';
49			var url = 'https://code.29ru.' + topDomain + '/_ajax/newsteaser/';
50			
51			var locationCode;
52			if (location.host.search(/^(?:m\.)?(?:123ru|ru24)\.(?:net|nbk)|news\-life(?:\-(?:pro|org))?\.(?:ru|nbk|pro|org)|(?:\w+\.)?russia24\.(?:pro|nbk)|russian\-city\.nbk|russian\.city$/) != -1)
53			{
54				var match = location.pathname.match(/^\/([^\/\?\#]+)/);
55				locationCode = match ? match[1] : '';
56			}
57			else
58				locationCode = '';
59			
60			var data = {
61				host:		location.host,
62				location:	locationCode
63			};
64			
65			var i = 0;
66			$jsTeasers.each(function() {
67				var $teaser = $(this);
68				$teaser.data('index', i);
69				data['type[' + i + ']'] = detectTeaserType($teaser);				
70				data['target[' + i + ']'] = $teaser.data('target');
71				data['width[' + i + ']'] = $teaser.data('width');
72				data['height[' + i + ']'] = $teaser.data('height');				
73				data['featured[' + i + ']'] = $teaser.data('featured');
74				i++;
75			});
76			
77			console.log(data);
78			
79			$.ajax(
80				{
81					url: url,
82					data: data,
83					success: function (data) {
84						var teaserCodes = JSON.parse(data);
85						$jsTeasers.each(function() {
86							var $teaser = $(this);
87							$teaser.html(teaserCodes[$teaser.data('index')]);
88						});
89						activateTeasers();
90					},
91					crossDomain: true,
92					dataType: 'html'
93				}
94			);
95		}
96		else
97			activateTeasers();
98	});
99
100	s29NewsTeaserDefined = true;
101}

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.