/******************************************************************************* * FORUM ******************************************************************************/ function checkThreadMessage() { var text = $('textarea.jTagEditor-editor').val(); if ($('#title').val() == '') { alert(N_JS_ENTER_SUBJECT); return false; } if (text.replace(/<\/?[^>]+(>|$)/g, "") == '') { alert(N_JS_ENTER_TEXT); return false; } if ($('#voting').attr('checked')) { if ($('#question').val() == '') { alert(N_JS_ENTER_QUESTION); return false; } var badoptions = false; $('#votelist input').each(function(el){ if ($(this).val() == '') { alert(N_JS_ENTER_ALL_ANSWERS); badoptions = true; return false; } }); if (badoptions) return false; } return true; } function saveThread(target, threadId, mode, targetId) { if (!checkThreadMessage()) return; $('#createBtn').hide(); if (mode == 'edit') { var request_url = '/ua/ajax.php?page=forum&action=editthread&thread_id='+threadId+'&target='+target+'&tid='+targetId; } else { var request_url = '/ua/ajax.php?page=forum&action=createThread'+'&target='+target+'&tid='+targetId; } var parameters = $('#createThreadForm').formSerialize(); $.post(request_url, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#savebad').hide(); //location.href = target + 'Thread'+reply.thread_id; location.href = target + targetId; } else { $('#createBtn').show(); $('#error').html(reply.message); $('#error').show(); } }); }; function addTargetComment(target, threadId) { $('#error').hide(); var comment = $('.jTagEditor-editor').val(); if (comment.replace(/<\/?[^>]+(>|$)/g, "") == '') { alert(N_JS_ENTER_TEXT); return; } var parameters = $('#fForumComment').formSerialize(); $('#replyBtn').hide(); $.post('/ua/ajax.php?page=forum&action=addComment&threadId='+threadId+'&target='+target, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#error').hide(); $('#forumComments').html( $('#forumComments').html() + reply.info); $('#comment'+reply.groupCommentId).fadeIn(1000); $('.jTagEditor-editor').val(''); $('#replyBtn').show(); } else { $('#error').html(json.message); $('#error').show(); } }); return; }; function deleteGroupComment(target, targetId, threadId, commentId) { if (!confirm(Q_JS_DELETE_COMMENT)) return false; $.post('/ua/ajax.php?page=forum&action=deleteComment&commentId='+commentId+'&threadId='+threadId+'&target='+target, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { if (reply.thread) { location.href = target + targetId; } else $('#comment' + commentId).fadeOut(200); } }); return; }; function replyThread(target) { $('#groupCommentPost').show(); location.href = '#groupCommentPost'; $('#content').focus(); }; function showEditComment(target, commentId) { $('#content'+commentId).hide(); $('#eddiv'+commentId).show(); $.post('/ua/ajax.php?page=forum&action=getCommentText&commentId='+commentId+'&target='+target, $('#edContent'+commentId).fieldSerialize(), function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#edContent'+commentId).val(reply.info); } }); }; function cancelEditComment(commentId) { $('#eddiv'+commentId).hide(); $('#content'+commentId).show(); }; function editComment(target, commentId) { $.post('/ua/ajax.php?page=forum&action=editComment&commentId='+commentId+'&target='+target, $('#edContent'+commentId).fieldSerialize(), function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#content'+commentId).html(reply.info); } }); cancelEditComment(commentId); }; function quoteMessage(target, commentId) { var selectedText = quoteSelection(); if (selectedText == '') { $.post('/ua/ajax.php?page=forum&action=getCommentText&commentId='+commentId+'&target='+target, $('#edContent'+commentId).fieldSerialize(), function(response) { eval( "var reply = "+response+";"); if (reply.result) { selectedText = reply.info; selectedText = '