PageSourceSearch

https://6packrick.com/main.js

js 6packrick.com collected 2026-10-01 03:07:27 UTC 30,448 bytes, 1,053 lines download raw bytes

1// ajax token
2$.ajaxSetup({
3    headers: {
4        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
5    }
6});
7
8//read-more
9$(document).on('click', '.read-more', function(){
10	var prev;
11	prev = $(this).prev();
12	prev.css("height", "auto");
13	$(this).hide();
14});
15
16//block-user
17$(document).on('click', '.block-user', function(){
18	var id = $(this).data('id');
19    $.ajax({
20	      url: '/comment/block-user',
21	      type: 'post',
22	      data: {id : id},
23	      success: function(data) {
24    	      if(data.status == 'success'){
25    	    	  $('.block-user[data-id="' + id + '"]').html('<i class="fas fa-fw fa-lg fa-ban" aria-hidden="true"></i> UNBLOCK USER').addClass('unblock-user').removeClass('block-user');
26    	      }
27	    	  show_message(data.msg);
28	      }
29    });
30});
31
32//unblock-user
33$(document).on('click', '.unblock-user', function(){
34	var id = $(this).data('id');
35    $.ajax({
36	      url: '/comment/unblock-user',
37	      type: 'post',
38	      data: {id : id},
39	      success: function(data) {
40    	      if(data.status == 'success'){
41    	    	  $('.unblock-user[data-id="' + id + '"]').html('<i class="fas fa-fw fa-lg fa-ban" aria-hidden="true"></i> BLOCK USER').addClass('block-user').removeClass('unblock-user');
42    	      }
43	    	  show_message(data.msg);
44	      }
45    });
46});
47
48//menu mobile
49var lastScrollTop = window.scrollY;
50var diff = 0;
51$(window).scroll(function(event){
52	if(window.innerWidth < 768){
53	   var st = $(this).scrollTop();
54	   if (st > lastScrollTop){
55	       // downscroll code
56		   diff = st - lastScrollTop;
57		   if(diff >= 100){
58			   $('.navbar').hide();
59			   lastScrollTop = st;
60		   }
61	   } else {
62		   diff = lastScrollTop - st;
63	      // upscroll code
64		   if(diff >= 100){
65		   		$('.navbar').show();
66		   		lastScrollTop = st;
67		   }
68	   }
69	   
70		if(window.location.hash.length > 0)
71	   	{
72			$('.navbar').show();
73		}
74	}
75});
76
77//user hide
78$(document).on('click', '.user-hide', function(e){
79	
80	var id = $(this).data('id');
81	
82    $.ajax({
83        url: '/user/hide/' + id,
84        type: 'post',
85        dataType : 'json',
86        data : { reason : 1},
87        success: function(data) {
88        	$('.user-hide-' + id).addClass('btn-grey').removeClass('btn-pink');
89        	$('.user-hide-' + id).html('<i class="fa fa-eye-slash pink"></i> HIDDEN');
90        	$('.user-hide-' + id).addClass('user-show').removeClass('user-hide');
91        	$('.user-follow-' + id).hide();
92	    	  	show_message("User content hidden");
93        },
94	     	error:function(data){
95         	console.log(data.responseJSON.message);
96        }
97	});
98	
99});
100
101//user-hide
102$(document).on('click', '.user-show', function(e){
103	
104    var id = $(this).data('id');
105	
106    $.ajax({
107        url: '/user/show/' + id,
108        type: 'post',
109        dataType : 'json',
110        success: function(data) {
111        	$('.user-hide-' + id).addClass('btn-pink').removeClass('btn-grey');
112        	$('.user-hide-' + id).html('<i class="fa fa-eye-slash"></i>');
113        	$('.user-hide-' + id).addClass('user-hide').removeClass('user-show');
114        	$('.user-follow-' + id).show();
115        	show_message("User content visible");
116        },
117	     	error:function(data){
118         	console.log(data.responseJSON.message);
119        }
120	});
121});
122
123//user follow
124$(document).on('click', '.user-follow', function(e){
125	
126	var id = $(this).data('id');
127	
128    $.ajax({
129	      url: '/user/follow/' + id,
130	      type: 'post',
131	      success: function(data) {
132	    	  $('.user-follow-' + id).removeClass('btn-pink').addClass('btn-grey').removeClass('user-follow').addClass('user-unfollow').html('<i class="fa fa-check pink"></i> FOLLOWING');
133	    	  $('.user-hide').hide();
134	      }
135	});
136});
137
138//user unfollow
139$(document).on('click', '.user-unfollow', function(e){
140	
141	var id = $(this).data('id');
142	
143    $.ajax({
144	      url: '/user/unfollow/' + id,
145	      type: 'post',
146	      success: function(data) {
147	    	  $('.user-follow-' + id).removeClass('btn-grey').addClass('btn-pink').removeClass('user-unfollow').addClass('user-follow').html('<i class="fa fa-plus"></i> FOLLOW');
148	    	  $('.user-hide').show();
149	      }
150	});
151});
152
153//album like
154$(document).on('click', '.album-like', function(e){
155	
156	var target = $(this);
157    
158    $.ajax({
159        url: '/album/like/' + target.data('id'),
160        type: 'post',
161        dataType : 'json',
162        success: function(data) {
163          target.removeClass('album-like').addClass('album-unlike');
164          target.find('b').html(data.content);
165          target.find('i').removeClass('far').addClass('fas').addClass('pink');
166        },
167	     	error:function(data){
168         	console.log(data.responseJSON.message);
169        }
170	});
171});
172
173//album unlike
174$(document).on('click', '.album-unlike', function(e){
175	
176	var target = $(this);
177    
178    $.ajax({
179        url: '/album/unlike/' + target.data('id'),
180        type: 'post',
181        dataType : 'json',
182        success: function(data) {
183          target.removeClass('album-unlike').addClass('album-like');
184          target.find('b').html(data.content);
185          target.find('i').removeClass('fas').addClass('far').removeClass('pink');
186        },
187	     	error:function(data){
188         	console.log(data.responseJSON.message);
189        }
190	});
191});
192
193//album save
194$(document).on('click', '.album-save', function(e){
195	
196	var target = $(this);
197	
198    $.ajax({
199	      url: '/album/save/' + target.data('id'),
200	      type: 'post',
201	      success: function(data) {
202	    	  
203	          target.removeClass('album-save').addClass('album-unsave');
204	          target.find('b').html('SAVED');
205	          target.find('i').removeClass('far').addClass('fas').addClass('pink');
206	          show_message("Album saved");
207	      }
208	});
209});
210
211//album unsave
212$(document).on('click', '.album-unsave', function(e){
213	
214	var target = $(this);
215	
216    $.ajax({
217	      url: '/album/unsave/' + target.data('id'),
218	      type: 'post',
219	      success: function(data) {
220	    	  
221	          target.removeClass('album-unsave').addClass('album-save');
222	          target.find('b').html('SAVE');
223	          target.find('i').removeClass('fas').addClass('far').removeClass('pink');
224	          show_message("Album unsaved");
225	      }
226    });
227});
228
229
230//gotop
231$(window).scroll(function() {
232	var w = $( document ).width();
233	
234	if($(window).scrollTop() < 100){
235		$('#bubble').css('bottom', '10px');
236		$('#goTop').hide();
237	} else {
238		if(w > 820){
239			$('#bubble').css('bottom', '50px');
240			$('#goTop').show();
241		}
242	}
243});
244
245$('#goTop').on('click', function(e){
246	e.stopPropagation();
247	$(window).scrollTop(0);
248});
249
250//autocomplete
251var globalTimeout = null;
252$(document).on('keyup', '#q', function (e){
253	var charCode = e.which || e.keyCode;
254	if(charCode != 38 && charCode != 40 && charCode != 13){
255		var search = $(this).val();
256		if (globalTimeout != null) {
257			clearTimeout(globalTimeout);
258		}
259		globalTimeout = setTimeout(function() {
260		    globalTimeout = null;
261			if(search.length >= 2)
262			{
263		        $.ajax({
264		        	url: "/search/autocomplete",
265		            dataType: "json",
266		            method: "POST",
267		            data: {
268		            	q: search
269		            },
270		            success: function( data ) {
271		            	$('#suggestions').empty();
272		            	$('#suggestions').append( '<p class="search-completions" ><i class="fa fa-search" ></i> <span>' + search + '</span></p>');
273		            	$.each(data, function(index, suggestion) {
274			
275							if(suggestion.type == 'user'){
276			            		var content = '<p class="user-completions" >';
277			            		if(suggestion.avatar != ''){
278			            			content = content + '<img src="' + suggestion.avatar + '" >';
279			            		} else {
280			            			content = content + '<i class="fa fa-user-circle" ></i>';
281			            		}
282			            		content += '<span>' + suggestion.name + '</span>';
283			            		if(suggestion.verified){
284			            			content += '<i class="fas fa-check-circle ero-badge"></i>';
285			            		}
286			            		content += '</p>';
287			            		
288			            		
289			            		$('#suggestions').append(content);
290							} else {
291								$('#suggestions').append( '<p class="search-completions" ><i class="fa fa-hashtag" ></i> <span>' + suggestion.search + ' </span></p>');
292							}
293		            	});
294		            }
295		          });
296			} else {
297				$('#suggestions').empty();
298			}
299		}, 300);
300	}
301});
302
303//search modal
304/*
305$('#searchModal').on('shown.bs.modal', function () {
306		
307		if(!mobile)
308		{
309			$('#q').focus();
310		}
311		
312		if($('#q').val() == '' && $('#suggestions p').length == 0){
313		
314		$.getJSON("/search/trends", function(data) {
315			$.each(data, function(key, search) {
316				if(search.type == 'trend')
317				{
318			    	$('#suggestions').append( '<p class="search-completions" ><i class="fa fa-hashtag" ></i> <span>' + search.search + '</span></p>');
319				} else {
320			    	$('#suggestions').append( '<p class="search-completions" ><i class="fa-solid fa-clock-rotate-left"></i> <span>' + search.search + '</span><i class="fa-solid fa-xmark"></i></p>');
321				}
322			});
323		});
324	}
325});*/
326
327
328//suggestions
329$(document).on('keydown', '#q', function (e){
330	var charCode = e.which || e.keyCode;
331	if(charCode == 38 || charCode == 40 || charCode == 13){
332		e.preventDefault();
333		selectedIndex = $('#suggestions p.selected').index();
334		
335		if(charCode == 13){
336			if(selectedIndex >= 1 && selectedIndex < $('#suggestions p').length){
337				$('#suggestions p:eq(' + selectedIndex + ')').click();
338			} else {
339				$('#searchForm').submit();
340			}
341		}
342		
343		if(charCode == 40){
344			if(selectedIndex >= 0){
345				if(selectedIndex < $('#suggestions p').length - 1){
346					$('#suggestions p:eq(' + selectedIndex + ')').removeClass('selected');
347					$('#suggestions p:eq(' + parseInt(selectedIndex + 1) + ')').addClass('selected');
348				}
349			} else {
350				$('#suggestions p:eq(0)').addClass('selected');
351			}
352		}
353		
354		if(charCode == 38){
355			if(selectedIndex > 0){
356				$('#suggestions p:eq(' + selectedIndex + ')').removeClass('selected');
357				$('#suggestions p:eq(' + parseInt(selectedIndex - 1) + ')').addClass('selected');
358			} else {
359				$('#suggestions p:eq(' + selectedIndex + ')').removeClass('selected');
360			}
361		}
362	}
363});
364
365/*$(document).on('click', '#q', function (e){
366	if($('#q').val() == '' && $('#suggestions .fa-clock-rotate-left').length == 0){
367		$.getJSON("/search/recents", function(data) {
368	    	$('#suggestions').empty();
369			$.each(data, function(key, search) {
370		    	$('#suggestions').append( '<p class="search-completions" ><i class="fa-solid fa-clock-rotate-left"></i> <span>' + search + '</span><i class="fa-solid fa-xmark"></i></p>');
371			});
372		});
373	}
374});*/
375
376$(document).on('click', '#suggestions .fa-xmark', function (e){
377	e.stopPropagation();
378	
379	var item = $(this);
380	var n = item.parent().find('span').text();
381	
382    $.ajax({
383		url: "/search/remove",
384	    dataType: "json",
385	    method: "POST",
386	    data: {
387	    	n: n
388	    },
389	    success: function( data ) {
390			if(data.status == 'success'){
391				item.parent().remove();
392			}
393		}
394	});
395	
396});
397
398$(document).on('click', '#searchForm .input-group-addon', function (e){
399	if($('#q').val() != ''){
400		var n = $('#q').val();
401		location.href = "/search?q=" + n;
402	}
403});
404$(document).on('click', '#suggestions .user-completions', function (e){
405	var n = $(this).find('span').text();
406	location.href = "/" + n;
407});
408$(document).on('click', '#suggestions .search-completions', function (e){
409	var n = $(this).find('span').text();
410	location.href = "/search?q=" + n.replace(/\s+/g, '+');
411});
412$(window).click(function() {
413	//$('#suggestions').empty();
414});
415$(document).on('click', '#suggestions', function (e){
416	e.stopPropagation();
417});
418
419
420
421$(document).on('click', '#copyButton', function(e){
422	$('#copy').select();
423	document.execCommand( 'copy' );
424});
425
426$(document).on('click', '.media-share', function(e){
427	e.preventDefault();
428	$('#dialogModal .modal-content').load('/media/share/' + $(this).attr('id').substr(12));
429	$('#dialogModal').modal('show');
430});
431
432
433//img
434var el = document.querySelectorAll('img');
435for (var i = 0 ; i < el.length ; i++) {
436    el[i].addEventListener('mousedown', function(e){
437      e.preventDefault();
438       
439    }, false);
440    el[i].addEventListener('mousemove', function(e){
441      e.preventDefault();
442       
443    }, false);
444}
445
446// privacy
447$(document).on('click', '.album-privacy', function(e){
448    $.ajax({
449	      url: '/album/privacy/update/' + $(this).attr('id').substring(14) + '/' + $(this).attr('data-privacy'),
450	      type: 'get',
451	      success: function(data) {
452	    	  $('#album-privacy-' + data.album_guid).attr('data-privacy', data.privacy);
453	    	  if(data.privacy == 0){
454	    		  $('#album-privacy-' + data.album_guid).empty().html('<i class="fa fa-lg fa-globe" aria-hidden="true"></i> MAKE PUBLIC');
455	    	  } else {
456	    		  $('#album-privacy-' + data.album_guid).empty().html('<i class="fa fa-lg fa-eye-slash" aria-hidden="true"></i> MAKE PRIVATE');
457	    	  }
458	    	  $('.username').html(data.html);
459	    	  show_message("Album privacy updated");
460	      }
461	});
462});
463
464//album flag
465$(document).on('click', '.album-flag', function(e){
466	e.preventDefault();
467	var id = $(this).attr('id');
468    $.ajax({
469    	url: '/user/check/',
470    	type: 'post',
471  		data:$(this).serialize(),
472  		success: function(data) {
473  			if(data.status == "success"){
474  				$('#dialogModal .modal-content').load('/album/flag/' + id.substring(11));
475  				$('#dialogModal').modal('show');
476  			} else {
477  				show_message(data.error);
478  			}
479  		}
480	});
481});
482
483$(document).on('submit', '#album-flag-form', function(e){
484    e.preventDefault();
485    if (!$("input[name='flag']:checked").val()) {
486        show_message("Please choose a reason");
487    } else {
488        $.ajax({
489	      url: '/album/flag/' + $("input[name='album_id']").val(),
490	      type: 'post',
491              data:$(this).serialize(),
492	      success: function(data) {
493                  $('#dialogModal').modal('hide');
494	    	  show_message("Album flagged");
495	      }
496	});
497    }
498});
499
500
501
502//user message
503function show_message(text){
504	$("#user_message").empty().text(text).show().delay(2000).fadeOut();
505}
506
507//Album title editable
508function update_title(){
509    $.ajax({
510	      url: '/album/update_title',
511	      type: 'get',
512	      data: {guid : $('#album_guid').val(), title : $('#album_title').val()},
513	      success: function(data) {
514	    	  if(data.status == 'success'){
515	    		  show_message(data.msg);
516	    	  }
517	    	  if (typeof data.title !== 'undefined') {
518		    	  $('#album_title').val(data.title);
519		    	  $('#title_editable').text(data.title);
520	    	  }
521	      }
522    });
523}
524
525$(document).on('blur', '#title_editable', function(e){
526	$('#album_title').val($(this).text());
527	update_title();
528});
529
530$(document).on('blur', '#album_title', function(e){
531	update_title();
532});
533
534//Media title editable
535$(document).on('blur', '.media-title', function(e){
536	var media_id = $(this).attr('id').substring(12);
537    $.ajax({
538	      url: '/media/title/update/' + media_id,
539	      type: 'get',
540	      data: {title : $(this).text()},
541	      success: function(data) {
542	    	  if(data.status == 'success'){
543	    		  show_message(data.msg);
544	    	  }
545	      }
546	});
547});
548
549//focus end contenteditable
550function placeCaretAtEnd(el) {
551    el.focus();
552    if (typeof window.getSelection != "undefined"
553            && typeof document.createRange != "undefined") {
554        var range = document.createRange();
555        range.selectNodeContents(el);
556        range.collapse(false);
557        var sel = window.getSelection();
558        sel.removeAllRanges();
559        sel.addRange(range);
560    } else if (typeof document.body.createTextRange != "undefined") {
561        var textRange = document.body.createTextRange();
562        textRange.moveToElementText(el);
563        textRange.collapse(false);
564        textRange.select();
565    }
566}
567
568//content editable
569$('.album-title').on('keypress input paste', function(e) {
570	if(e.which == 13) {
571		e.preventDefault();
572		$(this).blur();
573	}
574	if($(this).text().length >= 100) { 
575		$(this).text($(this).text().substring(0, 100));
576		placeCaretAtEnd($(this).get(0));
577	}
578});
579
580//upload
581$(document).on('click', '#add_more_box', function(e){
582	$( "#add_more_file" ).click();
583});
584
585$(document).on('change', '#add_more_file',function(e){
586	$('#add_more_form').submit();
587});
588
589function upload(file){
590    var type = 'bad';
591    switch(file.type)
592    {
593        case 'image/png': 
594        case 'image/jpeg':
595        	type = 'image';
596        	break;
597        case 'video/mp4':
598        case 'video/avi':
599        case 'video/quicktime':
600        case 'video/mpeg':
601        case 'video/x-flv':
602        case 'video/webm':
603        case 'video/3gpp':
604        case 'video/x-ms-wmv':
605        case 'image/gif':
606        case 'video/x-matroska':
607        	type = 'video';
608        	break;
609    }
610    
611    if(type != 'bad'){
612    	if($('#album_title').val() == ""){
613    		var album_title = file.name
614    		var album_title = album_title.substr(0, album_title.lastIndexOf('.')) || album_title;
615    		$('#album_title').val(album_title);
616    		update_title();
617    	}
618    	
619	    var n = parseInt($( "#n" ).val()) + 1;
620	    $( "#n" ).val(n);
621
622	    $( "#medias" ).append('<div id="upload-' + n + '" class="upload"><img class="uploading-img" src="/img/uploading.png" ></div>');
623		$( "#medias" ).append('<div id="progress-box-' + n + '" ><div class="progress-pourcent" id="progress-pourcent-' + n + '" ></div><div id="progress-bar-' + n + '" class="progress-bar" ></div></div>');
624	    $("html, body").animate({ scrollTop: 10000000 }, 100);
625    
626	    var fd = new FormData();
627	    fd.append("media", file);
628	    fd.append("album_guid", $('#album_guid').val());
629	    fd.append("n", n);
630
631	    $.ajax({
632	      url: '/upload',
633	      xhr: function() {
634	           var xhr = new XMLHttpRequest();
635	           var total = file.size;
636	                    
637	           xhr.upload.addEventListener("progress", function(evt) {
638	                  var loaded = Math.round((evt.loaded / total).toFixed(2)*100);
639	                  $('#progress-bar-' + n).css('width', loaded + '%');
640	                  if(loaded >= 100){
641	                	  loaded = 100;
642	                	  $('#progress-pourcent-' + n).text('Processing' );
643	                  } else{
644	                	  $('#progress-pourcent-' + n).text(loaded + '%' );
645	                  }
646	           }, false);
647
648	           return xhr;
649	      },
650	      type: 'post',
651	      processData: false,
652	      contentType: false,
653	      data: fd,
654	      success: function(data) {
655			  if(data.status == 'success'){
656		  	      $.ajax({
657		  	    	  url: '/media/load/' + data.media_id,
658		  	    	  success: function(data) {	
659		  	    		  $( "#upload-" + n ).css('min-height', $( "#upload-" + n ).height() + 'px');
660		  	    		  $( "#upload-" + n ).html(data.html)
661		  	    		  $('#progress-box-' + n).hide();
662		  	    		  $( "#upload-" + n ).css('min-height', 'auto');
663		  	    		  if(data.media_type == 2 && data.media_extension == 'mp4' && data.media_playable == 1){
664		  	    			  videojs("player-" + data.media_id, {}, function(){});
665		  	    		  }
666		  	    	  }
667		  	      });
668				} else {
669					show_message(data.msg);
670					$( "#upload-" + n ).remove();
671					$('#progress-box-' + n).remove();
672				}
673	      }
674	    });
675    } else {
676    	show_message("Format not supported");
677    }
678}
679
680$('#add_more_form').submit(function(e) {
681    e.preventDefault();
682    var total_file = $('#add_more_file')[0].files.length + parseInt($( "#n" ).val());
683    if(total_file <= 100){
684    	var too_big = false;
685    	$.each( $('#add_more_file')[0].files, function( key, file ) {
686        	if (file.size > 2147483648){
687//        		if (file.size > 1073741824){
688        		too_big = true;
689        	}
690        });
691    	if(too_big == false){
692    	    $.each( $('#add_more_file')[0].files, function( key, file ) {
693    	    	upload(file);
694    	    });
695    	} else{
696    		show_message("2Go per files maximum");
697    	}
698	} else {
699		show_message("100 files per album maximum");
700	}
701});
702
703//album thumbnails rotation
704var timer;
705$(document).on('mouseover', '#albums .album', function(e){
706	clearInterval(timer);
707	var item = $(this);
708	item.find('.album-thumbnail').each(function(){
709		if($(this)[0].hasAttribute('data-rotate-src'))
710		{
711			$(this).attr('src', $(this).attr('data-rotate-src'));
712			$(this).removeAttr('data-rotate-src'); 
713		}
714	});
715	
716	timer = setInterval(function(){
717		active = 0;
718		item.find('.album-thumbnail').each(function(){
719			if(active == 1){
720				$(this).addClass('active');
721				active = 0;
722				return false;
723			}
724			if($(this).hasClass('active')){
725				$(this).removeClass('active');
726				active = 1;
727			}
728		});
729		if(active == 1){
730			item.find('.album-thumbnail:eq( 0 )').addClass('active');
731		}
732	}, 500, item);
733});
734
735$(document).on('mouseout', '#albums .album', function(e){
736	clearInterval(timer);
737});
738
739/**$(document).on('click', '.album-thumbnail', function(e){
740	$(this).parent().parent().find('a')[0].click();
741});
742*/
743
744//album delete
745$(document).on('click', '.delete-album', function(e){
746    $.ajax({
747	      url: '/album/delete/' + $('#album_id').val(),
748	      type: 'get',
749	      success: function(data) {
750//	    	  $('#album-' + data.album_id).remove();
751//	    	  $('#delete_confirm').modal('hide');
752	    	  if(data.status == 'success'){
753	    		  window.location.href = "/" + data.user_name;
754	    	  } else {
755	    		  $('#delete_confirm').modal('hide');
756	    	  }
757	      }
758    });
759});
760
761$(document).on('click', '.album-delete', function(e){
762	e.preventDefault();
763	$('.modal-content').empty();
764	$('.modal-content').load($(this).attr('data-delete'));
765	$('#delete_confirm').modal('show');
766});
767
768//media delete
769$(document).on('click', '.media-delete', function(e){
770	e.preventDefault();
771	$('#dialogModal .modal-content').load('/media/delete-confim/' + $(this).attr('id').substr(13));
772	$('#dialogModal').modal('show');
773});
774$(document).on('click', '.media-delete-confirm', function(e){
775    $.ajax({
776	      url: '/media/delete/' + $('#media_id').val(),
777	      type: 'get',
778	      success: function(data) {
779	    	  if(data.status == "success"){
780	    		  $('#' + data.media_guid).remove();
781	    		  $('#dialogModal').modal('hide');
782	    	  } else {
783	    		  show_message(data.msg);
784	    	  }
785	      }
786    });
787});
788
789//media rotate
790$(document).on('click', '.media-rotate', function(e){
791	e.preventDefault();
792	var media_id = $(this).attr('id').substr(13);
793    $.ajax({
794	      url: '/media/rotate/' + media_id,
795	      type: 'get',
796	      success: function(data) {
797	    	  d = new Date();
798	    	  var src = $('#' + data.media_guid + ' .img-front').attr('src');
799	    	  $('#' + data.media_guid + ' .img-front').attr('src', src.substr(0, src.indexOf('?')) + '?v=' + d.getTime());
800	    	  $('#' + data.media_guid + ' .img-back').attr('src', src.substr(0, src.indexOf('?')) + '?v=' + d.getTime());
801	      }
802  });
803});
804
805
806// drop area
807$('.droparea').on('dragover', function(e) {
808    e.preventDefault();
809    e.stopPropagation();
810});
811$('.droparea').on('dragenter', function(e) {
812    e.preventDefault();
813    e.stopPropagation();
814});
815$('.droparea').on('drop', function(e){
816    if(e.originalEvent.dataTransfer){
817        if(e.originalEvent.dataTransfer.files.length) {
818            e.preventDefault();
819            e.stopPropagation();
820            var total_file = e.originalEvent.dataTransfer.files.length + parseInt($( "#n" ).val());
821            if(total_file <= 100){
822            	var too_big = false;
823                $.each( e.originalEvent.dataTransfer.files, function( key, file ) {
824                	if (file.size > 2147483648){
825//                		if (file.size > 1073741824){
826                		too_big = true;
827                	}
828                });
829            	if(too_big == false){
830	                $.each( e.originalEvent.dataTransfer.files, function( key, file ) {
831	                	upload(file);
832	                });
833            	} else{
834            		show_message("2Go per files maximum");
835            	}
836        	} else {
837        		show_message("100 files per album maximum");
838        	}
839        }   
840    }
841});
842
843//clic select
844$(document).on('click', '.clic-select', function(){
845	$(this).focus(); $(this).select();
846});
847
848/*********************************** comments ***********************************/
849$(document).on('click', '.leave-comment', function(e){
850	e.preventDefault();
851	var id = $(this).data('id');
852
853    $.ajax({
854        url: '/comment/check',
855        type: 'post',
856        dataType : 'json',
857        success: function(data) {
858
859			if(data.check){
860				$('.comments-' + id + ' .leave-comment').hide();
861				$('.comments-' + id + ' .form-comment').show();
862				$('.comments-' + id + ' input[name="content"]').val('');
863				$('.comments-' + id + ' input[name="content"]').focus();
864			} else {
865				if(data.modal == 'account'){
866					$('#needAccount').modal('show');
867				} else {
868					$('#dialogModal .modal-content').load('/comment/first');
869  					$('#dialogModal').modal('show');
870  					
871					$('.comments-' + id + ' .leave-comment').hide();
872					$('.comments-' + id + ' .form-comment').show();
873					$('.comments-' + id + ' input[name="content"]').val('');
874				}
875			}
876            
877        },
878	     	error:function(data){
879//          	console.log(data.responseJSON.message);
880        }
881	});
882});
883
884$(document).on('click', '.add-comment', function(e){
885	e.preventDefault();
886	
887	var id = $(this).data('id');
888	
889	if($('.comments-' + id + ' input[name="content"]').val() == '')
890	{
891		$('.comments-' + id + ' input[name="content"]').focus();
892		return false;
893	}
894	
895    $.ajax({
896        url: '/comment/add',
897        type: 'post',
898        dataType : 'json',
899        data:$('.comments-' + id + ' form').serialize(),
900        success: function(data) {
901
902        	if(data.status == 'added')
903        	{
904            	$('.comments-' + id + ' .list-comment').append(data.html);
905				$('.comments-' + id + ' .form-comment').hide();
906				$('.comments-' + id + ' .leave-comment').show();
907        	}
908
909        	show_message(data.message);
910        },
911	     	error:function(data){
912//          	console.log(data.responseJSON.message);
913        }
914	});
915    
916});
917
918$(document).on('keypress', '.add-comment-input', function(e){
919	var charCode = e.which || e.keyCode;
920	if(charCode == 13) {
921		e.preventDefault();
922		$(this).parent().find('.add-comment')[0].click();
923	}
924});
925
926$(document).on('click', '.edit-comment', function(e){
927	e.preventDefault();
928	var comment_id = $(this).data('id');
929
930    $.ajax({
931        url: '/comment/ajax-request/edit-comment',
932        type: 'post',
933        data:{'comment_id':comment_id},
934        dataType : 'json',
935        success: function(data) {
936			if(data.status == 'success')
937			{
938				$('#comment_' + data.comment_id + ' .comment-content').hide();
939				$('#comment_' + data.comment_id).append(data.html);
940				var input = $('#edit-comment-' + data.guid + ' .edit-comment-input')[0];
941				var end = input.value.length;
942				input.setSelectionRange(end, end);
943				input.focus();
944			}
945		}
946	});
947});
948
949$(document).on('keypress', '.edit-comment-input', function(e){
950	var charCode = e.which || e.keyCode;
951	if(charCode == 13) {
952		e.preventDefault();
953		$(this).parent().find('.edit-comment-action')[0].click();
954	}
955});
956
957$(document).on('click', '.edit-comment-action', function(e){
958	e.preventDefault();
959	var id = $(this).data('id');
960    $.ajax({
961        url: '/comment/ajax-request/edit-comment-action',
962        type: 'post',
963        data: $('#edit-comment-' + id + ' form').serialize(),
964        dataType : 'json',
965        success: function(data) {
966			if(data.status == 'success')
967			{
968				$('#edit-comment-' + data.guid).remove();
969				$('#comment_' + data.comment_id + ' .comment-text').html(data.content);
970				$('#comment_' + data.comment_id + ' .comment-content').show();
971			} else {
972				show_message(data.message);
973			}
974		}
975	});
976	
977});
978
979
980//$(document).on('click', '.flag-comment', function(e){
981//	e.preventDefault();
982//	$('#dialogModal .modal-content').load('/comment/flag/' + $(this).data('id'));
983//	$('#dialogModal').modal('show');
984//});
985
986//comment flag
987$(document).on('click', '.flag-comment', function(e){
988	e.preventDefault();
989	var id = $(this).data('id');
990    $.ajax({
991    	url: '/user/check/',
992    	type: 'post',
993  		data:$(this).serialize(),
994  		success: function(data) {
995  			if(data.status == "success"){
996  				$('#dialogModal .modal-content').load('/comment/flag/' + id);
997  				$('#dialogModal').modal('show');
998  			} else {
999  				show_message(data.error);
1000  			}
1001  		}
1002	});
1003});
1004
1005$(document).on('submit', '#comment-flag-form', function(e){
1006    e.preventDefault();
1007    if (!$("input[name='reason']:checked").val()) {
1008        show_message("Please choose a reason");
1009    } else {
1010        $.ajax({
1011	      url: '/comment/flag/' + $("input[name='id']").val(),
1012	      type: 'post',
1013              data:$(this).serialize(),
1014	      success: function(data) {
1015              $('#dialogModal').modal('hide');
1016	    	  show_message("Comment flagged");
1017	      }
1018	});
1019    }
1020});
1021
1022$(document).on('click', '.delete-comment', function(e){
1023    $.ajax({
1024	      url: '/comment/delete/' + $(this).data('id'),
1025          type: 'post',
1026          dataType : 'json',
1027	      success: function(data) {
1028    	      $('#comment_' + data.comment_id).remove();
1029			  show_message('Comment deleted');
1030	      }
1031    });
1032});
1033
1034/*********************************** end comments ***********************************/
1035
1036/*********************************** warning ***********************************/
1037
1038$(document).on('click', '.close-warning', function(e){
1039    $.ajax({
1040	      url: '/user/close-warning',
1041          type: 'post',
1042          dataType : 'json',
1043	      success: function(data) {
1044    	      $('#warning').remove();
1045	      }
1046    });
1047});
1048
1049
1050
1051
1052
1053

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.