var UBlogs = { addComment: function(id) { $('cAdd'+id).toggle(); }, loadComments: function(id) { var forceReload = false; if(UBlogs.loadComments.arguments.length>1) { forceReload = UBlogs.loadComments.arguments[1]; } if($('commentList'+id).visible()==true && forceReload==false) { $('commentList'+id).hide(); } else { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+'/blogs.php?task=show_details&blog_id='+id+'&act=html')), { method: 'get', onSuccess: function(req){ if(UBlogs.checkForErrors(req.responseText)) { UBlogs.handleErrors(req.responseText); } else { $('commentList'+id).innerHTML = req.responseText; if($$('#commentList'+id+' .cEntry').length>0) { $$('#commentList'+id+' .cAdd form').each(function(el){ el.hide(); }); } $('commentList'+id).show(); } } } ); } }, saveComment: function(id) { new Ajax.Request( addSessionID(ABSOLUTE_URI+'/blogs.php?task=save_comment&blog_id='+id+'&act=html'), { method: 'post', parameters: $('cAddForm'+id).serialize(true), onSuccess: function(req){ if(parseInt(req.responseText)==1) { $('cAdd'+id).hide(); Page.formReactivate('cAddForm'+id); $('cAddComment'+id).value = ''; if($('commentList'+id).visible()==true) { setTimeout(function(){ UBlogs.loadComments(id, true); }, 4000); } Page.successMessage({ 'title': Language['UBlogs_Comment_Saved_Title'], 'text': Language['UBlogs_Comment_Saved_Text'], 'links': Language['UBlogs_Comment_Saved_Links'] }); } else { UBlogs.handleErrors(req.responseText); } } } ); }, confirmComment: function(blogID, commentID, index) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+'/blogs.php?task=confirm_comment&blog_id='+blogID+'&comment_id='+commentID+'&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { $$('#pE'+index+' .more .controls .confirm').each(function(el){ el.remove(); }); $$('#pE'+index+' .blogComment .notConfirmed').each(function(el){ el.remove(); }); } else { UBlogs.handleErrors(req.responseText); } } } ); }, deleteComment: function(blogID, commentID, index) { new Ajax.Request( addVTok(addSessionID(ABSOLUTE_URI+'/blogs.php?task=delete_comment&blog_id='+blogID+'&comment_id='+commentID+'&act=html')), { method: 'get', onSuccess: function(req){ if(parseInt(req.responseText)==1) { $('pE'+index).remove(); } else { UBlogs.handleErrors(req.responseText); } } } ); }, checkForErrors: function(type) { if(Page.checkForErrors(type)) { return true; } else if(type=='100' || type=='101' || type=='102' || type=='110' || type=='113') { return true; } else { return false; } }, handleErrors: function(type) { if(type=='100') { Page.errorMessage({ 'title': Language['UBlogs_Entry_Not_Found_Title'], 'text': Language['UBlogs_Entry_Not_Found_Text'], 'links': Language['UBlogs_Entry_Not_Found_Links'] }); } else if(type=='101') { Page.errorMessage({ 'title': Language['UBlogs_Entry_Too_Personal_Title'], 'text': Language['UBlogs_Entry_Too_Personal_Text'], 'links': Language['UBlogs_Entry_Too_Personal_Links'] }); } else if(type=='102') { Page.errorMessage({ 'title': Language['UBlogs_Entry_Not_Published_Title'], 'text': Language['UBlogs_Entry_Not_Published_Text'], 'links': Language['UBlogs_Entry_Not_Published_Links'] }); } else if(type=='103') { Page.errorMessage({ 'title': Language['UBlogs_Access_Blocked_Title'], 'text': Language['UBlogs_Access_Blocked_Text'], 'links': Language['UBlogs_Access_Blocked_Links'] }); } else if(type=='104') { Page.errorMessage({ 'title': Language['UBlogs_Access_Blocking_Title'], 'text': Language['UBlogs_Access_Blocking_Text'], 'links': Language['UBlogs_Access_Blocking_Links'] }); } else if(type=='105') { Page.errorMessage({ 'title': Language['IMSG_Ignore_Foreign_Error_Title'], 'text': Language['IMSG_Ignore_Foreign_Error_Text'], 'links': Language['IMSG_Ignore_Foreign_Error_Links'] }); } else if(type=='106') { Page.errorMessage({ 'title': Language['IMSG_Ignore_Own_Error_Title'], 'text': Language['IMSG_Ignore_Own_Error_Text'], 'links': Language['IMSG_Ignore_Own_Error_Links'] }); } else if(type=='110') { Page.errorMessage({ 'title': Language['UBlogs_No_Comments_Allowed_Title'], 'text': Language['UBlogs_No_Comments_Allowed_Text'], 'links': Language['UBlogs_No_Comments_Allowed_Links'] }); } else if(type=='112') { Page.errorMessage({ 'title': Language['UBlogs_Comment_Not_Found_Title'], 'text': Language['UBlogs_Comment_Not_Found_Text'], 'links': Language['UBlogs_Comment_Not_Found_Links'] }); } else if(type=='113') { Page.errorMessage({ 'title': Language['UBlogs_Comment_No_Text_Title'], 'text': Language['UBlogs_Comment_No_Text_Text'], 'links': Language['UBlogs_Comment_No_Text_Links'] }); } else { Page.handleErrors(type); } } };
