",{class:"comment-notification "+t,text:e});$(".msg-reply-holder").before(n),n.fadeIn(300),setTimeout(function(){n.fadeOut(300,function(){$(this).remove()})},3e3)}$(".ui-dialog-buttonset button").click(function(e){e.preventDefault(),$("#ui-dialog-aler").css("display","none")}),$(".ui-dialog-titlebar-close").click(function(e){e.preventDefault(),$("#ui-dialog-aler").css("display","none")}),loadUser(),darkmod(),$("#ajax-next-page")&&$("#ajax-next-page").click(function(e){e.preventDefault();var e=$(this).find("a").attr("href"),t=e.match(/page\/(\d+)/);let n=t?t[1]:1;var i=parseInt(n,10)+1,t=`/categoryajax/${n}/33969`;$(".pages a").removeClass("active"),history.pushState(null,null,e),$.ajax({url:t,type:"GET",dataType:"json",success:function(a){var e;a.success?(Array.isArray(a.html)?a.html.forEach(function(e,t){$(".app_list").append(e);e=$("html, body").prop("scrollHeight");$("html, body").animate({scrollTop:e},200)}):"string"==typeof a.html&&($(".app_list").append(a.html),e=$("html, body").prop("scrollHeight"),$("html, body").animate({scrollTop:e},200)),a.curPage==a.maxPage?($(".app_list").append($("#navcollapse")),$("#ajax-next-page").hide()):($(".app_list").append($("#navcollapse")),$("#ajax-next-page a").attr("href",function(e,t){return t.replace(`/page/${n}/`,`/page/${i}/`)})),e="1"===n?'.pages a[href="//"]':`.pages a[href="//page/${n}/"]`,$(e).addClass("active"),$(".navigation_ext > a").each(function(){let n=$(this);var e=n.attr("href").replace(/\/page\/(\d+)\//,function(e,t){t=parseInt(t,10)+1;return t<=a.maxPage?`/page/${t}/`:(n.hide(),e)});n.attr("href",e)}),$("#navcollapse_btn .fbold").html("Page "+a.curPage)):$("#ajax-next-page").hide()},error:function(e,t,n){console.error("Lỗi:",n)}})}),$("#comments form").submit(function(e){e.preventDefault();let t=$(this);$.ajax({type:"POST",url:"/comment/add",data:$(this).serialize(),beforeSend:function(){t.find(".btn-submit").prop("disabled",!0)},success:function(e){1!=e.code?e.message&&showNotification(e.message,"error"):(showNotification("Your comment has been submitted successfully!","success"),t.find("textarea").val(""),t.find('input[name="rating"]').prop("checked",!1),t.find('input[name="parentid"]').val(""),$(".msg-reply-holder").empty())},error:function(e){console.log(e),showNotification("An error occurred. Please try again.","error")},complete:function(){t.find(".btn-submit").prop("disabled",!1)}})}),$("#comments").on("click","a.reply",function(e){e.preventDefault();var e=$(this),t=e.closest("#comments").find("form"),e=e.closest(".comment"),n=e.data("text"),e=e.data("id");t.find('input[name="parentid"]').val(e),t.find(".msg-reply-holder").html(`
${n}
`),t.find('textarea[name="content"]').focus()}),$("#comments").on("click",".msg-reply-holder",function(e){e.preventDefault();e=$(this);e.closest("#comments").find("form").find('input[name="parentid"]').val(null),e.html("")}),$("#comments").on("click",".btn-seemore-comment",function(e){e.preventDefault();var t=$(this),e=t.data("pid"),n=t.closest("#comments").data("lid"),a=t.closest(".lch-sort").find(".lchs-current").data("sort"),i=t.data("total"),o=parseInt(t.closest("#comments").find(".list-comments>li").length)||0;t.prop("disabled",!0),$.ajax({url:domain+"/comment/ajax",data:{sort:a,pid:e,lid:n,offset:o},method:"POST",success:function(e){t.prop("disabled",!1),1==e.code&&(t.closest("#comments").find(".list-comments").append(e.data),o=parseInt(t.closest("#comments").find(".list-comments>li").length),t.find("span").text(i-o),i-o<=0)&&t.addClass("hidden")}})}),$("#comments").on("click",".btn-seemore-reply",function(e){e.preventDefault();var t=$(this),e=t.data("pid"),n=t.closest("#comments").data("lid"),a=t.data("total"),i=t.closest(".lch-sort").find(".lchs-current").data("sort"),o=parseInt(t.closest("#comments").find(".list-replies>li").length)||0;t.prop("disabled",!0),$.ajax({url:domain+"/comment/reply/ajax",data:{sort:i,parentid:e,lid:n,offset:o},method:"POST",success:function(e){t.prop("disabled",!1),1==e.code&&(t.closest(".comment").find(".list-replies").append(e.data),o=parseInt(t.closest(".comment").find(".list-replies>li").length)||0,t.find("span").text(a-o),a-o<=0)&&t.addClass("hidden")}})}),$("#comments").on("click",".links .like",function(e){e.preventDefault();var a=$(this),e=a.closest(".comment").data("id"),i=$("#pagePopup"),o=i.find(".bigText"),s=i.find(".subText");$.ajax({url:"/comment/like",data:{id:e},method:"POST",success:function(e){var t,n=1==e.code?"text-success":"text-danger";1==e.code?(t=0
(${e.numLike})`:"",t=e.isLike?"Like "+t:"Unlike "+t,a.find("span").html(t),e.isLike||a.addClass("unlike")):(o.text(e.message),s.html(e.button),o.text(o.data("text")),i.find(".subText").html(`${e.message}
`),i.addClass("open"))}})})