function saveEntry() { var text = $('textarea[id=content]').val(); if ($('#title').val() =='') { alert(N_JS_ENTER_TITLE); return; } if (text.replace(/<\/?[^>]+(>|$)/g, "") == '') { alert(N_JS_ENTER_TEXT); return; } document.entryform.submit(); }; 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(entryId, target, itemtype, groupId) { 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=blogs&action=vote&entryId='+entryId+'&optionId='+optionId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { if (itemtype == 'project_news') { location.href = '/profile/project_news&id='+entryId; } else if (itemtype == 'groupblog' && groupId) { location.href = '/groupBlog' + entryId+'&gid='+groupId; } else { if (itemtype == 'stuffmain') { location.href = '/' + target+ '/blogs/entry/' + entryId; } else { location.href = '/' + target+ '/blog_post' + entryId; } } } }); } }; function showVoteResults(poll_id) { $('#voteResults'+poll_id).show(); $('#voteQuestion'+poll_id).hide(); }; function showVoteQuestion(poll_id) { $('#voteQuestion'+poll_id).show(); $('#voteResults'+poll_id).hide(); }; function checkPoll() { var badoptions = false; var badquestion = false; if ($('#question').val() == '') { badquestion = true; } $('#votelist input').each(function(el){ if ($(this).val() == '') { badoptions = true; } }); if (badquestion) alert(N_JS_ENTER_QUESTION); else if (badoptions) alert(N_JS_ENTER_ALL_ANSWERS); else document.entryform.submit(); }; function removeFromBest(entryId) { $('#mem'+entryId).hide(); $.post('/ua/ajax.php?page=blogs&action=removeFromBest&entryId='+entryId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#entryItem'+entryId).fadeOut(300); showNotification(reply.message); } }); }; function addToBest(entryId) { $('#mem'+entryId).hide(); $.post('/ua/ajax.php?page=blogs&action=addToBest&entryId='+entryId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { showNotification(reply.message); } }); }; function getDialogEditBlog (entryId) { $.getJSON( '/ua/ajax.php', {page:'dialogs', action:'getEditBlog', entryId: entryId}, function(json){ completeDialogBox(json); }); }; function EditBlogEntry (entryId) { if (!entryId) { closeDialog(); showNotification('Группа не выбрана'); return; } if ($('#title').val() =='') { showNotification(N_JS_ENTER_TITLE); return; } if ($('textarea[id=text_content]').val() =='') { showNotification(N_JS_ENTER_TEXT); return; } var multipleValues = $("#select_blogs").val() || []; res = multipleValues.join(","); var multipleValues = $("#select_groups").val() || []; res_groups = multipleValues.join(","); $.post( '/ua/ajax.php', {page:'blogs', action:'editBlogEntry', entry_id: entryId, title: $('#title').val(), content: $('textarea[id=text_content]').val(), tags: $('#tags').val(), pvc_visibility: $("select#select_pvc_visibility").val(), pvc_comment: $("select#select_pvc_comment").val(), blogs: res, groups: res_groups}, function(response){ eval( "var reply = "+response+";"); if (reply.result) { closeDialog(); showNotification(reply.message); location.href = self.location.href; } else { closeDialog(); showNotification('Ошибка сохранения'); } }); }; function DeleteBlogEntry (entryId) { if (! entryId) { closeDialog(); alert('Группа не выбрана'); return; } $.post('/ua/ajax.php?page=blogs&action=deleteBlogEntry&entryId='+entryId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { closeDialog(); showNotification(reply.message); location.href = self.location.href; } else { closeDialog(); showNotification('Ошибка при удалении'); } }); }; function showUserGrops(element) { var tmp_value=element.value; if (tmp_value == '3') { $("#selectBlogs").slideDown("slow"); //all_blogs $("#pvc_comment").empty(); $("#to_mypage").slideDown("slow"); $("