"use strict";$('[data-toggle="tooltip"]').tooltip();var friendAdded=false;function addFriend(el,id){if(!friendAdded){friendAdded=true;$.ajax({url:'/api/v1/friend/add',type:'post',context:el,headers:{'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')},data:{id:id},success:function success(res){if(res.status=='ok'){$(el).after('
'+userLang.oczekujesznazaakcept+'
').remove();showNoty(userLang.zaprosilesuzytkdoznajomych,'success');}else{showNoty(userLang.blad,'danger');friendAdded=false;} return true;},error:function error(err){friendAdded=false;}});}} function acceptFriend(el,id){$.ajax({url:'/api/v1/friend/add',type:'post',context:el,headers:{'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')},data:{id:id},success:function success(res){if(res.status=='ok'){$(el).after(''+userLang.usunznajomego+'').remove();showNoty(userLang.jestescieznaj,'success');}else{showNoty(userLang.blad,'danger');} return true;},error:function error(err){}});} function removeFriend(el,id){$.ajax({url:'/api/v1/friend/remove',type:'post',context:el,headers:{'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')},data:{id:id},success:function success(res){if(res.status=='ok'){$(el).after(''+userLang.dodajznajomego+'').remove();showNoty(userLang.usunalesznaj,'warning');}else{showNoty(userLang.blad,'danger');} return true;},error:function error(err){}});} $('.page-single-user').on('click','#add-friend',function(){var id=$(this).data('id');addFriend(this,id);});$('#moreFriends').on('click',function(e){e.preventDefault();$('#myTab a[href="#single-user-friends"]').tab('show');});$('.page-single-user').on('click','#accept-friend',function(){var id=$(this).data('id');acceptFriend(this,id);});$('.page-single-user').on('click','#remove-friend',function(){var id=$(this).data('id');removeFriend(this,id);});$('.page-single-user').on('click','#profile-chat',function(){var id=$(this).data('id');var name=$('.profile-header').find('#profile-name').text();var avatar=$('.profile-header').find('#profile-avatar').attr('src');if(detectmob()==false){openBox(id,name,avatar);return false;} window.location.href='/pl/chat/'+name.toLowerCase().trim();});"use strict";app.controller("friendsListsCtrl",["$scope","$timeout","$http","$q","$rootScope",function($scope,$timeout,$http,$q,$rootScope){var vm=this;console.log("nowy controller lol friends: ",friends);vm.skip=24;vm.friends=friends;vm.user_id=user_id;vm.searchName=null;vm.canLoadMore=false;if(vm.friends.length==24){vm.canLoadMore=true;} vm.loadMoreFriends=function(){getMoreFriends(0);};vm.searchFriends=function(){if(vm.searchName.length>0){getMoreFriends(1);}else{getMoreFriends(0);}};$scope.$watch("vm.searchName",function(newValue,oldValue){console.log("newValue",newValue);console.log("oldValue",oldValue);},true);function getMoreFriends(searched){$.ajax({url:"/api/v1/user/friends/load",type:"GET",context:this,headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{skip:vm.skip,limit:24,name:vm.searchName,id:vm.user_id},success:function success(res){if(searched==0){for(var i in res){vm.friends.push(res[i]);} if(res.length<24){vm.canLoadMore=false;}else{vm.canLoadMore=true;} vm.skip=vm.skip+res.length;vm.loaded=true;}else{vm.canLoadMore=false;vm.friends=res;vm.skip=0;}},error:function error(res){console.log("errror",res);vm.loaded=true;}});} var typingTimer;var doneTypingInterval=500;vm.clearTimeout=function(){clearTimeout(typingTimer);};vm.openResults=function(){if(typeof vm.searchName!="undefined"){if(vm.searchName.length>0){clearTimeout(typingTimer);typingTimer=setTimeout(getMoreFriends,doneTypingInterval);}else{previous="";vm.clearRecords();vm.downloaded=false;}}};vm.clearRecords=function(){vm.friends=friends;vm.skip=24;if(vm.friends.length==24){vm.canLoadMore=true;}else{vm.canLoadMore=false;}};vm.lol=function(){console.log("down");};}]);"use strict";$(function(){var el=$("#form-comment").find("#comment");el.emojioneArea({pickerPosition:"bottom",tonesStyle:"bullet",saveEmojiAs:"unicode"});$(document).off('click',".edit-comment").on("click",".edit-comment",function(){editComment($(this).data("id"));});$(document).off('click',".confirm-comment-edit").on("click",".confirm-comment-edit",function(){confirmEdit($(this).data("id"));});});$("#form-comment").submit(function(event){var comment=$(this).find("#comment").val().replace(/\n/g,"
");comment=emojione.toShort(comment);var id=$(this).find("input[name='id']").val();$.ajax({url:$commentapi,type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{comment:comment,id:id},success:function success(res){var el=$("#comment").emojioneArea();el[0].emojioneArea.setText("");$("#form-comment").find(".alert").remove();$("#form-comment").find("#comment").val("");$(".comments-wrap").find(".alert").remove();if(typeof res.url!=="undefined"&&res.url&&window.location.href!=res.url){getPage(res.url,0);return true;} $(".comments-wrap").append(res.data);$('[data-toggle="tooltip"]').tooltip();},error:function error(err){$("#form-comment").find(".alert").remove();$("#form-comment").find("button").removeClass("on-loading").find(".loader").remove();if(typeof err.responseJSON=="undefined"){showNoty(":(","danger");}else{showNoty(err.responseJSON.error,"danger");$("#form-comment").prepend('
'+err.responseJSON.error+"
");}}});event.preventDefault();return false;});$(".comments-wrap").on("click",".like",function(){var id=$(this).data("id");var type=$(this).data("type");if(!$(this).hasClass("voted")){$.ajax({url:$likeapi,type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},context:this,data:{target_id:id,type:type,like:1},success:function success(res){var thisParent=$(this).parent();var value=$(this).find(".postLikesValue").html();if(thisParent.find(".dislike").hasClass("voted")){var dislikeValue=parseInt(thisParent.find(".postDislikesValue").html());thisParent.find(".dislike").removeClass("voted");thisParent.find(".postDislikesValue").html(dislikeValue-1);} thisParent.find(".like").addClass("voted");thisParent.find(".postLikesValue").html(parseInt(value)+1);},error:function error(err){if(typeof err.responseJSON=="undefined"){showNoty(gameLang.wystapilblad,"danger");}else{showNoty(err.responseJSON.error,"danger");}}});}});$(".comments-wrap").on("click",".dislike",function(){var id=$(this).data("id");var type=$(this).data("type");if(!$(this).hasClass("voted")){$.ajax({url:$likeapi,type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},context:this,data:{target_id:id,type:type,like:0},success:function success(res){var thisParent=$(this).parent();var value=$(this).find(".postDislikesValue").html();if(thisParent.find(".like").hasClass("voted")){var likeValue=parseInt(thisParent.find(".postLikesValue").html());thisParent.find(".like").removeClass("voted");thisParent.find(".postLikesValue").html(likeValue-1);} thisParent.find(".dislike").addClass("voted");thisParent.find(".postDislikesValue").html(parseInt(value)+1);},error:function error(err){if(typeof err.responseJSON=="undefined"){showNoty(gameLang.wystapilblad,"danger");}else{showNoty(err.responseJSON.error,"danger");}}});}});$(".comments-wrap").on("click",".remove-btn",function(){var id=$(this).data("id");var type=$(this).data("type");console.log("type: ",type);console.log("id: ",id);var buttonsData={cancel:{class:"btn btn-secondary",text:''},confirm:{class:"btn btn-primary",text:''}};var buttons=[Noty.button(buttonsData.cancel.text,buttonsData.cancel.class,function(){n.close();}),Noty.button(buttonsData.confirm.text,buttonsData.confirm.class,function(){$.ajax({url:"/api/v1/mod/post/remove",type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{com_id:id,type:type},success:function success(res){showNoty(res.mess,"success");n.close();if(res.back==1){console.log("parent: ",parent.history);if(typeof res.back_url!=="undefined"&&res.back_url&&window.location.href!=res.back_url){getPage(res.back_url,0);return true;}} $('[data-id="'+id+'"]').hide();},error:function error(err){console.log("err",err);showNoty(err.error,"danger");n.close();}});})];var n=new Noty({type:"dialog",text:forumLang.czynapewnousunackomentarz,layout:"center",closeWith:"button",animation:{open:"animated bounceIn",close:"animated bounceOut"},buttons:buttons}).show();});$(".comments-wrap").on("click",".remove-ban-btn",function(){var id=$(this).data("id");var type=$(this).data("type");var buttonsData={cancel:{class:"btn btn-secondary",text:''},confirm:{class:"btn btn-primary",text:''}};var buttons=[Noty.button(buttonsData.cancel.text,buttonsData.cancel.class,function(){n.close();}),Noty.button(buttonsData.confirm.text,buttonsData.confirm.class,function(){$.ajax({url:"/api/v1/mod/post/remove",type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{com_id:id,type:type,ban:1},success:function success(res){showNoty(res.mess,"success");n.close();if(res.back==1){console.log("parent: ",parent.history);if(typeof res.back_url!=="undefined"&&res.back_url&&window.location.href!=res.back_url){getPage(res.back_url,0);return true;}} $('[data-id="'+id+'"]').hide();},error:function error(err){console.log("err",err);showNoty(err.error,"danger");n.close();}});})];var n=new Noty({type:"dialog",text:forumLang.czynapewnousunackomentarz,layout:"center",closeWith:"button",animation:{open:"animated bounceIn",close:"animated bounceOut"},buttons:buttons}).show();});$(".comments-wrap").on("click",".remove-all-btn",function(){var id=$(this).data("id");var type=$(this).data("type");var buttonsData={cancel:{class:"btn btn-secondary",text:''},confirm:{class:"btn btn-primary",text:''}};var buttons=[Noty.button(buttonsData.cancel.text,buttonsData.cancel.class,function(){n.close();}),Noty.button(buttonsData.confirm.text,buttonsData.confirm.class,function(){$.ajax({url:"/api/v1/mod/userspost/remove",type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{com_id:id,type:type},success:function success(res){showNoty(res.mess,"success");n.close();if(res.back==1){console.log("parent: ",parent.history);if(typeof res.back_url!=="undefined"&&res.back_url&&window.location.href!=res.back_url){getPage(res.back_url,0);return true;}} $('[data-id="'+id+'"]').hide();},error:function error(err){console.log("err",err);showNoty(err.error,"danger");n.close();}});})];var n=new Noty({type:"dialog",text:forumLang.napewnousunacwszystkiekomentarze,layout:"center",closeWith:"button",animation:{open:"animated bounceIn",close:"animated bounceOut"},buttons:buttons}).show();});$(".comments-wrap").on("click",".report",function(){var id=$(this).data("id");var type=$(this).data("type");if(!$(this).hasClass("voted")){$.ajax({url:"/api/v1/forum/reportCom",type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},context:this,data:{com_id:id,type:type},success:function success(res){showNoty(res.message,"success");},error:function error(err){if(typeof err.responseJSON=="undefined"){showNoty(gameLang.wystapilblad,"danger");}else{showNoty(err.responseJSON.error,"danger");}}});}});function parseComment(text){console.log("text",text);var replaced=text.replace(//g,"$1");var removedBr=replaced.replace(/
/g,"\n");var textWithShortName=emojione.toShort(removedBr);return textWithShortName;} function hideEditComment(id,newText){var comment=$(".comments-wrap").find(".single-comment[data-id="+id+"]");comment.removeClass("editing");comment.find(".edit-holder").remove();var commentWrapper=comment.find(".comment-wrapper");commentWrapper.find("p").html(emojione.shortnameToImage(newText));commentWrapper.show();} function editComment(id){if(!emojione)return false;var comment=$(".comments-wrap").find(".single-comment[data-id="+id+"]");comment.addClass("editing");var commentText=comment.find(".comment-text");var commentWrapper=comment.find(".comment-wrapper");var convertedText=parseComment(commentWrapper.find(">p").html().trim());var textareaHolder="
\n \n \n
");commentText.append(textareaHolder);commentWrapper.hide();var textareaElem=commentText.find(".comment-edit[data-id=\"".concat(id,"\"]"));textareaElem.emojioneArea({pickerPosition:"bottom",tonesStyle:"bullet",saveEmojiAs:"unicode"});} function confirmEdit(id){var comment=$(".comments-wrap").find(".single-comment[data-id="+id+"]");var commentType=comment.data("type");console.log("commentType",commentType);var textareaElem=comment.find(".comment-edit[data-id=\"".concat(id,"\"]"));var converted=textareaElem.val().replace(/\n/g,"
");converted=emojione.toShort(converted);if(commentType==1){var type="forum";} if(commentType==0){var type="games";} if(commentType==2){var type="news";} console.log("type",type);changeComment(id,converted,type);} function changeComment(id,newText,type){$.ajax({url:"/api/v1/forum/editPost",type:"post",headers:{"X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},data:{type:type,id:id,text:newText},success:function success(res){console.log("res",res);hideEditComment(id,newText);},error:function error(err){console.log("err",err);if(typeof err.responseJSON=="undefined"){showNoty(gameLang.wystapilblad,"error");}else{showNoty(err.responseJSON.error,"error");}}});}