var _page_url = '/ajax.php'; var editEventHandler = { url: '/ajax.php?page=events&action=editEvent', type: 'post', dataType : 'json', success: postEditEvent }; var createEventHandler = { url: '/ajax.php?page=events&action=createEvent', type: 'post', dataType : 'json', success: postEditEvent }; function postEditEvent(reply) { if (reply.result) { $('#savebad').hide(); if (reply.new_pic) { $('#event_pic').removeAttr('height'); $('#event_pic').removeAttr('width'); $('#event_pic').attr('src', reply.new_pic.src); } $('#fileToUpload').clearFields(); showNotification(reply.message); if (reply.event_id) { if (reply.group_id) { location.href = 'group'+reply.group_id; } else { if (reply.view) { location.href = 'event'+reply.event_id + '&view=calend'; } else { location.href = 'event'+reply.event_id; } } } } else { $('#savebad').html(reply.info); $('#savebad').css('display', ''); } }; function showJoinEventDlg(event_id, view) { $.getJSON( '/ajax.php', {page:'dialogs', action:'joinevent', eventId: event_id, view: view}, function(json){ completeDialogBox(json); }); }; function acceptEventInvitation(eventId) { $.post('/ajax.php?page=events&action=acceptInvitation&eventId='+eventId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#htmlGI'+ eventId).hide(); } }); }; function rejectEventInvitation(eventId) { $.post('/ajax.php?page=events&action=rejectInvitation&eventId='+eventId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#htmlGI'+ eventId).hide(); } }); }; function searchEvents(baseurl) { var searchVal = $("#eventSearch").val(); if (searchVal == '') showNotification('Введите информацию для поиска'); else location.href = baseurl+'&search=' + searchVal; return false; }; function saveEventOptions(eventId, view) { var parameters = $('#eventOptionsForm').formSerialize(); $.post(_page_url + '?page=events&action=saveOptions&eventId='+eventId, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { if (view) location.href = 'event' + eventId+'&view=' + view; else location.href = 'event' + eventId; } }); }; function deleteEvent(eventId) { if (!confirm(Q_JS_DELETE_EVENT)) return false; $.post(_page_url + '?page=events&action=deleteEvent&eventId='+eventId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#savebad').hide(); showNotification(N_JS_SAVED); location.href = '/profile/calendar'; } else { $('#savebad').css('display', ''); } }); }; function inviteToEvent() { if ($('#eventInviteName').val() != '') { location.href = 'search&s=1&invev='+$('#eventId').val()+'&lfn='+$('#eventInviteName').val(); } }; function acceptEventMember(userIds, eventId) { $.post(_page_url + '?page=events&action=acceptMember&eventId='+eventId+'&userIds='+userIds, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { moveToMembers(userIds, 0); } }); }; function deleteEventMember(userIds, eventId, fromSection) { $.post(_page_url + '?page=events&action=deleteMember&eventId='+eventId+'&userIds='+userIds, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { removeMember(userIds, fromSection); } }); }; function promoteEventMember(userIds, eventId) { $.post(_page_url + '?page=events&action=promoteMember&eventId='+eventId+'&userIds='+userIds, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { moveToModerators(userIds); } }); }; function demoteEventMember(userIds, eventId) { $.post(_page_url + '?page=events&action=demoteMember&eventId='+eventId+'&userIds='+userIds, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { moveToMembers(userIds, 2); } }); }; function joinEvent(eventId, access, target_type, target_id, view) { $.post(_page_url + '?page=events&action=joinEvent&eventId='+eventId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { if(access == 5) { $('#adev'+eventId).hide(); $('#aaev'+eventId).show(); showNotification(reply.message); } if (access == 0) { /*if (view == 'calend') { location.href = 'event'+eventId+'&view=calend'; } else { location.href = self.location.href; }*/ location.href = self.location.href; } else { $('#modalBox').hide(); $.unblockUI(); showNotification(reply.message); } } }); }; function joinEventGroup(eventId, groupId, accessEvent, accessGroup, target_type, target_id, view) { $.post(_page_url + '?page=events&action=joinEventGroup&eventId='+eventId+'&groupId='+groupId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { if((accessEvent == 5)||(accessGroup == 5)) { $('#adev'+eventId).hide(); $('#aaev'+eventId).show(); showNotification(reply.message); } if ((accessEvent == 0)&&(accessGroup == 0)) { if (view && view == 'calend') { location.href = 'event'+reply.event.event_id + '&view=calend'; } else { location.href = 'event'+reply.event.event_id; } } else { $('#modalBox').hide(); $.unblockUI(); showNotification(reply.message); } } }); }; function joinEventService(eventId, serviceId, accessEvent, accessService, target_type, target_id, view) { $.post(_page_url + '?page=events&action=joinEventService&eventId='+eventId+'&serviceId='+serviceId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { if((accessEvent == 5)||(accessService == 5)) { $('#adev'+eventId).hide(); $('#aaev'+eventId).show(); showNotification(reply.message); } if ((accessEvent == 0)&&(accessService == 0)) { if (view && view == 'calend') { location.href = 'event'+reply.event.event_id + '&view=calend'; } else { location.href = 'event'+reply.event.event_id; } } else { $('#modalBox').hide(); $.unblockUI(); showNotification(reply.message); } } }); }; function leaveEvent(eventId, view) { $.post(_page_url + '?page=events&action=leaveEvent&eventId='+eventId, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { //location.href = '/profile/calendar'; if (view) { location.href = 'event'+eventId+'&view=calend'; } else { //location.href = 'event'+eventId; window.location.reload(); } } }); }; function getEventMembers(page) { eventId = $('#event_id').val(); $.post('/ajax.php?page=events&action=getMembers&eventId='+eventId+'&pg='+page, '', function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#eventMembers').html( reply.info ); } }); }; function editEventPhotos(albumIds) { var parameters = $('#feditPhotos').formSerialize(); $.post('/ajax.php?page=events&action=savePhotos&albumIds='+albumIds, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { location.href = 'editEventPhotos'+albumIds; } }); }; function changeEventCity(value) { if (value == -1) { $('#fevcitysearch').show(); $('#fevcity').hide(); $('#newEventBtn').hide(); } else document.fevcity.submit(); }; function onSelectEventCity(value) { $('#event_city_id').val(value.extra[1]); }; $.fn.outer = function() { return $( $('
').html(this.clone()) ).html(); }; function showCreateGroupEventDlg() { $.getJSON( '/ajax.php', {page:'dialogs', action:'creategroupevent'}, function(json){ completeDialogBox(json); }); }; function showCreateEventDlg() { $.getJSON( '/ajax.php', {page:'dialogs', action:'createevent'}, function(json){ completeDialogBox(json); }); }; function ToCreateEvent() { // создаем событие group_id = $("select#selectedGroup").val(); str = ''; if ($('#to_afisha').attr('checked')) str = '&to_afisha=yes'; if (group_id != '0') { location.href = '/createEvent&gid=' + group_id + str; } else { location.href = '/createEvent'+ str; } }; function CreateGroupEvent() { group_id = $("select#selectedGroup").val(); if (group_id) { location.href = '/createEvent&gid=' + group_id; } else { closeDialog(); showNotification('Группа не выбрана'); } }; function accessAll() { if ($('#to_afisha').attr('checked')) { $("#members").empty(); $("#access").empty(); $("#enable_photo").empty(); $("#enable_wall").empty(); $("