Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('#reposition-profile-cover').on('click',function(){$('#profile-menu').hide();$('#cover-menu').show();$('.profile-cover-controls').hide();$('.profile-cover').unbind('mouseenter').unbind('mouseleave');Ossn.Drag();});$("#upload-photo").on('submit',function(event){event.preventDefault();var formData=new FormData($(this)[0]);var $url=Ossn.site_url+'action/profile/photo/upload';$.ajax({url:Ossn.AddTokenToUrl($url),type:'POST',data:formData,async:true,beforeSend:function(){$('.upload-photo').attr('class','user-photo-uploading');},error:function(xhr,status,error){if(error=='Internal Server Error'||error!==''){Ossn.MessageBox('syserror/unknown');}},cache:false,contentType:false,processData:false,success:function(callback){$time=$.now();$('.user-photo-uploading').attr('class','upload-photo').hide();$imageurl=$('.profile-photo').find('img').attr('src')+'?'+$time;$('.profile-photo').find('img').attr('src',$imageurl);$topbar_icon_url=$('.ossn-topbar-menu').find('img').attr('src')+'?'+$time;$('.ossn-topbar-menu').find('img').attr('src',$topbar_icon_url);}});return false;});$("#upload-cover").on('submit',function(event){event.preventDefault();var formData=new FormData($(this)[0]);var $url=Ossn.site_url+'action/profile/cover/upload';var fileInput=$('#upload-cover').find("input[type=file]")[0],file=fileInput.files&&fileInput.files[0];if(file){var img=new Image();img.src=window.URL.createObjectURL(file);img.onload=function(){var width=img.naturalWidth,height=img.naturalHeight;window.URL.revokeObjectURL(img.src);if(width<1040||height<300){Ossn.trigger_message(Ossn.Print('profile:cover:err1:detail'),'error');return false;}else{$.ajax({url:Ossn.AddTokenToUrl($url),type:'POST',data:formData,async:true,cache:false,contentType:false,processData:false,beforeSend:function(xhr,obj){$('.profile-cover').prepend('<div class="ossn-covers-uploading-annimation"> <div class="ossn-loading"></div></div>');$('.profile-cover-img').attr('class','user-cover-uploading');},success:function(callback){$time=$.now();$('.profile-cover').find('img').removeClass('user-cover-uploading');$('.profile-cover').find('img').addClass('profile-cover-img');$imageurl=$('.profile-cover').find('img').attr('src')+'?'+$time;$('.profile-cover').find('img').attr('src',$imageurl);$('.profile-cover').find('img').attr('style','');$('.profile-cover').find('img').show();$('.ossn-covers-uploading-annimation').remove();},});}};}
return false;});$('#profile-extra-menu').on('click',function(){$div=$('.ossn-profile-extra-menu').find('div');if($div.is(":not(:visible)")){$div.show();}else{$div.hide();}});});});Ossn.repositionCOVER=function(){var $pcover_top=$('.profile-cover-img').css('top');var $pcover_left=$('.profile-cover-img').css('left');$url=Ossn.site_url+"action/profile/cover/reposition";$.ajax({async:true,type:'post',data:'&top='+$pcover_top+'&left='+$pcover_left,url:Ossn.AddTokenToUrl($url),success:function(callback){$("#draggable").draggable('destroy');$('#profile-menu').show();$('#cover-menu').hide();$('.profile-cover').on('mouseenter',function(){$('.profile-cover-controls').show();});$('.profile-cover').on('mouseleave',function(){$('.profile-cover-controls').hide();});},});};Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('.profile-photo').on('mouseenter',function(){$('.upload-photo').slideDown();});$('.profile-photo').on('mouseleave',function(){$('.upload-photo').slideUp();});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('.profile-cover').on('mouseenter',function(){$('.profile-cover-controls').show();});$('.profile-cover').on('mouseleave',function(){$('.profile-cover-controls').hide();});});});Ossn.register_callback('ossn','init','ossn_wall_init');Ossn.register_callback('ossn','init','ossn_wall_postform');Ossn.register_callback('ossn','init','ossn_wall_post_edit');Ossn.register_callback('ossn','init','ossn_wall_select_friends');Ossn.register_callback('ossn','init','ossn_wall_location');Ossn.register_callback('ossn','init','ossn_wall_privacy');Ossn.register_callback('ossn','init','ossn_wall_container_expend');function ossn_wall_post_edit(){$(document).ready(function(){Ossn.ajaxRequest({url:Ossn.site_url+"action/wall/post/edit",containMedia:true,form:'#ossn-post-edit-form',beforeSend:function(){$('#ossn-post-edit-form').find('textarea').hide();$('#ossn-post-edit-form').append('<div class="ossn-loading ossn-box-loading"></div>');},callback:function(callback){if(callback['success']){$text=$('#ossn-post-edit-form').find('#post-edit').val();$guid=$('#ossn-post-edit-form').find('input[name="guid"]').val();$elem=$("#activity-item-"+$guid).find('.post-contents').find('p:first');var preview_url='';$preview_block=$("#activity-item-"+$guid).find('.post-contents').find('.link-preview-item');$preview_link=$("#activity-item-"+$guid).find('.post-contents').find('.link-preview-item').find('a');if($preview_link.length){preview_url=$preview_link[0].href;}
if($elem.length){$elem.text('');Ossn.PostRequest({url:Ossn.site_url+"action/wall/post/embed",params:'text='+encodeURIComponent($text)+'&preview='+preview_url+'&guid='+$guid,callback:function(return_data){$elem.append(return_data['text']);if((return_data['preview_state']=='removed')||(return_data['preview_state']=='changed')){$preview_block.remove();}
if((return_data['preview_state']=='created')||(return_data['preview_state']=='changed')){$("#activity-item-"+$guid).find('.post-contents').append(return_data['preview']);}}});}
Ossn.trigger_message(callback['success']);}
if(callback['error']){Ossn.trigger_message(callback['error'],'error');}
Ossn.MessageBoxClose();}});});}
function ossn_wall_clear_form(){var $file=$("#ossn-wall-form").find("input[type='file']");$file.replaceWith($file.val('').clone(true));$('#ossn-wall-photo').hide();$("#ossn-wall-location-input").val('');$('#ossn-wall-location').hide();$('#ossn-wall-friend-input').val('');if($('#ossn-wall-friend-input').length){$("#ossn-wall-friend-input").tokenInput("clear");$('#ossn-wall-friend').hide();}
$('#ossn-wall-form').find('input[type=submit]').show();$('#ossn-wall-form').find('.ossn-loading').addClass('ossn-hidden');$('#ossn-wall-form').find('textarea').val("");$('.ossn-wall-container-data textarea').removeClass('postbg-container');$('.ossn-wall-container-data textarea').attr('style','');$('#ossn-wall-postbg').attr('data-toggle',0);$('#ossn-wall-postbg').hide();}
function ossn_wall_postform(){$(document).ready(function(){$url=$('#ossn-wall-form').attr('action');Ossn.ajaxRequest({url:$url,action:true,containMedia:true,form:'#ossn-wall-form',beforeSend:function(request){$('#ossn-wall-form').find('input[type=submit]').hide();$('#ossn-wall-form').find('.ossn-loading').removeClass('ossn-hidden');},callback:function(callback){if(callback['success']){if(callback['data']['post']){var new_post=callback['data']['post'];$('.user-activity').prepend($(callback['data']['post']).hide().fadeIn('slow'));$('.user-activity div').first().attr('post','new');}}
if(callback['error']){Ossn.trigger_message(callback['error'],'error');}
ossn_wall_clear_form();}});});}
function ossn_wall_init(){$(document).ready(function(){$('.ossn-wall-container').find('.ossn-wall-friend').on('click',function(){$('#ossn-wall-location').hide();$('#ossn-wall-photo').hide();$('#ossn-wall-friend').show();});$('.ossn-wall-container').find('.ossn-wall-location').on('click',function(){$('#ossn-wall-friend').hide();$('#ossn-wall-photo').hide();$('#ossn-wall-location').show();});$('.ossn-wall-container').find('.ossn-wall-photo').on('click',function(){$('#ossn-wall-friend').hide();$('#ossn-wall-location').hide();$('#ossn-wall-photo').show();});$('body').on('click','.ossn-wall-container-menu-post',function(e){e.preventDefault();$('.ossn-wall-container-data-post').hide();$('.ossn-wall-container-data-post').show();});$('body').on('click','.ossn-wall-post-delete',function(e){$url=$(this);e.preventDefault();var ossn_site_url_parse=Ossn.ParseUrl(Ossn.site_url);var $page_url_path=$(location).attr('pathname').substr(1);if(Ossn.isset(ossn_site_url_parse['path'])){$page_url_path=$(location).attr('pathname');$page_url_path=Ossn.str_replace(ossn_site_url_parse['path'],'',$page_url_path);}
var base_page_url=Ossn.site_url+$page_url_path;$to_be_deleted=$('#activity-item-'+$url.attr('data-guid'));var post_attribute=$to_be_deleted.attr('post');var old_posting_deleted=false;var last_page_posting_deleted=false;var $element='';if(typeof post_attribute==='undefined'){$next=$('.user-activity .ossn-pagination').find('.active').next();if($next.length){var next_url=$next.find('a').attr('href');var results=new RegExp('[\?&]'+'offset'+'=([0-9]*)').exec(next_url);$next_offset=results[1]||false;next_url='?offset='+$next_offset;var current_url=$(location).attr('href');var results=new RegExp('[\?&]'+'offset'+'=([0-9]*)').exec(current_url);if(results){var $current_offset=results[1]||false;}else{var $current_offset=1;}
$last=$('.user-activity .ossn-pagination').find('li:last');var last_url=$last.find('a').attr('href');var results=new RegExp('[\?&]'+'offset'+'=([0-9]*)').exec(last_url);$last_offset=results[1]||false;if($current_offset<$last_offset){Ossn.PostRequest({async:false,action:false,url:base_page_url+next_url,beforeSend:function(){},callback:function(callback){$element=$(callback).find('.ossn-wall-item').first();if($element.length){$element.insertBefore('.user-activity .container-table-pagination');$element.hide();old_posting_deleted=true;}},});}else{last_page_posting_deleted=true;}}}
Ossn.PostRequest({url:$url.attr('href'),async:false,beforeSend:function(request){$('#activity-item-'+$url.attr('data-guid')).attr('style','opacity:0.5;');},callback:function(callback){if(callback==1){$('#activity-item-'+$url.attr('data-guid')).fadeOut();$('#activity-item-'+$url.attr('data-guid')).remove();}else{$('#activity-item-'+$url.attr('data-guid')).attr('style','opacity:1;');}}});if($element.length){$element.show();}});$('body').on('click','.ossn-wall-post-edit',function(){var $dataguid=$(this).attr('data-guid');Ossn.MessageBox('post/edit/'+$dataguid);});$('body').on('input','#ossn-wall-privacy',function(){switch(parseInt($(this).val())){case 3:$('.ossn-wall-privacy-lock').removeClass('fa-lock');$('.ossn-wall-privacy-lock').removeClass('fa-globe-americas');$('.ossn-wall-privacy-lock').removeClass('fa-users');$('.ossn-wall-privacy-lock').addClass('fa-users');break;case 2:$('.ossn-wall-privacy-lock').removeClass('fa-lock');$('.ossn-wall-privacy-lock').removeClass('fa-globe-americas');$('.ossn-wall-privacy-lock').removeClass('fa-users');$('.ossn-wall-privacy-lock').addClass('fa-globe-americas');break;}});if($('#ossn-wall-privacy').length){$('#ossn-wall-privacy').trigger('input');}});}
function ossn_wall_select_friends(){$(document).ready(function(){if(typeof $.fn.tokenInput==='function'){$("#ossn-wall-friend-input").tokenInput(Ossn.site_url+"friendpicker",{placeholder:Ossn.Print('tag:friends'),hintText:false,propertyToSearch:"first_name",resultsFormatter:function(item){return"<li>"+"<img src='"+item.imageurl+"' title='"+item.first_name+" "+item.last_name+"' height='25px' width='25px' />"+"<div style='display: inline-block; padding-left: 10px;'><div class='full_name' style='font-weight:bold;color:#2B5470;'>"+item.first_name+" "+item.last_name+"</div></div></li>"},tokenFormatter:function(item){return"<li><p>"+item.first_name+" "+item.last_name+"</p></li>"},});}});}
Ossn.PostMenu=function($id){$element=$($id).find('.menu-links');if($element.is(":not(:visible)")){$element.show();}else{$element.hide();}};function ossn_wall_privacy(){$(document).ready(function(){$('.ossn-wall-privacy').on('click',function(e){Ossn.MessageBox('post/privacy');});$('#ossn-wall-privacy').on('click',function(e){var wallprivacy=$('#ossn-wall-privacy-container').find('input[name="privacy"]:checked').val();$('#ossn-wall-privacy').val(wallprivacy);$('#ossn-wall-privacy').trigger("input");Ossn.MessageBoxClose();var $url=window.location.href;if($url.match(Ossn.site_url+'home')){wallSetCookie('ossn_home_wall_privacy',wallprivacy,365);}else if($url.match(Ossn.site_url+'u/')){wallSetCookie('ossn_user_wall_privacy',wallprivacy,365);}});});}
function ossn_wall_location(){$(document).ready(function(){if($('#ossn-wall-location-input').length){var placesAutocomplete=places({container:document.querySelector('#ossn-wall-location-input')});$('#ossn-wall-location-input').on('keypress',function(event){if(event.keyCode==13){event.preventDefault();return false;}});}});}
function ossn_wall_container_expend(){$(document).ready(function(){$('#ossn-wall-form').on('submit',function(){$('.ossn-wall-container textarea').height(40);});$('.ossn-wall-container textarea:not(.postbg-container)').on('keyup',function(e){if(!$(this).hasClass('postbg-container')){$(this).height(0);$(this).height(this.scrollHeight+parseFloat($(this).css('borderTopWidth'))+parseFloat($(this).css('borderBottomWidth')));}});});}
function wallSetCookie(cname,cvalue,exdays){var d=new Date();d.setTime(d.getTime()+(exdays*24*60*60*1000));Ossn.setCookie(cname,cvalue,d,'/');}
Ossn.register_callback('ossn','init','ossn_comment_init');Ossn.register_callback('ossn','init','ossn_comment_delete_handler');Ossn.register_callback('ossn','init','ossn_comment_edit');Ossn.register_callback('ossn','init','ossn_comment_post_sm_button');function ossn_comments_replace_tags(input,allowed){allowed=(((allowed||'')+'').toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join('')
var tags=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi
var commentsAndPhpTags=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>|&nbsp;/gi
return input.replace(commentsAndPhpTags,'').replace(tags,function($0,$1){return allowed.indexOf('<'+$1.toLowerCase()+'>')>-1?$0:''});}
Ossn.PostComment=function($container){$('#comment-box-p'+$container).on('keypress',function(e){if($('.comment-post-btn').is(":visible")===false){if(e.which==13){if(e.shiftKey===false){$text=$('#comment-box-p'+$container).html();$text=ossn_comments_replace_tags($text,'<br>').replace(/\<br\\?>/g,"\n");$('#comment-container-p'+$container).append("<textarea name='comment' class='hidden'>"+$text+"</textarea>");$('#comment-container-p'+$container).submit();}}}});$('#comment-box-p'+$container).on('paste',function(e){e.preventDefault();var text=(e.originalEvent||e).clipboardData.getData('text/plain')||prompt('Paste something..');window.document.execCommand('insertText',false,text);});Ossn.ajaxRequest({url:Ossn.site_url+'action/post/comment',form:'#comment-container-p'+$container,beforeSend:function(request){$('#comment-box-p'+$container).attr('readonly','readonly');$('#comment-box-p'+$container).attr('contenteditable',false);},callback:function(callback){if(callback['process']==1){$('#comment-box-p'+$container).removeAttr('readonly');$('#comment-box-p'+$container).val('');$('.ossn-comments-list-p'+$container).append(callback['comment']);$('#comment-attachment-container-p'+$container).hide();$('#ossn-comment-attachment-p'+$container).find('.image-data').html('');$('#comment-container-p'+$container).find('input[name="comment-attachment"]').val('');}
if(callback['process']==0){$('#comment-box-p'+$container).removeAttr('readonly');Ossn.MessageBox('syserror/unknown');}
$('#comment-box-p'+$container).attr('contenteditable',true);$('#comment-box-p'+$container).html("");Ossn.trigger_callback('comment','post:callback',{guid:$container,response:callback,});}});};Ossn.ObjectComment=function($container){$('#comment-box-o'+$container).on('keypress',function(e){if($('.comment-post-btn').is(":visible")===false){if(e.which==13){if(e.shiftKey===false){$text=$('#comment-box-o'+$container).html();$text=ossn_comments_replace_tags($text,'<br>').replace(/\<br\\?>/g,"\n");$('#comment-container-o'+$container).append("<textarea name='comment' class='hidden'>"+$text+"</textarea>");$('#comment-container-o'+$container).submit();}}}});$('#comment-box-o'+$container).on('paste',function(e){e.preventDefault();var text=(e.originalEvent||e).clipboardData.getData('text/plain')||prompt('Paste something..');window.document.execCommand('insertText',false,text);});Ossn.ajaxRequest({url:Ossn.site_url+'action/post/object/comment',form:'#comment-container-o'+$container,beforeSend:function(request){$('#comment-box-o'+$container).attr('readonly','readonly');$('#comment-box-o'+$container).attr('contenteditable',false);},callback:function(callback){if(callback['process']==1){$('#comment-box-o'+$container).removeAttr('readonly');$('#comment-box-o'+$container).val('');$('.ossn-comments-list-o'+$container).append(callback['comment']);$('#comment-attachment-container-o'+$container).hide();$('#ossn-comment-attachment-o'+$container).find('.image-data').html('');$('#comment-container-o'+$container).find('input[name="comment-attachment"]').val('');}
if(callback['process']==0){$('#comment-box-o'+$container).removeAttr('readonly');Ossn.MessageBox('syserror/unknown');}
$('#comment-box-o'+$container).attr('contenteditable',true);$('#comment-box-o'+$container).html("");Ossn.trigger_callback('comment','object:callback',{guid:$container,response:callback,});}});};Ossn.EntityComment=function($container){$('#comment-box-e'+$container).on('keypress',function(e){if($('.comment-post-btn').is(":visible")===false){if(e.which==13){if(e.shiftKey===false){$text=$('#comment-box-e'+$container).html();$text=ossn_comments_replace_tags($text,'<br>').replace(/\<br\\?>/g,"\n");$('#comment-container-e'+$container).append("<textarea name='comment' class='hidden'>"+$text+"</textarea>");$('#comment-container-e'+$container).submit();}}}});$('#comment-box-e'+$container).on('paste',function(e){e.preventDefault();var text=(e.originalEvent||e).clipboardData.getData('text/plain')||prompt('Paste something..');window.document.execCommand('insertText',false,text);});Ossn.ajaxRequest({url:Ossn.site_url+'action/post/entity/comment',form:'#comment-container-e'+$container,beforeSend:function(request){$('#comment-box-e'+$container).attr('readonly','readonly');$('#comment-box-e'+$container).attr('contenteditable',false);},callback:function(callback){if(callback['process']==1){$('#comment-box-e'+$container).removeAttr('readonly');$('#comment-box-e'+$container).val('');$('.ossn-comments-list-e'+$container).append(callback['comment']);$('#comment-attachment-container-e'+$container).hide();$('#ossn-comment-attachment-e'+$container).find('.image-data').html('');$('#comment-container-e'+$container).find('input[name="comment-attachment"]').val('');}
if(callback['process']==0){$('#comment-box-e'+$container).removeAttr('readonly');Ossn.MessageBox('syserror/unknown');}
$('#comment-box-e'+$container).attr('contenteditable',true);$('#comment-box-e'+$container).html("");Ossn.trigger_callback('comment','entity:callback',{guid:$container,response:callback,});}});};Ossn.CommentMenu=function($id){$element=$($id).find('.menu-links');if($element.is(":not(:visible)")){$element.show();$($id).find('.drop-down-arrow').attr('style','display:block;');}else{$element.hide();$($id).find('.drop-down-arrow').attr('style','');}};function ossn_comment_delete_handler(){$(document).ready(function(){$('body').on('click','.ossn-delete-comment',function(e){e.preventDefault();$comment=$(this);$url=$comment.attr('href');$comment_id=Ossn.UrlParams('comment',$url);Ossn.PostRequest({url:$url,action:false,beforeSend:function(){$('#comments-item-'+$comment_id).attr('style','opacity:0.6;');},callback:function(callback){if(callback==1){$('#comments-item-'+$comment_id).fadeOut().remove();}
if(callback==0){$('#comments-item-'+$comment_id).attr('style','opacity:0.6;');}
Ossn.trigger_callback('comment','delete:callback',{id:$comment_id,response:callback,});}});});});}
Ossn.CommentImage=function($container,$ftype){if($ftype=='post'){$ftype='p';}
if($ftype=='entity'){$ftype='e';}
$(document).ready(function(){$("#ossn-comment-image-file-"+$ftype+""+$container).on('change',function(event){event.preventDefault();var formData=new FormData($('#ossn-comment-attachment-'+$ftype+''+$container)[0]);$.ajax({url:Ossn.site_url+'comment/attachment',type:'POST',data:formData,async:true,beforeSend:function(){$('#ossn-comment-attachment-'+$ftype+''+$container).find('.image-data').html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" style="width:30px;border:none;height: initial;" />');$('#comment-attachment-container-'+$ftype+''+$container).show();},cache:false,contentType:false,processData:false,success:function(callback){if(callback['type']==1){$('#comment-container-'+$ftype+''+$container).find('input[name="comment-attachment"]').val(callback['file']);$('#ossn-comment-attachment-'+$ftype+''+$container).find('.image-data').html('<img src="'+Ossn.site_url+'comment/staticimage?image='+callback['file']+'" />');}
if(callback['type']==0){$('#comment-container-'+$ftype+''+$container).find('input[name="comment-attachment"]').val('');$('#comment-attachment-container-'+$ftype+''+$container).hide();Ossn.MessageBox('syserror/unknown');}
Ossn.trigger_callback('comment','attachment:image:callback',{guid:$container,type:$ftype,response:callback,});},});});});};function ossn_comment_edit(){$(document).ready(function(){$('body').on('click','.ossn-edit-comment',function(){var $dataguid=$(this).attr('data-guid');Ossn.MessageBox('comment/edit/'+$dataguid);});Ossn.ajaxRequest({url:Ossn.site_url+"action/comment/edit",containMedia:true,form:'#ossn-comment-edit-form',beforeSend:function(){$('#ossn-comment-edit-form').find('textarea').hide();$('#ossn-comment-edit-form').append('<div class="ossn-loading ossn-box-loading"></div>');},callback:function(callback){if(callback['success']){$text=$('#ossn-comment-edit-form').find('#comment-edit').val();$guid=$('#ossn-comment-edit-form').find('input[name="guid"]').val();$elem=$("#comments-item-"+$guid).find('.comment-contents').find('.comment-text:first');if($elem){$elem.text('');Ossn.PostRequest({url:Ossn.site_url+"action/comment/embed",params:'content='+encodeURIComponent($text)+'&guid='+$guid,callback:function(return_data){$elem.append(return_data['data']);Ossn.trigger_callback('comment','edit:callback',{guid:$guid,response:return_data,});}});}
Ossn.trigger_message(callback['success']);}
if(callback['error']){Ossn.trigger_message(callback['error'],'error');}
Ossn.MessageBoxClose();}});});}
function ossn_comment_post_sm_button(){$(document).ready(function(){$('body').on('click','.comment-post-btn',function(){$type=$(this).attr('data-type');$guid=$(this).attr('data-guid');if($type=='p'||$type=='o'||$type=='e'){$text=$('#comment-box-'+$type+''+$guid).html();$container=$('#comment-container-'+$type+''+$guid);}
$text=ossn_comments_replace_tags($text,'<br>').replace(/\<br\\?>/g,"\n");$container.append("<textarea name='comment' class='hidden'>"+$text+"</textarea>");$container.submit();});});}
function ossn_comment_init(){$(document).ready(function(){$('body').on('click','.comment-post',function(){var $guid=$(this).attr('data-guid');if($guid){$("#comment-box-p"+$guid).focus();}});$('body').on('click','.comment-entity',function(){var $guid=$(this).attr('data-guid');if($guid){$("#comment-box-e"+$guid).focus();}});$('body').on('click','.comment-object',function(){var $guid=$(this).attr('data-guid');if($guid){$("#comment-box-o"+$guid).focus();}});});}
Ossn.PostUnlike=function(post){Ossn.PostRequest({url:Ossn.site_url+'action/post/unlike',beforeSend:function(){$('#ossn-like-'+post).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&post='+post,callback:function(callback){if(callback['done']!==0){$('#ossn-like-'+post).html(callback['button']);$('#ossn-like-'+post).attr('data-reaction','Ossn.PostLike('+post+', "<<reaction_type>>");');$('#ossn-like-'+post).removeAttr('onclick');$parent=$('#ossn-like-'+post).parent().parent().parent();if(callback['container']){$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}
if(!callback['container']){$parent.find('.like-share').remove();}}else{$('#ossn-like-'+post).html(Ossn.Print('unlike'));}},});};Ossn.PostLike=function(post,$reaction_type=''){Ossn.PostRequest({url:Ossn.site_url+'action/post/like',beforeSend:function(){$('#ossn-like-'+post).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&post='+post+'&reaction_type='+$reaction_type,callback:function(callback){if(callback['done']!==0){$('#ossn-like-'+post).html(callback['button']);$('#ossn-like-'+post).attr('onClick','Ossn.PostUnlike('+post+');');$('#ossn-like-'+post).removeAttr('data-reaction');if(callback['container']){$parent=$('#ossn-like-'+post).parent().parent().parent();$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}}else{$('#ossn-like-'+post).html(Ossn.Print('like'));}},});};Ossn.EntityUnlike=function(entity){Ossn.PostRequest({url:Ossn.site_url+'action/post/unlike',beforeSend:function(){$('#ossn-elike-'+entity).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&entity='+entity,callback:function(callback){if(callback['done']!==0){$('#ossn-elike-'+entity).html(callback['button']);$('#ossn-elike-'+entity).attr('data-reaction','Ossn.EntityLike('+entity+', "<<reaction_type>>");');$('#ossn-elike-'+entity).removeAttr('onclick');$parent=$('#ossn-elike-'+entity).parent().parent().parent();if(callback['container']){$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}
if(!callback['container']){$parent.find('.like-share').remove();}}else{$('#ossn-elike-'+entity).html(Ossn.Print('unlike'));}},});};Ossn.EntityLike=function(entity,$reaction_type=''){Ossn.PostRequest({url:Ossn.site_url+'action/post/like',beforeSend:function(){$('#ossn-elike-'+entity).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&entity='+entity+'&reaction_type='+$reaction_type,callback:function(callback){if(callback['done']!==0){$('#ossn-elike-'+entity).html(callback['button']);$('#ossn-elike-'+entity).attr('onClick','Ossn.EntityUnlike('+entity+');');$('#ossn-elike-'+entity).removeAttr('data-reaction');if(callback['container']){$parent=$('#ossn-elike-'+entity).parent().parent().parent();$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}}else{$('#ossn-elike-'+entity).html(Ossn.Print('like'));}},});};Ossn.ObjectUnlike=function(object_guid){Ossn.PostRequest({url:Ossn.site_url+'action/post/unlike',beforeSend:function(){$('#ossn-olike-'+object_guid).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&object='+object_guid,callback:function(callback){if(callback['done']!==0){$('#ossn-olike-'+object_guid).html(callback['button']);$('#ossn-olike-'+object_guid).attr('data-reaction','Ossn.ObjectLike('+object_guid+', "<<reaction_type>>");');$('#ossn-olike-'+object_guid).removeAttr('onclick');$parent=$('#ossn-olike-'+object_guid).parent().parent().parent();if(callback['container']){$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}
if(!callback['container']){$parent.find('.like-share').remove();}}else{$('#ossn-olike-'+object_guid).html(Ossn.Print('unlike'));}},});};Ossn.ObjectLike=function(object_guid,$reaction_type=''){Ossn.PostRequest({url:Ossn.site_url+'action/post/like',beforeSend:function(){$('#ossn-olike-'+object_guid).html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},params:'&object='+object_guid+'&reaction_type='+$reaction_type,callback:function(callback){if(callback['done']!==0){$('#ossn-olike-'+object_guid).html(callback['button']);$('#ossn-olike-'+object_guid).attr('onClick','Ossn.ObjectUnlike('+object_guid+');');$('#ossn-olike-'+object_guid).removeAttr('data-reaction');if(callback['container']){$parent=$('#ossn-olike-'+object_guid).parent().parent().parent();$parent.find('.like-share').remove();$parent.find('.menu-likes-comments-share').after(callback['container']);}}else{$('#ossn-olike-'+object_guid).html(Ossn.Print('like'));}},});};Ossn.RegisterStartupFunction(function(){$(document).ready(function(){var $htmlreactions='<div class="ossn-like-reactions-panel"> <li class="ossn-like-reaction-like"> <div class="emoji  emoji--like"> <div class="emoji__hand"> <div class="emoji__thumb"></div> </div> </div> </li> <li class="ossn-like-reaction-dislike"> <div class="emoji  emoji--dislike"> <div class="emoji__hand"> <div class="emoji__thumb"></div> </div> </div> </li> <li class="ossn-like-reaction-love"> <div class="emoji  emoji--love"> <div class="emoji__heart"></div> </div> </li> <li class="ossn-like-reaction-haha"> <div class="emoji  emoji--haha"> <div class="emoji__face"> <div class="emoji__eyes"></div> <div class="emoji__mouth"> <div class="emoji__tongue"></div> </div> </div> </div> </li> <li class="ossn-like-reaction-yay"> <div class="emoji  emoji--yay"> <div class="emoji__face"> <div class="emoji__eyebrows"></div> <div class="emoji__mouth"></div> </div> </div> </li> <li class="ossn-like-reaction-wow"> <div class="emoji  emoji--wow"> <div class="emoji__face"> <div class="emoji__eyebrows"></div> <div class="emoji__eyes"></div> <div class="emoji__mouth"></div> </div> </div> </li> <li class="ossn-like-reaction-sad"> <div class="emoji  emoji--sad"> <div class="emoji__face"> <div class="emoji__eyebrows"></div> <div class="emoji__eyes"></div> <div class="emoji__mouth"></div> </div> </div> </li> <li class="ossn-like-reaction-angry"> <div class="emoji  emoji--angry"> <div class="emoji__face"> <div class="emoji__eyebrows"></div> <div class="emoji__eyes"></div> <div class="emoji__mouth"></div> </div> </div> </li> </div>';$('body').on('click',function(e){$class=$(e.target).attr('class');if($class&&!$(e.target).hasClass('post-control-like')&&!$(e.target).hasClass('entity-menu-extra-like')&&!$(e.target).hasClass('ossn-like-comment')&&!$(e.target).hasClass('ossn-like-reactions-panel')){$('.ossn-like-reactions-panel').remove();}});$MenuReactions=function($elem){$parent=$($elem).parent();$('.ossn-like-reactions-panel').remove();$onclick=$($elem).attr('data-reaction');if(!$onclick||$parent.find('.ossn-like-reactions-panel').length>0){return false;}
$parent.append($htmlreactions);$like=$onclick.replace("<<reaction_type>>",'like');$dislike=$onclick.replace("<<reaction_type>>",'dislike');$love=$onclick.replace("<<reaction_type>>",'love');$haha=$onclick.replace("<<reaction_type>>",'haha');$yay=$onclick.replace("<<reaction_type>>",'yay');$wow=$onclick.replace("<<reaction_type>>",'wow');$sad=$onclick.replace("<<reaction_type>>",'sad');$angry=$onclick.replace("<<reaction_type>>",'angry');$parent.find('.ossn-like-reaction-like').attr('onclick',$like);$parent.find('.ossn-like-reaction-dislike').attr('onclick',$dislike);$parent.find('.ossn-like-reaction-love').attr('onclick',$love);$parent.find('.ossn-like-reaction-haha').attr('onclick',$haha);$parent.find('.ossn-like-reaction-yay').attr('onclick',$yay);$parent.find('.ossn-like-reaction-wow').attr('onclick',$wow);$parent.find('.ossn-like-reaction-sad').attr('onclick',$sad);$parent.find('.ossn-like-reaction-angry').attr('onclick',$angry);};$("body").on('mouseenter touchstart','.post-control-like, .entity-menu-extra-like',function(){$MenuReactions($(this));});$("body").on('mouseenter touchstart','.post-control-like, .object-menu-extra-like',function(){$MenuReactions($(this));});$("body ").on('mouseenter touchstart','.ossn-like-comment',function(){$parent=$(this).parent().parent();$('.ossn-like-reactions-panel').remove();if($(this).attr('data-type')=='Unlike'||$parent.find('.ossn-like-reactions-panel').length>0||!$(this).attr('data-id')){return true;}
$parent.append($htmlreactions);$parent.find('.ossn-like-reaction-like').addClass('ossn-like-comment-react').attr('data-reaction','like').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-dislike').addClass('ossn-like-comment-react').attr('data-reaction','dislike').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-love').addClass('ossn-like-comment-react').attr('data-reaction','love').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-haha').addClass('ossn-like-comment-react').attr('data-reaction','haha').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-yay').addClass('ossn-like-comment-react').attr('data-reaction','yay').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-wow').addClass('ossn-like-comment-react').attr('data-reaction','wow').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-sad').addClass('ossn-like-comment-react').attr('data-reaction','sad').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));$parent.find('.ossn-like-reaction-angry').addClass('ossn-like-comment-react').attr('data-reaction','angry').attr('data-id',$(this).attr('data-id')).attr('data-type','Like').attr('href',$(this).attr('href'));});$('body').on('click','.ossn-like-comment-react, .ossn-like-comment',function(e){e.preventDefault();var $item=$(this);var $type=$.trim($item.attr('data-type'));var $url=$item.attr('href');if($(this).attr('class')=='ossn-like-comment'&&$type=='Like'){return false;}
Ossn.PostRequest({url:$url,action:false,params:'&reaction_type='+$item.attr('data-reaction'),beforeSend:function(){$item.html('<img src="'+Ossn.site_url+'components/OssnComments/images/loading.gif" />');},callback:function(callback){if(callback['done']==1){$total_guid=Ossn.UrlParams('annotation',$url);$total=$('.ossn-total-likes-'+$total_guid).attr('data-likes');if($type=='Like'){$('#ossn-like-comment-'+$total_guid).html(Ossn.Print('unlike'));$('#ossn-like-comment-'+$total_guid).attr('data-type','Unlike');var unlike=$url.replace("like","unlike");$('#ossn-like-comment-'+$total_guid).attr('href',unlike);$total_likes=$total;$('.ossn-like-reactions-panel').remove();}
if($type=='Unlike'){$('#ossn-like-comment-'+$total_guid).html(Ossn.Print('like'));$('#ossn-like-comment-'+$total_guid).attr('data-type','Like');var like=$url.replace("unlike","like");$('#ossn-like-comment-'+$total_guid).attr('href',like);}
if(callback['container']){$('#comments-item-'+$total_guid).find('.ossn-likes-annotation-total').remove();$('#comments-item-'+$total_guid).find('.ossn-reaction-list').remove();$('#comments-item-'+$total_guid).find('.comment-metadata').append(callback['container']);}}
if(callback['done']==0){if($type=='Like'){$('#ossn-like-comment-'+$total_guid).html(Ossn.Print('like'));$('#ossn-like-comment-'+$total_guid).attr('data-type','Like');Ossn.MessageBox('syserror/unknown');}
if($type=='Unlike'){$('#ossn-like-comment-'+$total_guid).html(Ossn.Print('unlike'));$('#ossn-like-comment-'+$total_guid).attr('data-type','Unlike');Ossn.MessageBox('syserror/unknown');}}},});});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('#ossn-add-album').on('click',function(){Ossn.MessageBox('album/add');});$('#album-add').on('click',function(){Ossn.MessageBox('album/add');});$('body').on('click','#ossn-photos-edit-album',function(){$guid=$(this).attr('data-guid');Ossn.MessageBox("album/edit/"+$guid);});$('#ossn-add-photos').on('click',function(){$dataurl=$(this).attr('data-url');Ossn.MessageBox('photos/add'+$dataurl);});$('body').on('click','#ossn-photos-add-button-inner',function(e){e.preventDefault();$('.ossn-photos-add-button').find('input').click();});$('body').on('change','.ossn-photos-add-button input',function(e){$length=$(this)[0].files.length;$('.ossn-photos-add-button').find('.images').show();$('.ossn-photos-add-button').find('.images .count').html($length);$('#ossn-photos-add-button-inner').blur();});});});Ossn.NotificationBox=function($title,$meta,$type,height,$extra){Ossn.NotificationsCheck();$extra=$extra||'';if(height==''){}
if($type){$('.selected').addClass($type);}
if($title){$('.ossn-notifications-box').show()
$('.ossn-notifications-box').find('.type-name').html($title+$extra);}
if($meta){$('.ossn-notifications-box').find('.metadata').html($meta);$('.ossn-notifications-box').css('height',height);}};Ossn.NotificationBoxClose=function(){$('.ossn-notifications-box').hide()
$('.ossn-notifications-box').find('.type-name').html('');$('.ossn-notifications-box').find('.metadata').html('<div><div class="ossn-loading ossn-notification-box-loading"></div></div><div class="bottom-all">---</div>');$('.selected').attr('class','selected');};Ossn.NotificationShow=function($div){$('.ossn-notifications-box').show();$($div).attr('onClick','Ossn.NotificationClose(this)');Ossn.PostRequest({url:Ossn.site_url+"notification/notification",action:false,beforeSend:function(request){Ossn.NotificationBoxClose();$('.ossn-notifications-friends').attr('onClick','Ossn.NotificationFriendsShow(this)');$('.ossn-notifications-messages').attr('onClick','Ossn.NotificationMessagesShow(this)');Ossn.NotificationBox(Ossn.Print('notifications'),false,'notifications');},callback:function(callback){var data='';var height='';if(callback['type']==1){data=callback['data'];}
if(callback['type']==0){data=callback['data'];}
Ossn.NotificationBox(Ossn.Print('notifications'),data,'notifications',height,callback['extra']);}});};Ossn.NotificationClose=function($div){Ossn.NotificationBoxClose();$($div).attr('onClick','Ossn.NotificationShow(this)');};Ossn.NotificationFriendsShow=function($div){$('.ossn-notifications-box').show();$($div).attr('onClick','Ossn.NotificationFriendsClose(this)');Ossn.PostRequest({url:Ossn.site_url+"notification/friends",action:false,beforeSend:function(request){Ossn.NotificationBoxClose();$('.ossn-notifications-notification').attr('onClick','Ossn.NotificationShow(this)');$('.ossn-notifications-messages').attr('onClick','Ossn.NotificationMessagesShow(this)');Ossn.NotificationBox(Ossn.Print('friend:requests'),false,'firends');},callback:function(callback){var data='';var height='';if(callback['type']==1){data=callback['data'];}
if(callback['type']==0){data=callback['data'];}
Ossn.NotificationBox(Ossn.Print('friend:requests'),data,'firends',height);}});};Ossn.NotificationFriendsClose=function($div){Ossn.NotificationBoxClose();$($div).attr('onClick','Ossn.NotificationFriendsShow(this)');};Ossn.AddFriend=function($guid){action=Ossn.site_url+"action/friend/add?user="+$guid;Ossn.ajaxRequest({url:action,form:'#add-friend-'+$guid,action:true,beforeSend:function(request){$('#notification-friend-item-'+$guid).find('form').hide();$('#ossn-nfriends-'+$guid).append('<div class="ossn-loading"></div>');},callback:function(callback){if(callback['type']==1){$('#notification-friend-item-'+$guid).addClass("ossn-notification-friend-submit");$('#ossn-nfriends-'+$guid).addClass('friends-added-text').html(callback['text']);}
if(callback['type']==0){$('#notification-friend-item-'+$guid).find('form').show();$('#ossn-nfriends-'+$guid).find('.ossn-loading').remove();}
Ossn.NotificationsCheck();}});};Ossn.removeFriendRequset=function($guid){action=Ossn.site_url+"action/friend/remove?user="+$guid;Ossn.ajaxRequest({url:action,form:'#remove-friend-'+$guid,action:true,beforeSend:function(request){$('#notification-friend-item-'+$guid).find('form').hide();$('#ossn-nfriends-'+$guid).append('<div class="ossn-loading"></div>');},callback:function(callback){if(callback['type']==1){$('#notification-friend-item-'+$guid).addClass("ossn-notification-friend-submit");$('#ossn-nfriends-'+$guid).addClass('friends-added-text').html(callback['text']);}
if(callback['type']==0){$('#notification-friend-item-'+$guid).find('form').show();$('#ossn-nfriends-'+$guid).find('.ossn-loading').remove();}
Ossn.NotificationsCheck();}});};Ossn.NotificationMessagesShow=function($div){$('.ossn-notifications-box').show();$($div).attr('onClick','Ossn.NotificationMessagesClose(this)');Ossn.PostRequest({url:Ossn.site_url+"notification/messages",action:false,beforeSend:function(request){Ossn.NotificationBoxClose();$('.ossn-notifications-notification').attr('onClick','Ossn.NotificationShow(this)');$('.ossn-notifications-friends').attr('onClick','Ossn.NotificationFriendsShow(this)');Ossn.NotificationBox(Ossn.Print('messages'),false,'messages');},callback:function(callback){var data='';var height='';if(callback['type']==1){data=callback['data'];height='';}
if(callback['type']==0){data=callback['data'];}
Ossn.NotificationBox(Ossn.Print('messages'),data,'messages',height);}});};Ossn.NotificationMessagesClose=function($div){Ossn.NotificationBoxClose();$($div).attr('onClick','Ossn.NotificationMessagesShow(this)');};Ossn.NotificationsCheck=function(){Ossn.PostRequest({url:Ossn.site_url+"notification/count",action:false,callback:function(callback){$notification=$('#ossn-notif-notification');$notification_count=$notification.find('.ossn-notification-container');$friends=$('#ossn-notif-friends');$friends_count=$friends.find('.ossn-notification-container');$messages=$('#ossn-notif-messages');$messages_count=$messages.find('.ossn-notification-container');if(callback['notifications']>0){$notification_count.html(callback['notifications']);$notification.find('.ossn-icon').addClass('ossn-icons-topbar-notifications-new');$notification_count.attr('style','display:inline-block !important;');}
if(callback['notifications']<=0){$notification_count.html('');$notification.find('.ossn-icon').removeClass('ossn-icons-topbar-notifications-new');$notification.find('.ossn-icon').addClass('ossn-icons-topbar-notification');$notification_count.hide();}
if(callback['messages']>0){$messages_count.html(callback['messages']);$messages.find('.ossn-icon').addClass('ossn-icons-topbar-messages-new');$messages_count.attr('style','display:inline-block !important;');}
if(callback['messages']<=0){$messages_count.html('');$messages.find('.ossn-icon').removeClass('ossn-icons-topbar-messages-new');$messages.find('.ossn-icon').addClass('ossn-icons-topbar-messages');$messages_count.hide();}
if(callback['friends']>0){$friends_count.html(callback['friends']);$friends.find('.ossn-icon').addClass('ossn-icons-topbar-friends-new');$friends_count.attr('style','display:inline-block !important;');}
if(callback['friends']<=0){$friends_count.html('');$friends.find('.ossn-icon').removeClass('ossn-icons-topbar-friends-new');$friends.find('.ossn-icon').addClass('ossn-icons-topbar-friends');$friends_count.hide();}}});};Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('.ossn-topbar-dropdown-menu').on('click',function(){Ossn.NotificationBoxClose();});$(document).on('click','.ossn-notification-mark-read',function(e){e.preventDefault();Ossn.PostRequest({url:Ossn.site_url+"action/notification/mark/allread",action:false,beforeSend:function(request){$('.ossn-notification-mark-read').attr('style','opacity:0.5;');},callback:function(callback){if(callback['success']){Ossn.trigger_message(callback['success']);}
if(callback['error']){Ossn.trigger_message(callback['error']);}
$('.ossn-notification-mark-read').attr('style','1;');}});});});});jQuery.fn.visibleInScroll=function(goDeep){var parent=$(this[0]).scrollParent()[0],elRect=this[0].getBoundingClientRect(),rects=[parent.getBoundingClientRect()];elRect={left:elRect.left,top:elRect.top,right:elRect.right,bottom:elRect.bottom,width:elRect.width,height:elRect.height,visibleWidth:elRect.width,visibleHeight:elRect.height,isVisible:true,isContained:true};var elWidth=elRect.width,elHeight=elRect.height;if(parent===this[0].ownerDocument){return elRect;}
while(parent!==this[0].ownerDocument&&parent!==null){if(parent.scrollWidth>parent.clientWidth||parent.scrollHeight>parent.clientHeight){rects.push(parent.getBoundingClientRect());}
if(rects.length&&goDeep){break;}
parent=$(parent).scrollParent()[0];}
if(!goDeep){rects.length=1;}
for(var i=0;i<rects.length;i+=1){var rect=rects[i];elRect.left=Math.max(elRect.left,rect.left);elRect.top=Math.max(elRect.top,rect.top);elRect.right=Math.min(elRect.right,rect.right);elRect.bottom=Math.min(elRect.bottom,rect.bottom);}
elRect.visibleWidth=Math.max(0,elRect.right-elRect.left);elRect.visibleHeight=elRect.visibleWidth&&Math.max(0,elRect.bottom-elRect.top);if(!elRect.visibleHeight){elRect.visibleWidth=0;}
elRect.isVisible=elRect.visibleWidth>0&&elRect.visibleHeight>0;elRect.isContained=elRect.visibleWidth===elRect.width&&elRect.visibleHeight===elRect.height;return elRect;};Ossn.MessagesURLparam=function(name,url){if(!name||!url){return false;}
var results=new RegExp('[\?&]'+name+'=([0-9]*)').exec(url);if(results==null){return null;}else{return results[1]||false;}};Ossn.SendMessage=function($user){Ossn.ajaxRequest({url:Ossn.site_url+"action/message/send",form:'#message-send-'+$user,action:true,beforeSend:function(request){$('#message-send-'+$user).find('input[type=submit]').hide();$('#message-send-'+$user).find('.ossn-loading').removeClass('ossn-hidden');},callback:function(callback){if(callback!=='0'){$('#message-append-'+$user).append(callback);}
$('#message-send-'+$user).find('textarea').val('');$('#message-send-'+$user).find('input[type=submit]').show();$('#message-send-'+$user).find('.ossn-loading').addClass('ossn-hidden');Ossn.message_scrollMove($user);}});};Ossn.getMessages=function($user,$guid){Ossn.PostRequest({url:Ossn.site_url+"messages/getnew/"+$user,action:false,callback:function(callback){$('#message-append-'+$guid).append(callback);if(callback){Ossn.message_scrollMove($guid);}}});};Ossn.getRecent=function($user){Ossn.PostRequest({url:Ossn.site_url+"messages/getrecent/"+$user,action:false,callback:function(callback){$('#get-recent').html(callback);$('#get-recent').addClass('inner');$('.messages-from').find('.inner').remove();$('#get-recent').appendTo('.messages-from');$('#get-recent').show();}});};Ossn.playSound=function(){document.getElementById('ossn-chat-sound').play();};Ossn.message_scrollMove=function(fid){var message=document.getElementById('message-append-'+fid);if(message){message.scrollTop=message.scrollHeight;return message.scrollTop;}};$(document).ready(function(){$calledOnce=[];$('.ossn-messages .messages-recent .messages-from').on('scroll',function(){if($('.ossn-pagination').visibleInScroll().isVisible){$element=$('.ossn-messages .messages-recent .messages-from .inner .container-table-pagination');$next=$element.find('.ossn-pagination .active').next();$last=$element.find('.ossn-pagination').find('li:last');$last_url=$last.find('a').attr('href');$last_offset=Ossn.MessagesURLparam('offset_message_xhr_recent',$last_url);var selfElement=$element;if($next){$url=$next.find('a').attr('href');$offset=Ossn.MessagesURLparam('offset_message_xhr_recent',$url);$url='?offset_message_xhr_recent='+$offset;if($.inArray($url,$calledOnce)==-1&&$offset>0){$calledOnce.push($url);Ossn.PostRequest({url:Ossn.site_url+'messages/xhr/recent'+$url,beforeSend:function(){$('.ossn-messages .messages-recent .messages-from .inner').append('<div class="ossn-messages-pagination-loading"><div class="ossn-loading"></div></div>');},callback:function(callback){$element=$(callback).find('.inner');if($element.length){$clone=$element.find('.container-table-pagination').html();$element.find('.container-table-pagination').remove();$('.ossn-messages .messages-recent .messages-from .inner').append($element.html());selfElement.html($clone);selfElement.appendTo('.ossn-messages .messages-recent .messages-from .inner');$('.ossn-messages .messages-recent .messages-from .inner .ossn-messages-pagination-loading').remove();if($offset==$last_offset){$('.ossn-messages .messages-recent .messages-from .inner .container-table-pagination').fadeOut();}}
return;},});}}}});});Ossn.MessageNotifcationPagination=function(event,$calledOnce){if($('.ossn-notification-messages .ossn-pagination').visibleInScroll().isVisible){$element=$('.ossn-notification-messages .container-table-pagination');$next=$element.find('.ossn-pagination .active').next();$last=$element.find('.ossn-pagination').find('li:last');$last_url=$last.find('a').attr('href');$last_offset=Ossn.MessagesURLparam('offset_message_xhr_recent',$last_url);var selfElement=$element;if($next){$url=$next.find('a').attr('href');$offset=Ossn.MessagesURLparam('offset_message_xhr_recent',$url);$url='?offset_message_xhr_recent='+$offset;if($.inArray($url,$calledOnce)==-1&&$offset>0){$calledOnce.push($url);Ossn.PostRequest({url:Ossn.site_url+'messages/xhr/notification'+$url,beforeSend:function(){$('.ossn-notification-messages').append('<div class="ossn-messages-notification-pagination-loading"><div class="ossn-loading"></div></div>');},callback:function(callback){$element=$(callback).find('.ossn-notification-messages');if($element.length){$clone=$element.find('.container-table-pagination').html();$element.find('.container-table-pagination').remove();$('.ossn-notification-messages').append($element.html());selfElement.html($clone);selfElement.appendTo('.ossn-notification-messages');$('.ossn-notification-messages .ossn-messages-notification-pagination-loading').remove();if($offset==$last_offset){$('.ossn-notification-messages .container-table-pagination').fadeOut();}}
return;},});}}}};$(document).ready(function(e){e.preventDefault;var offset=1;var old_offset=offset;var last_offset=0;var msg_window=$('.ossn-messages .ossn-widget .message-with .message-inner');var pagination=$('.ossn-messages .ossn-widget .message-with .message-inner .container-table-pagination');if(pagination.length){offset=2;$last=pagination.find('.ossn-pagination').find('li:last');$last_url=$last.find('a').attr('href');last_offset=Ossn.MessagesURLparam('offset_message_xhr_with',$last_url);}else{return;}
const SCROLLBAR_ADJUSTMENT=290;var client_height;var scroll_height;var scroll_top;var scroll_pos=0;var old_scroll_pos=0;const MAX_MESSAGES_PER_LOAD=10;var messages_loaded;var messages_displayed;var messages_xhr_inserted;msg_window.scroll(function(event){event.stopImmediatePropagation();client_height=parseInt(msg_window[0].clientHeight);scroll_height=parseInt(msg_window[0].scrollHeight);scroll_top=parseInt(msg_window[0].scrollTop);scroll_pos=scroll_height-client_height-scroll_top;old_scroll_pos=scroll_height-client_height;if(scroll_pos>=old_scroll_pos&&offset>old_offset&&offset<=last_offset){old_scroll_pos=scroll_pos;old_offset=offset;messages_loaded=(offset-1)*MAX_MESSAGES_PER_LOAD;messages_displayed=msg_window.find("[id^=message-item-]").length;messages_xhr_inserted=messages_displayed-messages_loaded;$url='?offset_message_xhr_with='+offset;$user_guid=msg_window.attr('data-guid');Ossn.PostRequest({url:Ossn.site_url+'messages/xhr/with'+$url+'&guid='+$user_guid,beforeSend:function(){msg_window.prepend('<div class="ossn-messages-with-pagination-loading"><div class="ossn-loading"></div></div>').fadeIn();},callback:function(callback){$element=$(callback).find('.message-inner');if($element.length){offset++;$last=$element.find('.ossn-pagination').find('li:last');$last_url=$last.find('a').attr('href');last_offset=Ossn.MessagesURLparam('offset_message_xhr_with',$last_url);if(messages_xhr_inserted){var messages=$element.find("[id^=message-item-]");for(var i=0;i<messages.length;i++){var msg_id=$(messages[i]).attr('id');if(msg_window.find('#'+msg_id).length){$element.find('#'+msg_id).remove();}}}
$clone=$element.find('.container-table-pagination').html();$element.find('.container-table-pagination').remove();msg_window.prepend($element.html());pagination.html($clone);pagination.prependTo(msg_window);}
msg_window.find('.ossn-messages-with-pagination-loading').remove();if(offset>last_offset){pagination.remove();}else{msg_window.animate({scrollTop:SCROLLBAR_ADJUSTMENT},0);}},});}});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('body').on('click','.ossn-message-delete',function(e){var id=$(this).attr('data-id');Ossn.MessageBox('messages/delete?id='+id);});Ossn.ajaxRequest({form:'#ossn-message-delete-form',url:Ossn.site_url+'action/message/delete',beforeSend:function(){$('#ossn-message-delete-form').html('<div class="ossn-loading"></div>');},callback:function(callback){if(callback['status']==true){var $parent=$('#message-item-'+callback['id']);if(callback['type']=='all'){$parent=$parent.find('.message-box-sent');$text="<i class='fa fa-times-circle'></i>"+Ossn.Print('ossnmessages:deleted');$parent.find('span').html($text);$parent.find('.time-created').hide();$parent.addClass('ossn-message-deleted');Ossn.MessageBoxClose();}
if(callback['type']=='me'){Ossn.MessageBoxClose();$parent.css({'opacity':0.5});setTimeout(function(){$parent.fadeOut('slow').remove();},1000);}}else{Ossn.MessageBoxClose();}}});$('body').on('click','.ossn-message-deletes',function(e){e.preventDefault();$text="<i class='fa fa-times-circle'></i>"+Ossn.Print('ossnmessages:deleted');$self=$(this);$parent=$(this).parent();$action=$(this).attr('href');if($action){Ossn.PostRequest({url:$action,action:false,callback:function(callback){if(callback==1){console.log($parent.attr('class'));if($parent.hasClass('message-box-sent')){$parent.find('span').html($text);$parent.find('.time-created').hide();$parent.addClass('ossn-message-deleted');$self.remove();}}}});}});});});$(document).ready(function(){var $MessageNotifcationPagination=[];$('body').on('click','#ossn-notif-messages',function(){$MessageNotifcationPagination=[];});document.addEventListener('scroll',function(event){var $elm=$(event.target);if($elm.attr('class')=='messages-inner'&&$elm.parent().parent().hasClass('ossn-notifications-box')){Ossn.MessageNotifcationPagination(event,$MessageNotifcationPagination);}},true);});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('#ossn-group-add').on('click',function(){Ossn.MessageBox('groups/add');});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$("#group-upload-cover").on('submit',function(event){event.preventDefault();var formData=new FormData($(this)[0]);var $url=Ossn.site_url+'action/group/cover/upload';var fileInput=$('#group-upload-cover').find("input[type='file']")[0],file=fileInput.files&&fileInput.files[0];if(file){var img=new Image();img.src=window.URL.createObjectURL(file);img.onload=function(){var width=img.naturalWidth,height=img.naturalHeight;window.URL.revokeObjectURL(img.src);if(width<1040||height<300){Ossn.trigger_message(Ossn.Print('profile:cover:err1:detail'),'error');return false;}else{$.ajax({url:Ossn.AddTokenToUrl($url),type:'POST',data:formData,async:true,beforeSend:function(xhr,obj){if($('.ossn-group-cover').length==0){$('.header-users').attr('style','opacity:0.7;');}else{$('.ossn-group-cover').attr('style','opacity:0.7;');}
$('.ossn-group-profile').find('.groups-buttons').find('a').hide();$('.ossn-group-cover').prepend('<div class="ossn-covers-uploading-annimation"> <div class="ossn-loading"></div></div>');},cache:false,contentType:false,processData:false,success:function(callback){if(callback['type']==1){if($('.ossn-group-cover').length==0){location.reload();}else{$('.ossn-group-cover').attr('style','');$('.ossn-covers-uploading-annimation').remove();$('.ossn-group-profile').find('.groups-buttons').find('a').show();$('.ossn-group-cover').find('img').attr('style','');$('.ossn-group-cover').find('img').show();$('.ossn-group-cover').find('img').attr('src',callback['url']);}}
if(callback['type']==0){Ossn.MessageBox('syserror/unknown');}}});}};}
return false;});$('#add-cover-group').on('click',function(e){e.preventDefault();$('#group-upload-cover').find('.coverfile').click();});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('#reposition-group-cover').on('click',function(){$('.group-c-position').attr('style','display:inline-block !important;');$('.ossn-group-cover-button').hide();$('.ossn-group-cover').unbind('mouseenter').unbind('mouseleave');Ossn.Drag();});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('.ossn-group-cover').on('mouseenter',function(){$('.ossn-group-cover-button').show();});$('.ossn-group-cover').on('mouseleave',function(){$('.ossn-group-cover-button').hide();});});});Ossn.repositionGroupCOVER=function($group){var cover_top=parseInt($('.ossn-group-cover').find('img').css('top'));var cover_left=parseInt($('.ossn-group-cover').find('img').css('left'));var $url=Ossn.site_url+"action/group/cover/reposition";$.ajax({async:true,type:'post',data:'&top='+cover_top+'&left='+cover_left+'&group='+$group,url:Ossn.AddTokenToUrl($url),success:function(callback){$("#draggable").draggable('destroy');$('.group-c-position').attr('style','display:none !important;');$('.ossn-group-cover').hover(function(){$('.ossn-group-cover-button').show();},function(){$('.ossn-group-cover-button').hide();});},});};Ossn.RegisterStartupFunction(function(){$(document).ready(function(){$('.ossn-group-change-owner').on('click',function(e){e.preventDefault();var new_owner=$(this).attr('data-new-owner');var is_admin=$(this).attr('data-is-admin');if(is_admin){var del=confirm(Ossn.Print('group:memb:make:owner:admin:confirm',[new_owner]));}else{var del=confirm(Ossn.Print('group:memb:make:owner:confirm',[new_owner]));}
if(del==true){var actionurl=$(this).attr('href');window.location=actionurl;}});});});Ossn.RegisterStartupFunction(function(){$(document).ready(function(){var EmojiiArray={"emoticons":["1f600","1f603","1f604","1f601","1f606","1f605","1f923","1f602","1f642","1f643","1f609","1f60a","1f607","1f970","1f60d","1f929","1f618","1f617","1f61a","1f619","1f60b","1f61b","1f61c","1f92a","1f61d","1f911","1f917","1f92d","1f92b","1f914","1f910","1f928","1f610","1f611","1f636","1f60f","1f612","1f644","1f62c","1f925","1f60c","1f614","1f62a","1f924","1f634","1f637","1f912","1f915","1f922","1f92e","1f927","1f975","1f976","1f974","1f635","1f92f","1f920","1f973","1f60e","1f913","1f9d0","1f615","1f61f","1f641","1f62e","1f62f","1f632","1f633","1f97a","1f626","1f627","1f628","1f630","1f625","1f622","1f62d","1f631","1f616","1f623","1f61e","1f613","1f629","1f62b","1f971","1f624","1f621","1f620","1f92c","1f608","1f47f","1f480","1f4a9","1f921","1f479","1f47a","1f47b","1f47d","1f47e","1f916","1f63a","1f638","1f639","1f63b","1f63c","1f63d","1f640","1f63f","1f63e","1f648","1f649","1f64a","1f476","1f466","1f467","1f468","1f469","1f474","1f475","1f46e","1f575","1f482","1f477","1f934","1f478","1f473","1f472","1f471","1f935","1f470","1f930","1f47c","1f385","1f936","1f64d","1f64e","1f645","1f646","1f481","1f64b","1f647","1f926","1f937","1f486","1f487","1f6b6","1f3c3","1f483","1f57a","1f46f","1f6c0","1f6cc","1f574","1f5e3","1f464","1f465","1f93a","1f3c7","26f7","1f3c2","1f3cc","1f3c4","1f6a3","1f3ca","26f9","1f3cb","1f6b4","1f6b5","1f3ce","1f3cd","1f938","1f93c","1f93d","1f93e","1f939","1f46b","1f46c","1f46d","1f48f","1f491","1f46a","1f933","1f4aa","1f448","1f449","261d","1f446","1f595","1f447","270c","1f91e","1f596","1f918","1f919","1f590","270b","1f44c","1f44d","1f44e","270a","1f44a","1f91b","1f91c","1f91a","1f44b","270d","1f44f","1f450","1f64c","1f64f","1f91d","1f485","1f442","1f443","1f463","1f440","1f441","1f445","1f444","1f48b","1f498","2764","1f493","1f494","1f495","1f496","1f497","1f499","1f49a","1f49b","1f49c","1f5a4","1f90d","1f49d","1f49e","1f49f","2763","1f48c","1f4a4","1f4a2","1f4a3","1f4a5","1f4a6","1f4a8","1f4ab","1f4ac","1f5e8","1f5ef","1f4ad","1f573","1f453","1f576","1f454","1f455","1f456","1f457","1f458","1f459","1f45a","1f45b","1f45c","1f45d","1f6cd","1f392","1f45e","1f45f","1f460","1f461","1f462","1f451","1f452","1f3a9","1f393","26d1","1f4ff","1f484","1f48d","1f48e"],"animals":["1f435","1f412","1f98d","1f9a7","1f436","1f415","1f429","1f43a","1f98a","1f431","1f408","1f981","1f42f","1f405","1f406","1f434","1f40e","1f984","1f98c","1f42e","1f402","1f403","1f404","1f437","1f416","1f417","1f43d","1f40f","1f411","1f410","1f42a","1f42b","1f418","1f98f","1f42d","1f401","1f400","1f439","1f430","1f407","1f43f","1f987","1f43b","1f428","1f43c","1f43e","1f983","1f414","1f413","1f423","1f424","1f425","1f426","1f427","1f54a","1f985","1f986","1f989","1f438","1f40a","1f422","1f98e","1f40d","1f432","1f409","1f433","1f40b","1f42c","1f41f","1f420","1f421","1f988","1f419","1f41a","1f980","1f990","1f991","1f40c","1f98b","1f41b","1f41c","1f41d","1f41e","1f577","1f578","1f982","1f490","1f338","1f4ae","1f3f5","1f339","1f940","1f33a","1f33b","1f33c","1f337","1f331","1f332","1f333","1f334","1f335","1f33e","1f33f","2618","1f340","1f341","1f342","1f343"],"food":["1f374","1f347","1f348","1f349","1f34a","1f34b","1f34c","1f34d","1f34e","1f34f","1f350","1f351","1f352","1f353","1f95d","1f345","1f951","1f346","1f954","1f955","1f33d","1f336","1f952","1f344","1f95c","1f330","1f35e","1f950","1f956","1f95e","1f9c0","1f356","1f357","1f953","1f354","1f35f","1f355","1f32d","1f32e","1f32f","1f959","1f95a","1f373","1f958","1f372","1f957","1f37f","1f371","1f358","1f359","1f35a","1f35b","1f35c","1f35d","1f360","1f362","1f363","1f364","1f365","1f361","1f366","1f367","1f368","1f369","1f36a","1f382","1f370","1f36b","1f36c","1f36d","1f36e","1f36f","1f37c","1f95b","2615","1f375","1f376","1f37e","1f377","1f378","1f379","1f37a","1f37b","1f942","1f943","1f37d","1f944","1f52a","1f3fa"],"travelplaces":["1f30d","1f30e","1f30f","1f310","1f5fa","1f5fe","1f3d4","26f0","1f30b","1f5fb","1f3d5","1f3d6","1f3dc","1f3dd","1f3de","1f3df","1f3db","1f3d7","1f3d8","1f3da","1f3e0","1f3e1","1f3e2","1f3e3","1f3e4","1f3e5","1f3e6","1f3e8","1f3e9","1f3ea","1f3eb","1f3ec","1f3ed","1f3ef","1f3f0","1f492","1f5fc","1f5fd","26ea","1f54c","1f54d","26e9","1f54b","26f2","26fa","1f301","1f303","1f3d9","1f304","1f305","1f306","1f307","1f309","2668","1f30c","1f3a0","1f3a1","1f3a2","1f488","1f3aa","1f682","1f683","1f684","1f685","1f686","1f687","1f688","1f689","1f68a","1f69d","1f69e","1f68b","1f68c","1f68d","1f68e","1f690","1f691","1f692","1f693","1f694","1f695","1f696","1f697","1f698","1f699","1f69a","1f69b","1f69c","1f6b2","1f6f4","1f6f5","1f68f","1f6e3","1f6e4","1f6e2","26fd","1f6a8","1f6a5","1f6a6","1f6d1","1f6a7","2693","26f5","1f6f6","1f6a4","1f6f3","26f4","1f6e5","1f6a2","2708","1f6e9","1f6eb","1f6ec","1f4ba","1f681","1f69f","1f6a0","1f6a1","1f6f0","1f680","1f6ce"],"activities":["231a","231b","23f3","23f0","23f1","23f2","1f55b","1f567","1f550","1f55c","1f551","1f55d","1f552","1f55e","1f553","1f55f","1f554","1f560","1f555","1f561","1f556","1f562","1f557","1f563","1f558","1f564","1f559","1f565","1f55a","1f566","1f311","1f312","1f313","1f314","1f315","1f316","1f317","1f318","1f319","1f31a","1f31b","1f31c","1f321","2600","1f31d","1f31e","2b50","1f31f","1f320","2601","26c5","26c8","1f324","1f325","1f326","1f327","1f328","1f329","1f32a","1f32b","1f32c","1f300","1f308","1f302","2602","26f1","26a1","2744","2603","26c4","2604","1f525","1f4a7","1f30a","26bd","26be","1f3c0","1f3d0","1f3c8","1f3c9","1f3be","1f3b3","1f3cf","1f3d1","1f3d2","1f3d3","1f3f8","1f94a","1f94b","1f945","26f3","26f8","1f3a3","1f3bd","1f3bf","1f3af","1f3b1","1f52e","1f3ae","1f579","1f3b0","1f3b2","2660","2665","2666","2663","1f0cf","1f004","1f3b4","1f3ad","1f5bc","1f3a8","1f396","1f3c6","1f3c5","1f947","1f948","1f949"],"objects":["2699","1f508","1f509","1f50a","1f4e2","1f4e3","1f4ef","1f514","1f3bc","1f3b5","1f3b6","1f399","1f39a","1f39b","1f3a4","1f3a7","1f4fb","1f3b7","1f3b8","1f3b9","1f3ba","1f3bb","1f941","1f4f1","1f4f2","260e","1f4de","1f4df","1f4e0","1f50b","1f50c","1f4bb","1f5a5","1f5a8","2328","1f5b1","1f5b2","1f4bd","1f4be","1f4bf","1f4c0","1f3a5","1f39e","1f4fd","1f3ac","1f4fa","1f4f7","1f4f8","1f4f9","1f4fc","1f50d","1f50e","1f56f","1f4a1","1f526","1f3ee","1f4d4","1f4d5","1f4d6","1f4d7","1f4d8","1f4d9","1f4da","1f4d3","1f4d2","1f4c3","1f4dc","1f4c4","1f4f0","1f5de","1f4d1","1f516","1f3f7","1f4b0","1f4b4","1f4b5","1f4b6","1f4b7","1f4b8","1f4b3","1f4b9","1f4b1","1f4b2","2709","1f4e7","1f4e8","1f4e9","1f4e4","1f4e5","1f4e6","1f4eb","1f4ea","1f4ec","1f4ed","1f4ee","1f5f3","270f","2712","1f58b","1f58a","1f58c","1f58d","1f4dd","1f4bc","1f4c1","1f4c2","1f5c2","1f4c5","1f4c6","1f5d2","1f5d3","1f4c7","1f4c8","1f4c9","1f4ca","1f4cb","1f4cc","1f4cd","1f4ce","1f587","1f4cf","1f4d0","2702","1f5c3","1f5c4","1f5d1","1f512","1f513","1f50f","1f510","1f511","1f5dd","1f528","26cf","2692","1f6e0","1f5e1","2694","1f52b","1f3f9","1f6e1","1f527","1f529","1f5dc","2696","1f517","26d3","2697","1f52c","1f52d","1f4e1","1f489","1f48a","1f6aa","1f6cf","1f6cb","1f6bd","1f6bf","1f6c1","1f6d2","1f6ac","26b0","26b1","1f5ff","1f383","1f384","1f386","1f387","2728","1f388","1f389","1f38a","1f38b","1f38d","1f38e","1f38f","1f390","1f391","1f380","1f381","1f397","1f39f","1f3ab"],"symbols":["1f6ae","1f6b0","267f","1f6b9","1f6ba","1f6bb","1f6bc","1f6be","1f6c2","1f6c3","1f6c4","1f6c5","26a0","1f6b8","26d4","1f6ab","1f6b3","1f6ad","1f6af","1f6b1","1f6b7","1f4f5","1f51e","1f507","1f515","2622","2623","2b06","2197","27a1","2198","2b07","2199","2b05","2196","2195","2194","21a9","21aa","2934","2935","1f503","1f504","1f519","1f51a","1f51b","1f51c","1f51d","1f6d0","269b","1f549","2721","2638","262f","271d","2626","262a","262e","1f54e","1f52f","2648","2649","264a","264b","264c","264d","264e","264f","2650","2651","2652","2653","26ce","1f500","1f501","1f502","25b6","23e9","23ed","23ef","25c0","23ea","23ee","1f53c","23eb","1f53d","23ec","23f8","23f9","23fa","23cf","1f3a6","1f505","1f506","1f4f6","1f4f3","1f4f4","2640","2642","2695","267b","269c","1f531","1f4db","1f530","2b55","2705","2611","2714","2716","274c","274e","2795","2796","2797","27b0","27bf","303d","2733","2734","2747","203c","2049","2753","2754","2755","2757","3030","00a9","00ae","2122","1f4af","1f520","1f521","1f522","1f523","1f524","1f170","1f18e","1f171","1f191","1f192","1f193","2139","1f194","24c2","1f195","1f17e","1f197","1f17f","1f198","1f199","1f19a","1f201","1f202","1f237","1f236","1f22f","1f250","1f239","1f21a","1f232","1f251","1f238","1f234","1f233","3297","3299","1f23a","1f235","25aa","25ab","25fb","25fc","25fd","25fe","2b1b","2b1c","1f536","1f537","1f538","1f539","1f53a","1f53b","1f4a0","1f518","1f532","1f533","26aa","26ab","1f534","1f535","1f3c1","1f6a9","1f38c","1f3f4","1f3f3","1f3e7"]};$('body').append('<div id="master-moji"><input type="hidden" id="master-moji-anchor" value=""><div class="dropdown emojii-container-main"> <div class="emojii-container" data-active="emoticons"> <ul class="nav nav-tabs"></ul> </div> </div> </div>');$.each(EmojiiArray,function(key,data){firstele=data[0];$('.emojii-container').find('.nav-tabs').append("<li class='ossn-emojii-tab' data-type='"+key+"'><a class='emojii' href='javascript:void(0);'>&#x"+firstele+";</a></li>");$('.emojii-container').append("<div class='emojii-list emojii-list-"+key+"'></div>");$.each(data,function(k,d){$('.emojii-list-'+key).append("<li class='emojii' data-val='"+d+"'>&#x"+d+";</li>");});});$('body').on('click','.ossn-emojii-tab',function(e){e.preventDefault();type=$(this).attr('data-type');$('.emojii-list').hide();$('.emojii-list-'+type).show();});if($('.message-form-form').length){$('<div class="ossn-message-attach-photo"><i class="fa fa-smile"></i></div>').prependTo('.message-form-form .controls');}
$('body').on('click','.ossn-comment-attach-photo .fa-smile',function(e){$parent=$(this).parent().parent().parent();Ossn.OpenEmojiBox('#'+$parent.find('.comment-box').attr('id'));});$('body').on('click','.ossn-wall-container-control-menu-emojii-selector',function(e){Ossn.OpenEmojiBox('.ossn-wall-container-data textarea');});$('body').on('click','.ossn-message-attach-photo .fa-smile',function(e){Ossn.OpenEmojiBox('.message-form-form textarea');});Ossn.OpenEmojiBox=function(anchor){if($('#master-moji .emojii-container-main').is(":hidden")){$('#master-moji-anchor').val(anchor);$('#master-moji .emojii-container-main').show();}else{$('#master-moji-anchor').val('');$('#master-moji .emojii-container-main').hide();}}
$('body').on('click','#master-moji .emojii-list li',function(e){e.preventDefault();var type=$(this).html();var anchor=$('#master-moji-anchor').val();var element=$(anchor);if(anchor.substring(0,12)=='#comment-box'){var tmp1=$(element).html();var tmp2=tmp1+" "+type;$(element).html(tmp2);}
else{var tmp1=$(element).val();var tmp2=tmp1+" "+type;$(element).val(tmp2);}
if(anchor=='.ossn-editor'){element=$('.ossn-editor').attr('id');tinymce.get(element).insertContent(' '+type);}
if(anchor=='#forum-editor'){$(anchor).summernote('editor.restoreRange');$(anchor).summernote('editor.focus');$(anchor).summernote('editor.insertText',' '+type);}});});});$(document).ready(function(){$('body').append('<div id="sounds"></div>');if(/android|ipod|iphone|ipad|blackberry|kindle/i.test(navigator.userAgent)&&!window.matchMedia('(display-mode: standalone)').matches){if($('.ossn-chat-windows-long').length){$('#sounds').append('<audio id="ossn-chat-sound" src="" preload="auto"></audio>');$('<div class="ossn-chat-pling"><i class="fa fa-bell-slash-o"></i></div>').prependTo('.ossn-chat-windows-long .inner');$('<div class="ossn-chat-pling"><i class="fa fa-bell-slash-o"></i></div>').prependTo('.ossn-chat-icon .ossn-chat-inner-text');}
if($('.message-form-form').length){$('#sounds').append('<audio id="ossn-message-sound" src="" preload="auto"></audio>');$('<div class="ossn-message-pling"><i class="fa fa-bell-slash-o"></i></div>').appendTo('.message-form-form .controls');}}
else{if($('.ossn-chat-windows-long').length){if(Ossn.getCookie("ossn_chat_bell")=='on'){$('#sounds').append('<audio id="ossn-chat-sound" src="https://www.joyriot.org/feed/components/OssnSounds/audios/pling.mp3" preload="auto"></audio>');$('<div class="ossn-chat-pling"><i class="fa fa-bell-o"></i></div>').prependTo('.ossn-chat-windows-long .inner');$('<div class="ossn-chat-pling"><i class="fa fa-bell-o"></i></div>').prependTo('.ossn-chat-icon .ossn-chat-inner-text');}
else{$('#sounds').append('<audio id="ossn-chat-sound" src="" preload="auto"></audio>');$('<div class="ossn-chat-pling"><i class="fa fa-bell-slash-o"></i></div>').prependTo('.ossn-chat-windows-long .inner');$('<div class="ossn-chat-pling"><i class="fa fa-bell-slash-o"></i></div>').prependTo('.ossn-chat-icon .ossn-chat-inner-text');chatSetCookie('ossn_chat_bell','off',365);}}
if($('.message-form-form').length){if(Ossn.getCookie("ossn_message_bell")=='on'){$('#sounds').append('<audio id="ossn-message-sound" src="https://www.joyriot.org/feed/components/OssnSounds/audios/pling.mp3" preload="auto"></audio>');$('<div class="ossn-message-pling"><i class="fa fa-bell-o"></i></div>').appendTo('.message-form-form .controls');}
else{$('#sounds').append('<audio id="ossn-message-sound" src="" preload="auto"></audio>');$('<div class="ossn-message-pling"><i class="fa fa-bell-slash-o"></i></div>').appendTo('.message-form-form .controls');chatSetCookie('ossn_message_bell','off',365);}}}
$(".ossn-chat-pling").on('click',function(e){e.stopImmediatePropagation();player=$('#ossn-chat-sound').get(0);pling='https://www.joyriot.org/feed/components/OssnSounds/audios/pling.mp3';bell=$('.ossn-chat-pling').find('i');if(bell.hasClass('fa fa-bell-slash-o')){bell.removeClass('fa fa-bell-slash-o');player.src=pling;player.play();bell.addClass('fa fa-bell-o');chatSetCookie('ossn_chat_bell','on',365);}
else{player.src='';bell.removeClass('fa fa-bell-o');bell.addClass('fa fa-bell-slash-o');chatSetCookie('ossn_chat_bell','off',365);}});$(".ossn-message-pling").on('click',function(e){player=$('#ossn-message-sound').get(0);pling='https://www.joyriot.org/feed/components/OssnSounds/audios/pling.mp3';bell=$('.ossn-message-pling').find('i');if(bell.hasClass('fa fa-bell-slash-o')){bell.removeClass('fa fa-bell-slash-o');player.src=pling;player.play();bell.addClass('fa fa-bell-o');chatSetCookie('ossn_message_bell','on',365);}
else{player.src='';bell.removeClass('fa fa-bell-o');bell.addClass('fa fa-bell-slash-o');chatSetCookie('ossn_message_bell','off',365);}});});Ossn.ChatplaySound=function(){var bell=document.getElementById('ossn-chat-sound');if(bell.readyState){bell.play();}};Ossn.MessageplaySound=function(){var bell=document.getElementById('ossn-message-sound');if(bell.readyState){bell.play();}};function chatSetCookie(cname,cvalue,exdays){var d=new Date();d.setTime(d.getTime()+(exdays*24*60*60*1000));Ossn.setCookie(cname,cvalue,d,'/');}
Ossn.register_callback('ossn','init','ossn_auto_pagination');Ossn.isInViewPort=function($params){var params=$params['params'];var callback=$params['callback'];if(!params){params={};}
if(!callback){callback=function(){};}
$($params['element']).scrolling(params);$($params['element']).on('scrollin',callback);};Ossn.AutoPaginationURLparam=function(name,url){if(!name||!url){return false;}
var results=new RegExp('[\?&]'+name+'=([0-9]*)').exec(url);if(results==null){return null;}else{return results[1]||false;}};function ossn_auto_pagination(){$(document).ready(function(){$calledOnce=[];$('.user-activity .ossn-pagination li').css({"visibility":"hidden"});$currenturlparams=Ossn.ParseUrl(window.location.href);$currentUrlQuery='';if($currenturlparams['query']&&$currenturlparams['query']!=''){$removeOffset=$currenturlparams['query'].split('&');if($removeOffset){$.each($removeOffset,function(k,v){if(v.includes('offset')){$removeOffset.splice(k,1);return false;}});}
$currentUrlQuery=$removeOffset.join('&');if($currentUrlQuery!=''){$currentUrlQuery='&'+$currentUrlQuery;}}
Ossn.isInViewPort({element:'.user-activity .ossn-pagination',callback:function(event,$all_elements){$next=$(this).find('.active').next();$last=$(this).find('li:last');var selfElement=$(this);if($next){$actual_next_url=$next.find('a').attr('href');$url=$actual_next_url;$offset=Ossn.AutoPaginationURLparam('offset',$url);$url='?offset='+$offset+$currentUrlQuery;$last_url=$last.find('a').attr('href');$last_offset=Ossn.AutoPaginationURLparam('offset',$last_url);if($.inArray($url,$calledOnce)==-1&&$offset>0){$calledOnce.push($url);Ossn.PostRequest({action:false,url:$actual_next_url,beforeSend:function(){$('.user-activity .ossn-pagination').append('<div class="ossn-loading"></div>');},callback:function(callback){$element=$(callback).find('.user-activity');if($element.length){$clone=$element.find('.ossn-pagination').html();$element.find('.ossn-pagination').remove();$('.user-activity').append($element.html());selfElement.html($clone);selfElement.appendTo('.user-activity .container-table-pagination .center-row');$('.user-activity .ossn-pagination li').css({"visibility":"hidden"});if($offset!=$last_offset){$('.user-activity .container-table-pagination').not(':last').remove();}else{$('.user-activity .container-table-pagination').remove();}}
return;},});}else{}}},});});}
$(document).ready(function(){$(document).on('focus','.friend-tab-item input',function(){$id=$(this).attr('id').split("-").pop();$status={url:Ossn.site_url+'action/message/typing/status/save?status=yes&subject_guid='+$id,action:true,callback:function(){}};Ossn.PostRequest($status);});$(document).on('blur','.friend-tab-item input',function(){$id=$(this).attr('id').split("-").pop();$status={url:Ossn.site_url+'action/message/typing/status/save?status=no&subject_guid='+$id,action:true,callback:function(){}};Ossn.PostRequest($status);});});$.fn.isInViewComments=function(){var win=$(window);var viewport={top:win.scrollTop(),left:win.scrollLeft()};viewport.right=viewport.left+win.width();viewport.bottom=viewport.top+win.height();var bounds=this.offset();if(!bounds){return false;}
bounds.right=bounds.left+this.outerWidth();bounds.bottom=bounds.top+this.outerHeight();return(!(viewport.right<bounds.left||viewport.left>bounds.right||viewport.bottom<bounds.top||viewport.top>bounds.bottom));};$(document).ready(function(){var comment_typing_send;$('body').on('focus','.comment-box',function(){$btype=false;if($(this).parent().parent().find('input[name="post"]').length){$guid=$(this).parent().parent().find('input[name="post"]').val();$btype='post';}
if($(this).parent().parent().find('input[name="entity"]').length){$guid=$(this).parent().parent().find('input[name="entity"]').val();$btype='entity';}
if(!$btype){return false;}
var $status={url:Ossn.site_url+'action/rtcomments/setstatus?type='+$btype+'&guid='+$guid,action:true,callback:function(){}};Ossn.PostRequest($status);comment_typing_send=setInterval(function(){Ossn.PostRequest($status);},3000);});$('body').on('blur','.comment-box',function(){if($(this).parent().parent().find('input[name="post"]').length){$btype='post';}
if($(this).parent().parent().find('input[name="entity"]').length){$btype='entity';}
clearInterval(comment_typing_send);});});Ossn.commentTyping=function($guid,$type){$addids=$(".ctyping-"+$type+"-"+$guid);$firstlist=$addids.parent().children(':first');if($firstlist.length){$firstclass=$firstlist.attr('class');if($firstclass.indexOf('ossn-comments-list')>=0){if(!$firstlist.hasClass("ossn-comments-list-"+$type.charAt(0)+""+$guid)){$firstlist.addClass("ossn-comments-list-"+$type.charAt(0)+""+$guid);}}}
var $cguid=$guid;var $ctype=$type;var $elem=$('.ctyping-'+$ctype+'-'+$cguid);var $timestamp=$('.ctyping-'+$ctype+'-'+$cguid).attr('data-time');var $status={url:Ossn.site_url+'action/rtcomments/status?guid='+$cguid+'&type='+$ctype,action:true,callback:function(callback){if(callback['status']=='typing'){$elem.find('.ctyping-c-item').fadeIn('slow');}else{$elem.find('.ctyping-c-item').fadeOut('slow');}
if(callback['lists']!=''){for(i=0;i<callback['lists'].length;i++){$id=$($.parseHTML(callback['lists'][i])).attr('id');$id=$id.replace(/[^0-9]/g,"");if($id&&$('#comments-item-'+$id).length==0){$(".ossn-comments-list-"+$type.charAt(0)+""+$guid).append(callback['lists'][i]).fadeIn();}}}}};setInterval(function(){if($('.ctyping-'+$ctype+'-'+$cguid).isInViewComments()){if($(".ossn-comments-list-"+$type.charAt(0)+""+$guid).find('.comments-item').length){var $ids=new Array();$($(".ossn-comments-list-"+$type.charAt(0)+""+$guid).find('.comments-item')).each(function(){$ids.push($(this).attr('id').replace('comments-item-',''));});$status['params']='&comments_ids='+$ids.join(',')+'&timestamp='+$timestamp;}
Ossn.PostRequest($status);}else{$elem.find('.ctyping-c-item').fadeOut('slow');}},4000);};$(document).ready(function(){var $listsbg=[{"name":"pbg1","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/1.jpg","color_hex":"#fff"},{"name":"pbg2","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/2.jpg","color_hex":"#fff"},{"name":"pbg3","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/3.jpg","color_hex":"#fff"},{"name":"pbg4","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/4.jpg","color_hex":"#fff"},{"name":"pbg5","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/5.jpg","color_hex":"#fff"},{"name":"pbg6","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/6.jpg","color_hex":"#fff"},{"name":"pbg7","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/7.jpg","color_hex":"#333"},{"name":"pbg8","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/8.jpg","color_hex":"#333"},{"name":"pbg9","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/9.jpg","color_hex":"#333"},{"name":"pbg10","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/10.jpg","color_hex":"#333"},{"name":"pbg11","url":"https:\/\/www.joyriot.org\/feed\/components\/OssnPostBackground\/images\/11.jpg","color_hex":"#333"}];if($('.ossn-wall-container-data').length){$('<div id="ossn-wall-postbg" style="display:none;"></div>').insertAfter('.ossn-wall-container-data textarea');$.each($listsbg,function(){$('#ossn-wall-postbg').append('<span class="" data-postbg-type="'+this['name']+'" style="background:url(\''+this['url']+'\'";background-position: center; background-size: cover;"></div>');});$('#ossn-wall-form').append('<input class="postbg-input" name="postbackground_type" type="hidden"/>');}
$('body').on('click','.ossn-wall-container-control-menu-postbg-selector',function(){$('.ossn-wall-container-data div').each(function(){$id=$(this).attr('id');if($id&&$id.indexOf('ossn-wall-')>=0){$(this).hide();}});if($('#ossn-wall-postbg').attr('data-toggle')==0||!$('#ossn-wall-postbg').attr('data-toggle')){$('#ossn-wall-postbg').attr('data-toggle',1);$('#ossn-wall-postbg').show();}else{$('.ossn-wall-container-data .postbg-container').attr('style','');$('.ossn-wall-container-data textarea').removeClass('postbg-container');if($('.postbg-input').length){$('.postbg-input').val('');}
$('#ossn-wall-postbg').attr('data-toggle',0);$('#ossn-wall-postbg').hide();}});$('.ossn-wall-container-data textarea').on('keyup',function(){var length=String.prototype.trim(this.value).length;if(length>125){$('.ossn-wall-container-data .postbg-container').attr('style','');$('.ossn-wall-container-data textarea').removeClass('postbg-container');if($('.postbg-input').length){$('.postbg-input').val('');}}});$('body').on('click','#ossn-wall-postbg span',function(){$type=$(this).attr('data-postbg-type');var i=0;for(i=0;i<=$listsbg.length;i++){if($listsbg[i]['name']==$type){$('.ossn-wall-container-data textarea').addClass('postbg-container');$('.ossn-wall-container-data .postbg-container').css({'background':'url("'+$listsbg[i]['url']+'")','background-position':'center','background-size':'cover','color':$listsbg[i]['color_hex'],});$('.postbg-input').val($type);break;}}});$(document).ajaxComplete(function(event,xhr,settings){var $url=settings.url;$pagehandler=$url.replace(Ossn.site_url,'');if($pagehandler.indexOf('action/wall/post/a')>=0||$pagehandler.indexOf('action/wall/post/g')>=0||$pagehandler.indexOf('action/wall/post/u')>=0||$pagehandler.indexOf('action/wall/post/bpage')>=0){$('.ossn-wall-container-data .postbg-container').attr('style','');$('.ossn-wall-container-data textarea').removeClass('postbg-container');if($('.postbg-input').length){$('.postbg-input').val('');}
$('.ossn-wall-container-data div').each(function(){$id=$(this).attr('id');if($id&&$id.indexOf('ossn-wall-')>=0){$(this).hide();}});}
if($pagehandler.indexOf('wall/post/embed')>=0){$data=settings.data;$listsdata=$data.split('&');if($listsdata.length>0){$.each($listsdata,function($key,$value){if($value.indexOf('guid=')>=0){$guid=$value.replace('guid=','');$element=$('#activity-item-'+$guid);if($element.length&&$element.find('.postbg-container')){$text=$element.find('.postbg-container').text();if($text&&$text.length>125){$element.find('.postbg-container').removeClass('postbg-container').attr('style','');$element.find('.postbg-text').removeClass('postbg-text');}}}});}}});});Ossn.register_callback('ossn','init','share_post_box');function share_post_box(){$(document).ready(function(){$('body').on('click','.post-control-sharepost',function(e){$guid=$(this).attr('data-guid');Ossn.MessageBox('sharepost?guid='+$guid);});$('body').on('change','#sharepost-select-type',function(){$type=$(this).val();switch($type){case'newsfeed':$('#sharepost-friends').hide();$('#sharepost-groups').hide();break;case'group':$('#sharepost-friends').hide();$('#sharepost-groups').show();break;case'friend':$('#sharepost-friends').show();$('#sharepost-groups').hide();break;default:$('#sharepost-friends').hide();$('#sharepost-groups').hide();}});});}