/* Attachments toggle */ function toggleAttachments() { $j("#open").toggle(); $j("#close").toggle(); $j("#attachments-outline").toggle(); $j("#attachments-details").toggle("fast"); return false; } /* Setup attach form */ function setupAttach(lId,cId,type){ var html = "
"+ ""+ ""+ ""+ ""+ ""+ "
"+ " "+ " "+ " "+ "
"+ "
"; var html1= "
"+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ "
"+ " "+ " "+ " "+ "
  (tùy chọn)
"+ "
"; if (type=='media') { $j("#attach-form" + cId).html(html1); } else { $j("#attach-form" + cId).html(html); } $j("#attach-form" + cId).css("display","block"); return false; } function cancelAttach(cId) { $j("#aloading-" + cId).remove(); $j("#attach-form" + cId).html(""); $j("#attach-form" + cId).css("display","none"); return false; } /* Attach to Comment */ function getAttachmentData(lId,cId,media) { query = "act=add&media="+media+"&link="+lId+"&comment="+cId; var attachment = $j("#attachment" + cId).val(); query += "&attachment=" + encodeURIComponent(attachment); var embedded = $j("#embedded" + cId).val(); query += "&embedded=" + encodeURIComponent(embedded); var cmt_type = parseInt($j("input#foreign_type_user").val()); query += "&cmt_type=" + encodeURIComponent(cmt_type); return query; } function attach2Comment(lId,cId,media) { var query = getAttachmentData(lId,cId,media); var loading = "
" + "" + "
" $j("#attachments"+cId).append(loading); $j("#attachments"+cId).css("display","block"); toggleButton("sattachment"+cId); $j.post(my_base_url+my_pligg_base+"/ajaxAttachment", query, function(result) { ajaxAttach2CommentCallback(result,cId); } ); return false; } function ajaxAttach2CommentCallback(result,cId) { if (/ERROR:/.test(result)) { result = result.substring(7, result.length); $j("#aloading-" + cId).remove(); toggleButton("sattachment"+cId); window.alert(result); } else { $j("#attachments"+cId).append(result); $j("#attachments"+cId).css("display","block"); $j("#aloading-" + cId).remove(); toggleButton("sattachment"+cId); cancelAttach(cId); } } function ajaxManageComment(action,cID){ if(confirm('Are you sure ?')){ var query = "action="+action+"&comment_id="+cID; $j.post(my_base_url+my_pligg_base+"/ajaxCommentManage", query, function(result) { ajaxManageCommentCallback(result,cID); } ); return false; } } function ajaxRemoveAttachmentCallback(result,str){ $j("#"+str).html(""); } function ajaxManageCommentCallback(result,cID){ $j("#c-toggle-" + cID).html(result); } function ajaxRemoveAttachment(aID,cID,str){ if(confirm('Are you sure ?')) { var query = "act=remove&attachment_id="+aID+"&comment_id="+cID; $j.post(my_base_url+my_pligg_base+"/ajaxAttachment", query, function(result) { ajaxRemoveAttachmentCallback(result,str); } ); return false; } } /* Setup edit attachment */ function setupEditAttachment(hash,cId){ $j("#label-"+hash+"-"+cId).css("display","none"); $j("#form-"+hash+"-"+cId).css("display","inline"); return false; } function cancelEditAttachment(hash,cId) { $j("#form-"+hash+"-"+cId).css("display","none"); $j("#label-"+hash+"-"+cId).css("display","inline"); return false; } function updateAttachment(hash,cId) { $j("#ajaxLoading").show(); var newLabel = $j("#text-"+hash+"-"+cId).val(); query = "act=edit&hash=" + hash + "&comment=" + cId + "&label=" + encodeURIComponent(newLabel); var cmt_type = parseInt($j("input#foreign_type_user").val()); query += "&cmt_type=" + encodeURIComponent(cmt_type); $j.post(my_base_url+my_pligg_base+"/ajaxAttachment", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { $j("#label-" + hash + "-" + cId).text(result); cancelEditAttachment(hash,cId) } } ); $j("#ajaxLoading").hide(); return false; } function removeAttachment(hash,cId) { $j("#ajaxLoading").show(); query = "act=del&hash=" + hash + "&comment=" +cId; var cmt_type = parseInt($j("input#foreign_type_user").val()); query += "&cmt_type=" + encodeURIComponent(cmt_type); $j.post(my_base_url+my_pligg_base+"/ajaxAttachment", query, function(result) { $j("#" + hash + "-" + cId).remove(); } ); $j("#ajaxLoading").hide(); return false; } /* Show/Hide attachment's embedded/thumb */ function showAEmbed(aId){ var toggler = $j("#a-show-embedded-"+aId); var embedDiv = $j("#a-embedded-"+aId); var content = $j(embedDiv).html(); if(content==null||content==""){ var loading = "
" + "" + "
" $j(embedDiv).html(loading); $j(embedDiv).css('display','block'); var embedVideo=""; $j.post(my_base_url+my_pligg_base+"/ajaxAttachment", "act=getEmbedded&id="+aId, function(result) { $j(embedDiv).html(result); $j(toggler).html(""); $j(toggler).attr('title','Đóng'); } ); } else { $j(embedDiv).html(""); $j(embedDiv).css('display','none'); $j(toggler).html(""); $j(toggler).attr('title','Mở'); } return false; } /* Setup comment form */ function setupComment() { $j.scrollTo('#c0-form', 500, {onAfter:function() {$j("textarea#ccontent").focus();}}); return false; } function setupCommentReply(cId,lId,status,date,link_url){ var cForm = $j("#c" + cId + "-form"); var cFooter = $j("#c" + cId + "-foot"); var html="
"+ ""+ ""+ ""+ "
Trả lời"+ ""+ "Đóng"+ ""+ "
"+ "
"+ "
"+ ""+ ""+ ""+ ""+ "Đính liên kết"+ "Chèn mã nhúng"+ "
"+ ""+ ""+ "
"+ "
"+ ""+ ""+ ""+ ""+ ""+ "
"+ "
"+ "
"+ "
"; cForm.html(html); // show it cFooter.hide();//slideUp("fast"); cForm.show();//slideDown("fast", var cText = $j("#txt_comment_" + cId); cText.focus(); return false; } function cancelCommentReply(cId) { var cForm = $j("#c" + cId + "-form"); var cFooter = $j("#c" + cId + "-foot"); cForm.hide();//slideUp("fast"); cFooter.show();//slideDown("fast"); return false; } /* * Comment Child Reply Form */ var pId = 0; var user_arr = new Array(); var user_arr_index = 0; var total_user = new Array(); var reset_user = false; function setupCommentChildReply(c_parentId, cId_user, lId, status, date, link_url){ var reply_to = ""; var c_user_arr = cId_user.split("-"); var cId = c_user_arr[0]; var username = "@"+c_user_arr[1]; var cForm = $j("#c-child-form-"+c_parentId); if(pId == 0 || pId != c_parentId){ var html="
"+ ""+ ""+ ""+ "
Trả lời"+ ""+ "Ðóng"+ ""+ "
"+ "
"+ "
"+ ""+ ""+ ""+ ""+ "Ðính liên kết"+ "Chèn mã nhúng"+ "
"+ ""+ ""+ ""+ "
" + "
"+ ""+ ""+ ""+ ""+ ""+ ""+ "
"+ "
"+ "
"+ "
"; cForm.html(html); user_arr = null; user_arr = new Array(); total_user = null; total_user = new Array(); user_arr_index = 0; } if(pId != 0 && pId == c_parentId){ //check exist var exist = false; var length = user_arr.length; for(i=0;iXóa"; }else{ reply_to = "
" + username + "Xóa
"; reset_user = false; } user_arr[user_arr_index] = username; total_user[user_arr_index] = cId_user; user_arr_index++; } }else{ reply_to = "
" + username + "Xóa
"; user_arr[user_arr_index] = username; total_user[user_arr_index] = cId_user; user_arr_index++; pId = c_parentId; } var cReplyto = $j("#reply-to"+c_parentId); cReplyto.append(reply_to); cReplyto.show(); var all_user = ""; var length_total = total_user.length; for(j=0;j 0){ user_arr_new = new Array(); total_user_new = new Array(); } for(i=0;iXóa"; }else{ reply_to += "
" + user_arr[i] + "Xóa
"; } } var cReplyto = $j("#reply-to"+c_parentId); //alert(reply_to); cReplyto.html(reply_to); cReplyto.show(); var all_user = ""; var length_total = total_user.length; for(j=0;j"+ "Sửa bình luận"+ ""+ ""+ "Đóng"+ ""+ ""+ ""+ ""+ "
"+ "" + "" + "" + ""+ ""+ "
"+ "
" + "
"+ ""+ ""+ "
"+ "
"+ "
"+ "
"; cForm.html(html); // show it $j(cFooter).hide(); $j(cForm).show(); var cText = $j("#txt_comment_edit_" + cId); cText.focus(); $j("#ajaxLoading").hide(); return false; } function cancelCommentEdit(cId) { $j("input#comment_edit_"+cId).remove(); var cForm = $j("#c" + cId + "-form-edit"); var cFooter = $j("#c" + cId + "-foot"); $j(cForm).slideUp("fast"); $j(cFooter).slideDown("fast"); return false; } function ajaxCommentEdit(cId) { $j("#ajaxLoading").show(); var comment_id = $j("#comment-form-edit" + cId + "> input#comment_id").val(); var query = "id=" + comment_id; var comment = $j("#comment-form-edit" + cId + "> .textarea > textarea").val(); query += "&content=" + encodeURIComponent(comment); $j.post(my_base_url+my_pligg_base+"/ajaxCommentEdit", query, function(result) { ajaxCommentEditCallback(result,cId); } ); return false; } function ajaxCommentEditCallback(result,cId){ if (/ERROR:/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { clearCForm("comment-form-edit"+cId); if (cId !='' && cId != 0) { $j("#c-content-" + cId).html(result); $j("#c"+cId+"-form-edit").hide("fast"); } else { $j("#c-content-" + cId).html(result); } } $j("#ajaxLoading").hide(); return false; } /** * Ajax post comment */ function getCFormData(cId) { var link = $j("#comment-form" + cId + "> input#clink").val(); query = "link=" + link; var parent = $j("#comment-form" + cId + "> input#cparent").val(); query += "&parent=" + parent; var comment = $j("#comment-form" + cId + "> .textarea > textarea").val(); query += "&comment=" + encodeURIComponent(comment); var status = $j("#comment-form" + cId + "> input#cstatus").val(); query += "&status=" + encodeURIComponent(status); var date = $j("#comment-form" + cId + "> input#cdate").val(); query += "&date=" + encodeURIComponent(date); var url = $j("#comment-form" + cId + "> input#curl").val(); query += "&url=" + encodeURIComponent(url); var cmt_type = parseInt($j("input#foreign_type_user").val()); query += "&cmt_type=" + encodeURIComponent(cmt_type); return query; } function getCFormDataChild(cId) { var link = $j("#comment-child-form" + cId + "> input#clink").val(); query = "link=" + link; var parent = $j("#comment-child-form" + cId + "> input#cparent").val(); query += "&parent=" + parent; var comment = $j("#comment-child-form" + cId + "> .textarea > textarea").val(); query += "&comment=" + encodeURIComponent(comment); var status = $j("#comment-child-form" + cId + "> input#cstatus").val(); query += "&status=" + encodeURIComponent(status); var date = $j("#comment-child-form" + cId + "> input#cdate").val(); query += "&date=" + encodeURIComponent(date); var url = $j("#comment-child-form" + cId + "> input#curl").val(); query += "&url=" + encodeURIComponent(url); //for child comment var parent_two = $j("#reply-to" + cId).val(); query += "&parent_two=" + parent_two; var cmt_type = parseInt($j("input#foreign_type_user").val()); query += "&cmt_type=" + encodeURIComponent(cmt_type); return query; } function clearCForm(form) { $j("#"+form + "> .textarea > textarea").val(""); } function ajaxComment(cId) { $j("#ajaxLoading").show(); var query = getCFormData(cId); $j("#loading"+cId).hide(); toggleButton("scomment"+cId); $j.post(my_base_url+my_pligg_base+"/ajaxCommentPost", query, function(result) { ajaxCommentCallback(result,cId); } ); return false; } function ajaxCommentCallback(result,cId) { if (/ERROR:/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { clearCForm("comment-form"+cId); $j("#attachments"+cId).html("");//clear attachments if (cId !='' && cId != 0) { $j("#c-wrap-"+cId+" > .comment-replies-body").append(result); $j("#c"+cId+"-form").hide("fast"); var cFooter = $j("#c" + cId + "-foot"); cFooter.slideDown("fast"); } else { $j("#comments").append(result); } } toggleButton("scomment"+cId); $j("#ajaxLoading").hide(); } function ajaxCommentChild(cId) { $j("#ajaxLoading").show(); var query = getCFormDataChild(cId); $j("#loading"+cId).hide(); toggleButton("scomment"+cId); $j.post(my_base_url+my_pligg_base+"/ajaxCommentPost", query, function(result) { ajaxCommentChildCallback(result,cId); } ); return false; } function ajaxCommentChildCallback(result,cId) { if (/ERROR:/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { clearCForm("comment-child-form"+cId); $j("#attachments"+cId).html("");//clear attachments //clear information user_arr = null; user_arr = new Array(); total_user = null; total_user = new Array(); user_arr_index = 0; reset_user = true; $j("#reply-to"+cId).html(""); if (cId !='' && cId != 0) { $j("#c-wrap-"+cId).append(result); $j("#c-child-form-" + cId).hide("fast"); } else { $j("#comments").append(result); } } toggleButton("scomment"+cId); $j("#ajaxLoading").hide(); } function ajax_set_comment_view_mode(modeId){ $j("#ajaxLoading").show(); var query = "modeId=" + modeId; $j.post(my_base_url+my_pligg_base+"/ajaxCommentSetViewMode", query, function(result) { $j("#set_comment_view_mode").addClass("greenie"); $j("#set_comment_view_mode").html(" Đã thiết lập mặc định"); $j("#ajaxLoading").hide(); } ); return false; } /** * Ajax vote for comment */ function cvote(cId,value) { $j("#ajaxLoading").show(); var query = "id=" + cId + "&value=" + value; $j.post(my_base_url+my_pligg_base+"/ajaxCommentVote", query, function(result) { cvoteCallback(cId,value,result); } ); return false; } function cvoteCallback(cId,value,result) { if (/ERROR:/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { updateCVotes(cId,value,result); disableVoteBtns(cId); if (value < 0) { collapseComment(cId); } } $j("#ajaxLoading").hide(); } function updateCVotes(cId,value,votes) { var cVotes = $j("#c-vote-"+cId); if (votes >= 0) { $j(cVotes).html('+' + votes); } else { $j(cVotes).html(votes); } } function disableVoteBtns(cId){ $j("#c-good-"+cId).html(''); $j("#c-bad-"+cId).html(''); } /** * Comment effects */ function collapseComment(cId) { $j("#c-showlink-"+cId).show(); $j("#c-show-a-"+cId).show(); $j("#c-hide-a-"+cId).hide(); $j("#c-container-"+cId).slideUp('normal'); $j("#c-block-"+cId).addClass("comment-bad"); return false; } function showComment(cId){ $j("#c-container-"+cId).slideDown('normal',finishShow(cId)); return false; } function finishShow(cId){ $j("#c-block-"+cId).removeClass("comment-bad"); if($j("#c-show-a-"+cId).css('display') == 'none'){ $j("#c-show-a-"+cId).show(); $j("#c-hide-a-"+cId).hide(); }else{ $j("#c-show-a-"+cId).hide(); $j("#c-hide-a-"+cId).show(); } return false; } function hideComment(cId){ $j("#c-container-"+cId).slideUp('normal',finishHide(cId)); return false; } function finishHide(cId){ $j("#c-block-"+cId).addClass("comment-bad"); if($j("#c-show-a-"+cId).css('display') == 'none'){ $j("#c-show-a-"+cId).show(); $j("#c-hide-a-"+cId).hide(); }else{ $j("#c-show-a-"+cId).hide(); $j("#c-hide-a-"+cId).show(); } return false; } /* * Report comment function reportCommentAbuse(user, cId, md5, value) { if (window.confirm('Bạn có chắc chắn đây là bình luận xấu không?')) { $j("#ajaxLoading").show(); var query = "id=" + cId + "&user=" + user + "&md5=" + md5 + "&value=" + value; $j.post(my_base_url+my_pligg_base+"/ajaxCommentVote", query, function(result) { reportCommentAbuseCallback(cId); } ); } return false; } function reportCommentAbuseCallback(cId){ disableVoteBtns(cId); $j("#c-report-"+cId).html(''); //$j("#c-report-"+cId).remove(); collapseComment(cId); $j("#ajaxLoading").hide(); } */ /* Get sidebar Links */ function getLinksAuthorMore(rId, orderBy, userId) { $j("#ajaxLoading").show(); var query = "orderBy=" + orderBy + "&userId=" + userId; $j.post(my_base_url+my_pligg_base+"/ajaxLinkAuthorMore", query, function(result) { getLinksAuthorMoreCallback(rId,result); } ); return false; } function getLinksAuthorMoreCallback(rId,result) { $j("#"+rId).html(result); $j("#ajaxLoading").hide(); } function getLinksTopicMore(rId, orderBy, categoryId) { $j("#ajaxLoading").show(); var query = "orderBy=" + orderBy + "&categoryId=" + categoryId; $j.post(my_base_url+my_pligg_base+"/ajaxLinkTopicMore", query, function(result) { getLinksTopicMoreCallback(rId,result); } ); return false; } function getLinksTopicMoreCallback(rId,result) { $j("#"+rId).html(result); $j("#ajaxLoading").hide(); } //Ajax load comment filter function ajax_comment_filter(filter,inputpage){ var page = 0; if(inputpage == null){ //For paging $j("#ajax-getmore-loading").show(); page = parseInt($j("input#comment_page").val()); }else{ //For change tab $j("#ajaxLoading").show(); page = inputpage; } var comment_mark = $j('#comment_mark').val(); var link_id = parseInt($j("input#comment_link_id").val()); var query = "page=" + page + "&link_id=" + link_id + "&filter=" + filter + "&comment_mark=" + comment_mark; $j.post(my_base_url+my_pligg_base+"/ajaxCommentFilter", query, function(result) { eval("var result=" + result); if(inputpage == null){ //For paging $j("#ajax-getmore-loading").hide(); $j("div#comments_more").append(result.comment_more); }else{ //For changetab $j("#ajaxLoading").hide(); $j("#comments").html(result.comment_more); } $j("input#comment_page").val(result.comment_page); $j('#show_comment_from').html(result.comment_from); $j('#show_comment_end').html(result.comment_end); $j('#show_comment_total').html(result.comment_total_lv1); if(result.show_comment_more == 0){ $j('#show_comment_more').hide(); } //Reload thickbox $j('.thickbox').each(function(i) { $j(this).unbind('click'); }); tb_init('a.thickbox, area.thickbox, input.thickbox'); } ); return false; } function ajax_comment_ignore(commentId){ if (window.confirm('Bạn muốn lọc bỏ những bình luận được gửi bởi người này?')) { $j("#ajaxLoading").show(); var query = "id=" + commentId; $j.post(my_base_url+my_pligg_base+"/ajaxCommentIgnoreAuthor", query, function(result) { if (/ERROR/.test(result)) { result = result.substring(7, result.length); window.alert(result); } else { //Show comment filter collapseComment(commentId); } $j("#ajaxLoading").hide(); } ); } return false; }