/******************************************************************************* * 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 = '
' + selectedText + '
' + "\n\n"; $('.jTagEditor-editor').val($('.jTagEditor-editor').val() + selectedText); $('.jTagEditor-editor').focus(); } }); } else { selectedText = '
' + selectedText + '
' + "\n\n"; $('.jTagEditor-editor').val($('.jTagEditor-editor').val() + selectedText); $('.jTagEditor-editor').focus(); } }; function quoteSelection() { if (document.selection) { theSelection = document.selection.createRange().text; return theSelection; }else { theSelection1 = window.getSelection(); return theSelection1; } return ''; }; /******************************************************************************* * FORUM POLLS ******************************************************************************/ function addVoteOption() { var voteCounter = $('#voteCounter').val(); if (voteCounter == 20) { return; } var elem = $('#voteItem').clone(); var elemA = $('a', elem); elemA.attr('href', 'javascript:removeVoteOption('+voteCounter+');'); elem.attr('id', 'voteItem'+voteCounter); elem.css('display', ''); $('#votelist').append(elem); $('#voteCounter').val(parseInt(voteCounter)+1); }; function removeVoteOption(id) { $('#voteItem'+id).remove(); }; /* function vote(target, threadId) { var optionId = 0; $('input:radio[@name=voteoption]').each(function(el){ if ($(this).attr('checked')) { optionId = $(this).val(); } }); if (optionId > 0) { $.post('/ua/ajax.php?page=forum&action=vote&threadId='+threadId+'&optionId='+optionId+'&target='+target, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { location.href = target+'Thread' + threadId; } }); } };*/ function showVoteResults() { $('#voteResults').show(); $('#voteQuestion').hide(); }; function showVoteQuestion() { $('#voteQuestion').show(); $('#voteResults').hide(); }; /******************************************************************************* * VISITS ******************************************************************************/ function setTargetRead(target, targetId) { $.post('/ua/ajax.php?page=forum&action=setTargetRead&tid='+targetId+'&target='+target, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { window.location.reload(); } }); }; function setTargetsRead(target) { $.post('/ua/ajax.php?page=forum&action=setTargetsRead'+'&target='+target, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { window.location.reload(); } }); };