PageSourceSearch

https://i49.vbox7.com/assets/js/vbox/ajax-events.js?v=166b748775

js vbox7.com collected 2026-10-02 02:25:34 UTC 18,549 bytes, 764 lines download raw bytes

1
2$(function() {
3	$('body').on(clicktouch, '.followed, .popup-unfollow', function (e) {
4		e.stopPropagation();
5		e.preventDefault();
6
7		if (redirectToLogin()) {
8			return false;
9		}
10
11		var userid = $(this).data('userid');
12
13		var text = 'Сигурни ли сте, че не желаете да следвате този канал? <br /><br /> <span class="follow-confirm" data-userid="' + userid + '">Да</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cancel-alert" data-userid="' + userid + '">Не</span>';
14		alert(text, true);
15
16		$('.popup-bg').click();
17	});
18
19	$('body').on(clicktouch, '.follow-confirm', function () {
20		var userid = $(this).data('userid');
21		$('.alert-bg').remove();
22		$("body").css("overflow", "auto");
23		followFollowedAjax($(this), userid, 0);
24	});
25	
26	$('body').on(clicktouch, '.follow, .popup-follow', function (e) {
27		e.stopPropagation();
28		e.preventDefault();
29
30		if (redirectToLogin()) {
31			return false;
32		}
33
34		var userid = $(this).data('userid');
35		followFollowedAjax($(this), userid, 1);
36
37		$('.popup-bg').click();
38	});
39	
40	$('body').on(clicktouch, '.watchLater:not(.added)', function (e) {
41		
42		e.preventDefault();
43		e.stopPropagation();
44		var that = $(this);
45
46		if (!globalLoginUserId) {
47			var watchLaterArray = JSON.parse(readCookie('watchLater'));
48			
49			if (!watchLaterArray) {
50				watchLaterArray = [];
51			}
52			
53			var inArray = watchLaterArray.indexOf(that.attr('data-mdkey'));
54
55			if (inArray < 0) {
56				watchLaterArray.push(that.attr('data-mdkey'));
57				setCookie('watchLater', JSON.stringify(watchLaterArray), 24*365);
58				that.addClass('added');
59			}
60			
61		} else {
62			addWatchLaterAjax(that);
63		}
64		
65	});
66
67	$('body').on(clicktouch, '.watchLater.added', function (e) {
68		
69		e.preventDefault();
70		e.stopPropagation();
71		var that = $(this);
72		
73		if (!globalLoginUserId) {
74			var watchLaterArray = JSON.parse(readCookie('watchLater'));
75			
76			if (watchLaterArray) {
77				var inArray = watchLaterArray.indexOf(that.attr('data-mdkey'));
78
79				if (inArray > -1) {
80					watchLaterArray.splice(inArray, 1);
81					setCookie('watchLater', JSON.stringify(watchLaterArray), 24*365);
82					that.removeClass('added');
83				}
84			}
85		} else {
86			removeWatchLaterAjax(that);
87		}
88		
89	});	
90	
91	$('body').on(clicktouch, '.popup-share', function (e) {
92		e.preventDefault();
93		e.stopPropagation();
94
95		var that = $(this);
96
97		if(isMobile == false) {
98			getShareTabAjax(that);
99		} else {
100			getShareTabMobile(that);
101		}		
102	});
103    
104	var currentRequest = null;  
105	var currentRequestUsers = null;  
106    
107	$('body').on('keyup', '#vbox_q_dt', function (e) {
108		var searchTerm = $(this).val();
109		var KeyCode = e.which; //13 = enter => submit
110
111		if (searchTerm.length >= 3 && KeyCode != 13) {
112            currentRequest = autoComplete(searchTerm, currentRequest);
113            $.when(currentRequest).done(function () {
114                currentRequestUsers = autoCompleteUsers(searchTerm, currentRequestUsers);    
115            });      
116		}
117	});
118	
119    $('body').on(clicktouch, '#filter-radio input', function (e) {
120		e.preventDefault();
121		e.stopPropagation();
122
123        $('#search-opt-menu a[data-field="' + $(this).val() + '"]').click();
124	});
125    
126	$('body, .basic-grid > *').on(clicktouch, '#search-opt-menu a', function (e) {
127
128		e.preventDefault();
129		e.stopPropagation();
130
131		var that = $(this);
132
133		that.parent().children().removeClass('active');
134		that.addClass('active');
135
136		var dataField = '';
137		var queryStr = $('#vbox_q, #vbox_q_dt').val();//TODO maybe some validation ex. < 3 chars and so on
138		var criteriaMenuEl = $('#search-opt-menu');
139
140		criteriaMenuEl.find('.icon-check').remove();
141		criteriaMenuEl.find(' a.active').each(function () {
142			dataField += '&' + $(this).attr('data-field');
143			$(this).find('span').before('<i class="icon-check"></i>');
144		});
145
146		criteriaMenuEl.removeClass('open');
147		$('.autocomplete-res-container').hide();
148
149		window.location.href = '/search?' + 'vbox_q=' + queryStr + dataField;
150
151	});
152	
153	$('body').on(clicktouch, '.item-delete', function(e) {
154		e.preventDefault();
155		
156		var itemid = $(this).attr('data-item-id');
157		var username = $(this).attr('data-username');
158
159		confirmModal("Внимание", "Потвърди изтриването", "Да", "Не" );
160		
161
162		$('body').on(clicktouch, '.dialog-confirmation-cancel, .dialog-close', function() {
163			return false;
164		});
165		
166		$('body').on(clicktouch, '.dialog-confirmation-confirm', function(e) {
167			
168			$('.moreLoadingBox').show();
169			
170			$.ajax({
171				url : "/aj/item/delete",
172				dataType: "json",
173				type: "POST",
174				data : {itemid: itemid}
175			}).done(function(data) {
176				$('.moreLoadingBox').show();
177				alert(data.message);
178				if (false == data.success) {
179					return false;
180				} else {
181					if (typeof username !== 'undefined') {
182						location.href = '/user:'+username+'?p=items';
183					} else {
184						window.location.reload(true);
185					}
186                   				
187				}
188				
189			}).fail(function() {
190				$('.moreLoadingBox').hide();
191			});
192
193		});
194	});
195	
196	// Add to favourites 
197	$('body').on(clicktouch, '.favourites-add', function (e) {
198		e.preventDefault();
199		var obj = $(this);
200
201		$.ajax({
202			url : "/aj/favorites/add",
203			dataType: "json",
204			type: "POST",
205			data : {
206				id: obj.attr('data-id')
207			}
208		}).done(function(data) {
209
210			alert(data.message);
211			if (false == data.success) {
212				return false;
213			} else {
214				$(obj).removeClass('favourites-add').addClass('favourites-delete').html('<i class="icon-favorites"></i> <span>Махни от любими</span>');
215			}
216
217		}).fail(function() {
218			
219		});
220
221	});
222
223	// Remove from favourites 
224	$('body').on(clicktouch, '.favourites-delete', function (e) {
225		e.preventDefault();
226		obj = $(this);
227
228		$.ajax({
229			url : "/aj/favorites/remove",
230			dataType: "json",
231			type: "POST",
232			data : {
233				id: obj.attr('data-id')
234			}
235		}).done(function(data) {
236
237			alert(data.message);
238			if (false == data.success) {
239				return false;
240			} else {
241				$(obj).removeClass('favourites-delete').addClass('favourites-add').html('<i class="icon-favorites"></i> <span>Добави в любими</span>');
242			}
243
244		}).fail(function() {
245			
246		});
247
248	});
249	
250	$('body').on(clicktouch, '.report-abuse-form-send-btn', function (e) {
251		e.preventDefault();
252
253		var type = $('input[name=abuseType]:checked').val();
254		var text = $('#otherTextField').val();
255		
256		if ('other' == type && text.length < 20) {
257			alert("Обясни защо алармираш този клип в полето. (с поне 20 символа)");
258			return false;
259		}
260		
261		$.ajax({
262			url : "/aj/item/add-abuse",
263			dataType: "json",
264			type: "POST",
265			data : {
266				id : $('#itemId').val(),
267				type : type,
268				text : text
269			}
270		}).done(function(data) {
271
272			alert(data.message);
273			if (false == data.success) {
274				return false;
275			} else {
276				$('#user_abuseReport_text').val('');
277				$('#reportVideo').remove();
278			}
279
280		}).fail(function() {
281			
282		});
283		
284		return true;
285	});
286	
287	$('#hasUsername').keyup(function(e) {
288		e.preventDefault();
289
290		var that = $(this);
291		var container = that.closest('.field-wrap');
292
293		$.ajax({
294			url : "/aj/hasUsername",
295			dataType: "json",
296			type: "POST",
297			data : {
298				username : that.val()
299			}
300		}).done(function(data) {
301			
302			if (false == data.success) {			
303				container.find('.note.err').remove();
304				container.removeClass('field-err');
305				container.find('.note.err').remove();
306				return false;
307			} else {
308				var html = '<p class="note err">Потребителското име е заето</p>';
309				container.find('.note.err').remove();
310				container.find('.icon-edit').after(html);
311				container.addClass('field-err');
312			}
313
314		}).fail(function(jqXHR, textStatus, errorThrown) {		
315			var obj = JSON.parse(jqXHR.responseText);
316			var error = obj.errors.username[0];
317			var html = '<p class="note err">' + error + '</p>';
318			container.find('.note.err').remove();
319			container.find('.icon-edit').after(html);
320			container.addClass('field-err');
321		});
322		
323		return true;
324	});
325	
326	var sendingvote = false;
327	$('body').on(clicktouch, '.play-vote', function (e) {
328		e.stopPropagation();
329		e.preventDefault();
330        $('.moreLoadingBox').hide();
331        
332		if (sendingvote) {
333			return false;
334		}
335		sendingvote = true;
336
337		var obj = $(this);
338
339		var hasvoted = false;
340		$('.play-vote').each(function (index) {
341			if ($(this).hasClass('voted')) {
342				hasvoted = true;
343			}
344		});
345		if (hasvoted)
346			return false;
347
348		itemId = $(this).attr('data-id');
349
350		params = {
351			itemId: itemId,
352            reaction: $(this).attr('data-reaction')
353		}
354
355		$.post('/aj/item/vote', params, function (data) {
356			sendingvote = false;
357			if (false == data.success) {
358				alert(data.message);
359			} else {
360				$(obj).addClass('voted');
361                $(obj).parent('.react-buttons').addClass('reacted');
362				var score = parseInt($(obj).find('.icon-like-num').html());
363				score++;
364				$(obj).find('.icon-like-num').html(score);
365			}
366		})
367        
368        
369	});
370	
371	$('body').on(clicktouch, '.playlist-delete', function(e) {
372		e.preventDefault();
373
374		var playlistId = $(this).attr('data-id');
375		var playlistName = $(this).attr('data-name');
376		
377		confirmModal("", 'Моля, потвърди изтриването на плейлиста "'+ playlistName +'"', "Да", "Не" );
378		
379
380		$('body').on(clicktouch, '.dialog-confirmation-cancel, .dialog-close', function() {
381			return false;
382		});
383
384		$('body').on('click', '.dialog-confirmation-confirm', function(e) {
385			e.preventDefault();
386
387			$('.moreLoadingBox').show();
388
389			$.ajax({
390				url : "/aj/playlist/delete",
391				dataType: "json",
392				type: "POST",
393				data : {
394					playlistId: playlistId
395				}
396			}).done(function(data) {
397
398				if (false == data.success) {
399					alert(data.message);
400				} else {
401					alert(data.message);
402					location.href = '/user:' + globalLoginUser + '?p=playlists'
403				}
404
405			}).fail(function() {
406
407			});
408
409			$('.moreLoadingBox').hide();
410
411			return true;
412		});
413	});
414	
415	$('body').on(clicktouch, '.copy-pls', function (e) {
416		e.preventDefault();
417		e.stopPropagation();
418		
419		var playlistId = $(this).attr('data-id');
420
421		$('.moreLoadingBox').show();
422
423		$.ajax({
424			url : "/aj/playlist/copy",
425			dataType: "json",
426			type: "POST",
427			data : {
428				playlistId: playlistId
429			}
430		}).done(function(data) {
431
432			if (false == data.success) {
433				alert(data.message);
434			} else {
435				alert(data.message);
436			}
437
438		}).fail(function() {
439
440		});
441
442		$('.moreLoadingBox').hide();
443
444	});
445	
446	$('body').on(clicktouch, '#calculateResult:not(.disabled)', function (event) {
447		event.stopPropagation();
448		event.preventDefault();
449		
450		var submitBtnEl = $('#calculateResult');
451		var params = $('#quizForm').serializeArray();
452		var formData = {};
453		for (var i = 0; i < params.length; i++) {
454			formData[params[i].name] = params[i].value;
455		}
456		
457		$.ajax({
458			url: '/aj/quiz/results',
459			data: formData,
460			dataType: 'json',
461			method: 'POST',
462			beforeSend: function (data, textStatus, jqXHR) {
463				submitBtnEl.hide();
464			}
465		}).done(function (data) {
466			if (false == data.success) {
467				console.log(data.error);
468				return false;
469			} else {
470				$('#quizResult').html(data.html);
471				$('#quizResult').css('display', 'block');
472				if (typeof $('.right-cont .item-wrapper').val() !== 'undefined') {
473					$('.right-cont .item-wrapper').animate({scrollTop: $('.right-cont .scroll-content').scrollTop() + $('#quizResult').offset().top - $('header.fixed-cont').height() - 40}, 200);
474				} else {
475					$('body, html').animate({scrollTop: $('#quizResult').offset().top - 88}, 200);
476				}
477				return true;
478			}
479		}).fail(function (data) {
480			console.log('Получи се грешка, опитай отново по-късно.');
481		}).always(function (jqXHR, textStatus, errorThrown) {
482			$('.moreLoadingBox').hide();
483		});
484	});
485
486	$('body').on(clicktouch, 'label.answer', function (event) {
487		$(this).closest('.answers-cont').addClass('answrd');
488	});
489	
490	// Remove video from playlist
491	$('body').on(clicktouch, '.user-playlist-video-delete', function(e) {
492		e.preventDefault();
493		obj = this;
494		
495		confirmModal("", 'Моля, потвърди изтриването на клипа от плейлиста', "Да", "Не" );
496
497		$('body').on(clicktouch, '.dialog-confirmation-cancel, .dialog-close', function() {
498			return false;
499		});
500		
501		$('body').on('click', '.dialog-confirmation-confirm', function(e) {
502			e.preventDefault();
503
504			params = {
505				playlistId: $(obj).attr('data-playlist-id'),
506				videoId: $(obj).attr('data-video-id')
507			}
508
509			$.post('/aj/playlist/video/remove', params, function(data) {
510				if (false == data.success) {
511					alert('Получи се грешка, опитай отново по-късно.');	
512				} else {
513					$(obj).parent().remove();
514					$('.total-vid').html($('.total-vid').text() - 1)
515				}
516
517			});
518
519		});
520	});
521	
522	$('body').on(clicktouch, '.pls-shuffle', function (e) {
523		e.stopPropagation();
524		e.preventDefault();
525
526		if ($(this).hasClass('on')) {
527			loadPlaylistVideos($(this).attr('data-href'));
528		} else {
529			loadPlaylistVideos($(this).attr('data-href'));
530		}
531		
532		$(this).toggleClass('on');
533	});
534	
535	$('body').on(clicktouch, '.pls-loop', function (e) {
536		e.stopPropagation();
537		e.preventDefault();
538		
539		var obj = $(this);
540		
541		$.ajax({
542			url : "/aj/playlist/loop",
543			dataType: "json",
544			type: "GET",
545			data : {
546				playlistId: obj.attr('data-id')
547			}
548		}).done(function(data) {
549
550			if (true == data.success) {
551				obj.toggleClass('on');
552			}
553
554		}).fail(function() {
555
556		});
557
558		
559	});
560	
561	$('body').on(clicktouch, '#notificationBell', function (e) {
562		e.stopPropagation();
563		e.preventDefault();
564		
565		$('.moreLoadingBox-small').show();
566
567		$.ajax({
568			url : "/aj/user/get-notifications",
569			dataType: "json",
570			type: "GET",
571		}).done(function(data) {	
572			  $('.moreLoadingBox-small').hide();	
573			if (data.success) {
574				
575				$('#notifications').html(data.html);	
576			}
577		}).fail(function() {
578			  $('.moreLoadingBox-small').hide();
579
580		});
581		
582	});
583	
584	var lastPreview = null;
585	var and = getAndroidVersion();
586	var delay = 200, setTimeoutConst;
587	if (!and || parseInt(and, 10) >= 7) {
588        
589		$('body').on('mouseenter', '.prw', function (e) {
590			var that = $(this);
591			
592			if (lastPreview && lastPreview != that) {
593				$(".hadiv").remove();
594			}
595			
596			setTimeoutConst = setTimeout(function() {
597				if (lastPreview != that) {
598					var mdkey = getMdkeyFromUrl(that.attr('href'));
599					if (mdkey) {
600						$.ajax({
601							url : "/aj/item/preview",
602							dataType: "json",
603							type: "GET",
604							data: { mdkey : mdkey},
605						}).done(function(data) {
606							if (data.success) {
607								that.append(data.html);	
608								$(".hadivvid").show();
609								lastPreview = that;
610							}
611						}).fail(function() {
612
613						});
614
615
616					}
617				}
618			}, delay);
619  		
620		});
621        
622        $('body').on('mouseleave', '.prw', function (e) {
623           clearTimeout(setTimeoutConst );
624        });     
625	}
626	
627	$('body').on(clicktouch, '.deleteMessage', function (e) {
628		e.stopPropagation();
629		e.preventDefault();
630		
631		var obj = $(this);
632		
633		$.ajax({
634			url : "/aj/pm/delete/message",
635			dataType: "json",
636			type: "POST",
637			data : {
638				msgid: obj.attr('data-id')
639			}
640		}).done(function(data) {
641
642			if (true == data.success) {
643				obj.toggleClass('on');
644			}
645
646		}).fail(function() {
647
648		});
649	})
650	
651	//block user ---
652	$('body').on(clicktouch, '.block-unblock', function (e) {
653		e.preventDefault();		
654		$.ajax({
655			url : '/aj/block/loadform',
656			dataType: 'json',
657			type: 'POST',
658			data : {
659				blockedUser: $(this).attr('data-uploader-name')
660			}
661		}).done(function(data) {			
662			if (false == data.success) {
663				return false;
664			} else {
665				addModal(data.html);
666			}
667		});		
668	});
669	
670	var playerFocused = false;
671	
672	$('body').on('focusin', '.video-player', function (e) {
673		playerFocused = true;
674	});	
675	
676	$('body').on('focusout', '.video-player', function (e) {
677		playerFocused = false;
678	});	
679	
680	$('body').on('keydown', function(e) {		
681		if(e.keyCode == 32 && playerFocused){
682			e.preventDefault();
683			e.stopPropagation();
684		}
685	});	
686	
687	$('body').on( "keyup", function(e) {		
688		if (!playerFocused) return true;
689		
690		if(e.keyCode == 32){
691			// user has pressed space
692			$('#html5player').vboxMediaPlayer.extPlayPause();
693		} else if(e.keyCode == 13){
694			// user has pressed enter
695			$('#html5player').vboxMediaPlayer.extGoFullscreen();
696		} else if(e.keyCode == 13 || e.keyCode == 70){
697			// user has pressed enter or letter F
698			$('#html5player').vboxMediaPlayer.extGoFullscreen();
699		} else if(e.keyCode == 27){
700			// user has pressed escape
701			if (navigator.userAgent.toLowerCase().indexOf('msie') > -1 || navigator.userAgent.toLowerCase().indexOf('trident') > -1)
702				$('#html5player').vboxMediaPlayer.extOutFullscreen();
703		} else if (e.keyCode == 37) {
704			//left
705			$('#html5player').vboxMediaPlayer.extSeekBackward();
706		} else if (e.keyCode == 38) {
707			//up
708			$('#html5player').vboxMediaPlayer.extVolUp();
709		} else if (e.keyCode == 39) {
710			//right
711			$('#html5player').vboxMediaPlayer.extSeekForward();
712		} else if (e.keyCode == 40) {
713			//down
714			$('#html5player').vboxMediaPlayer.extVolDown();
715		}
716		
717	});
718    
719    $('body').on('click', '.subtitle-delete', function(e) {
720		e.preventDefault();
721		e.stopPropagation();
722		e.stopImmediatePropagation();
723
724		var that = $(this);
725	
726		var subsid = that.attr('data-id');
727
728		var params = {subsid: subsid};
729
730        confirmModal("Внимание", "Потвърди изтриването", "Да", "Не" );	
731
732		$('body').on(clicktouch, '.dialog-confirmation-cancel, .dialog-close', function() {
733			return false;
734		});
735        
736        $('body').on(clicktouch, '.dialog-confirmation-confirm', function(e) {
737
738            $.ajax({
739                url : '/aj/subtitle/destroy',
740                dataType: 'json',
741                type: 'POST',
742                data: params,
743                beforeSend : function(data, textStatus, jqXHR) {
744                    that.css('pointer-events', 'none'); // prevent multiple tap/click which will make multiple ajax requests
745                } 
746            }).done(function(data, textStatus, jqXHR) {
747                if(data.success) {
748                    //OK
749                    that.closest('.video-cell').remove();
750                } else if (data.hasOwnProperty('msg')) {
751                    alert(data.msg);
752                }
753            }).fail(function (jqXHR, textStatus, errorThrown) {
754                //Error
755                console.log('we are in error!');
756            }).always(function (jqXHR, textStatus, errorThrown) {
757                that.css('pointer-events', 'auto');  
758            });
759        });
760	})
761	//<<< EVENTS
762	
763});
764

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.