﻿function addComment(){
    var comment = getDOM('txtQuickComment');
    if(comment.value.trim().length == 0)
    {
        alert("Bạn hãy nhập lời nhắn của bạn!");
        comment.focus();
        return false;    
    } 
    getDOM('btnQuickComment').disabled = true;
    quickCommentController.AddComment(comment.value.trim().capitalize());  
}   

function showAllQuickComments()
{
    var obj = new Object();     
    obj.UserName = getUserName();
    var html = '<div id="divQuickCommentContent"></div><div id="divQuickCommentsPaging"></div>';
    getDOM('divrender').innerHTML = html;    
    System.Environment.ObjectManager.clear();
    var pagingController = new PagingController({
       id: "list_all_quick_comments",
       pageId: 'divQuickCommentsPaging',
       contentId: 'divQuickCommentContent',
       pageSize: '20',//Number of items par page
       numberPage: '3',//Number of Page display
       urlGetCountRequest: ajaxRequestURL("quickcomment", "GetCountOfUser"),//Url to get count
       urlGetData: ajaxRequestURL("quickcomment", "GetAllOfUserByRange"),//Url get data for paging
       params: obj,
       beforeUpdate: function(list){
        if(list != null){
            var isDelete = (Globals.IsAuthorised || Globals.IsAdmin);
            $(list).each(function(i, item){
                item.isDelete = isDelete;
            });
        }
       },
       afterUpdate: function(){
            $("a[name='btnDeleteCommentOfQuickCommentOnAll']").click(function(){
                var id = $(this).attr("rel");
                quickCommentController.DeleteComment(id);
                showAllQuickComments();
                return false;
            });
       },
       tpl: templateQuickComment.GetAllOfUser
    });
}