PageSourceSearch

https://mia.tj/templates/style/js/libs.js

js mia.tj collected 2026-10-03 18:59:26 UTC 7,440 bytes, 227 lines download raw bytes

1$(document).ready(function(){
2
3	$('.cat-t').each(function(){
4		var speedbar = $('#dle-speedbar').children('span').eq(1);
5		$(this).append('<h2>'+speedbar.text()+'</h2><div class="sect-links icon-l"><a href="'+speedbar.children('a').attr('href')+'rss.xml"><span class="fa fa-rss"></span>Rss</a></div>');
6	});
7	
8	// Вставка блока в тело статьи. Здесь 3 - приблизительно первая треть статьи, сменить на 2 - половина, сменить на 4 - первая четверть.
9	$('#rels-in').each(function(){
10		var there = Math.floor($('#full-text br').length / 3);
11		$('.full-text br').eq(there).after($(this));
12	});
13	
14	// На случай, если не бб-редактор, то закомментировать код выше, раскомментировать код ниже.
15	/* $('#rels-in').each(function(){
16		var there = Math.floor($('#full-text p').length / 3);
17		$('.full-text p').eq(there).after($(this));
18	}); */
19	
20	$(".show-comms").click(function(){
21		$('html, body').animate({
22		scrollTop: $(".comms-title").offset().top - 10
23		}, 600);
24	});
25	
26	$('body').append('<div class="close-overlay" id="close-overlay"></div><div class="side-panel" id="side-panel"></div>');
27	$('.mob-menu').each(function() {
28		$(this).clone().appendTo('#side-panel');
29	});		
30	$(".btn-menu").click(function(){
31		$('#side-panel').addClass('active');
32		$("#close-overlay").fadeIn(200);
33	});
34	$(".close-overlay").click(function(){
35		$('#side-panel').removeClass('active');
36		$('#close-overlay').fadeOut(200);
37	}); 
38	
39	$("#login-box").dialog({
40		autoOpen: false,
41		modal: true,
42		show: 'fade',
43		hide: 'fade',
44		width: 320
45	});
46	
47	$('.show-login').click(function(){
48		$('#login-box').dialog('open');
49	});
50	
51	$('#ac-av').html($('#lb-ava').html());
52	
53	$(".add-comm-btn").click(function(){
54		$("#add-comm-form").slideToggle(200);
55	});
56	$(".reply").click(function(){
57		$("#add-comm-form").slideDown(200);
58	});
59	$('body').on('click','.ac-textarea textarea, .fr-wrapper',function(){
60		$('.add-comm-form').addClass('active').find('.ac-protect').slideDown(400);
61	});
62	$('.lb-soc a, .ac-soc a').on('click',function(){
63	   var href = $(this).attr('href');
64       var width  = 820;
65       var height = 420;
66       var left   = (screen.width  - width)/2;
67       var top   = (screen.height - height)/2-100;   
68
69       auth_window = window.open(href, 'auth_window', "width="+width+",height="+height+",top="+top+",left="+left+"menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
70       return false;
71	});
72    $('#dle-content > #dle-ajax-comments').appendTo($('#full-comms')); 
73
74	$('body').append('<div id="gotop"><span class="fa fa-chevron-up"></span></div>');
75	var $gotop=$('#gotop'); 
76	$(window).scroll (function () {
77		if ($(this).scrollTop () > 300) {$gotop.fadeIn(200);
78		} else {$gotop.fadeOut(200);}
79	});	
80	$gotop.click(function(){
81		$('html, body').animate({ scrollTop : 0 }, 'slow');
82	});
83	
84});
85
86jQuery.fn.tcarusel = function(options){
87	
88	return this.each(function() {
89			
90		var tcaruselBlock = $(this);
91		var tcaruselScroll = tcaruselBlock.find('.tcarusel-scroll');
92		var tcaruselFirstItem = tcaruselBlock.find('.tcarusel-item:first');
93		var tcaruselLastItem = tcaruselBlock.find('.tcarusel-item:last');
94		
95		var tcaruselBlockWidth = tcaruselBlock.find(tcaruselFirstItem).outerWidth(true);
96	
97		function tcaruselShowNext() {
98			tcaruselScroll.animate({'left':-tcaruselBlockWidth}, 200, function(){
99				tcaruselBlock.find('.tcarusel-item:first').appendTo(tcaruselScroll);
100				tcaruselScroll.css({'left':'0'});
101			});
102		}
103		
104		function tcaruselShowPrev() {
105			tcaruselBlock.find('.tcarusel-item:last').prependTo(tcaruselScroll);
106			tcaruselScroll.css({'left':-tcaruselBlockWidth});
107			tcaruselScroll.animate({'left':0}, 200);
108		}
109		
110		tcaruselBlock.find('.tcarusel-next').click(tcaruselShowNext);
111		tcaruselBlock.find('.tcarusel-prev').click(tcaruselShowPrev);
112		
113	});
114	
115};
116$(document).ready(function() {
117$('.tcarusel').tcarusel();
118});
119
120
121	// tooltip 
122	$(document).ready(function () {
123		var targets = $('[rel~=tooltip]'),
124			target = false,
125			tooltip = false,
126			title = false;
127		targets.bind('mouseenter', function () {
128			target = $(this);
129			tip = target.attr('title');
130			tooltip = $('<div id="tooltip"></div>');
131			if (!tip || tip == '') return false;
132			target.removeAttr('title');
133			tooltip.css('opacity', 0).html(tip).appendTo('body');
134			var init_tooltip = function () {
135					if ($(window).width() < tooltip.outerWidth() * 1.5) tooltip.css('max-width', $(window).width() / 2);
136					else tooltip.css('max-width', 340);
137					var pos_left = target.offset().left + (target.outerWidth() / 2) - (tooltip.outerWidth() / 2),
138						pos_top = target.offset().top - tooltip.outerHeight() - 18;
139					if (pos_left < 0) {
140						pos_left = target.offset().left + target.outerWidth() / 2 - 18;
141						tooltip.addClass('left')
142					} else tooltip.removeClass('left');
143					if (pos_left + tooltip.outerWidth() > $(window).width()) {
144						pos_left = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20;
145						tooltip.addClass('right')
146					} else tooltip.removeClass('right');
147					if (pos_top < 0) {
148						var pos_top = target.offset().top + target.outerHeight();
149						tooltip.addClass('top')
150					} else tooltip.removeClass('top');
151					tooltip.css({
152						left: pos_left,
153						top: pos_top
154					}).animate({
155						top: '+=10',
156						opacity: 1
157					}, 100)
158				};
159			init_tooltip();
160			$(window).resize(init_tooltip);
161			var remove_tooltip = function () {
162					tooltip.animate({
163						top: '-=10',
164						opacity: 0
165					}, 50, function () {
166						$(this).remove()
167					});
168					target.attr('title', tip)
169				};
170			target.bind('mouseleave', remove_tooltip);
171			tooltip.bind('click', remove_tooltip)
172		})
173	});
174	
175
176
177function extractYoutubeId(url) {
178        var pattern = /^.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
179        var result = url.match(pattern);
180
181        if (result && result[1].length === 11) {
182            return result[1];
183        } else {
184            return 'invalid';
185        }
186    }
187
188    $(document).ready(function() {
189        $('.youtube-container').each(function() {
190            var youtubeLink = $(this).attr('data-youtube-link');
191            var videoId = extractYoutubeId(youtubeLink);
192
193            if (videoId !== 'invalid') {
194                $(this).html('<iframe width="100%" style="border-radius:4px; height:400px" src="https://www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>');
195            } else {
196                $(this).html('Invalid YouTube URL');
197            }
198        });
199    });
200
201
202
203 function getId(url) {
204        var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
205        var match = url.match(regExp);
206
207        if (match && match[2].length == 11) {
208            return match[2];
209        } else {
210            return 'error';
211        }
212    }
213
214    $(document).ready(function() {
215        $('[data-youtube]').each(function() {
216            var youtubeUrl = $(this).data('youtube');
217            var myId = getId(youtubeUrl);
218
219            if (myId !== 'error') {
220                $(this).html('<iframe width="100%" style="border-radius:4px;" src="https://www.youtube.com/embed/' + myId + '" frameborder="0" allowfullscreen></iframe>');
221            } else {
222                $(this).html('Invalid YouTube URL');
223            }
224        });
225    });
226
227/* end */

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.