function saveOpinion (city_id,cityUrl,criterianUrl,isReload) { if (checkEmptyFields()){ var parameters = $('#formOpinion').formSerialize(); $.post('/ajax.php?page=opinions&action=saveOpinion&city_id='+city_id, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#savebad').hide(); showNotification(OK_OPINION_MODERATE); var htab = $('#htab').val(); var curl = $('#crit_url').val(); if (htab!='') htab = '&'+htab; if (curl!='') curl = '&'+curl; if (isReload) window.location.reload(); else location.href = '/profile/travel_opinions/geoid'+reply.encoded_id+htab+curl; } else { $('#savebad').css('display', ''); } }); } }; function saveObjectOpinion(objectId) { if (checkEmptyFields()){ var parameters = $('#formOpinion').formSerialize(); $.post('/ajax.php?page=opinions&action=saveObjectOpinion&objectId='+objectId, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#savebad').hide(); showNotification(N_JS_SAVED); $('#addcomment'+objectId).hide(); $('#addedcomment'+objectId).show(); } else { $('#savebad').css('display', ''); } }); } } function save_single_opinion (comment_id) { if (checkEmptyFields()){ var parameters = $('#formOpinion').formSerialize(); $.post('/ajax.php?page=opinions&action=save_comment&comment_id='+comment_id, parameters, function(response) { if (response){ var reply = json_decode(response); if (reply.result) { showNotification(N_JS_SAVED); close_edit_forms(); //update_text_conts(reply); window.location.reload(); } else showWarning('Ошибка!
Комментарий не сохранен!'); } else showWarning('Ошибка!
Комментарий не сохранен!'); }); } }; function save_comment_opinion (comment_id, objectId) { $.post('/ajax.php?page=opinions&action=save_owner_comment&comment_id='+comment_id, {comment: $('#commentBody').val(), objectId: objectId}, function(response) { if (response){ var reply = json_decode(response); if (reply.result) { showNotification(N_JS_SAVED); close_edit_forms(); window.location.reload(); } else showWarning('Ошибка!
Комментарий не сохранен!'); } else showWarning('Ошибка!
Комментарий не сохранен!'); }); }; function update_comment_opinion (comment_id, objectId) { $.post('/ajax.php?page=opinions&action=update_owner_comment&comment_id='+comment_id, {comment: $('#commentBody').val()}, function(response) { if (response){ var reply = json_decode(response); if (reply.result) { showNotification(N_JS_SAVED); close_edit_forms(); window.location.reload(); } else showWarning('Ошибка!
Комментарий не сохранен!'); } else showWarning('Ошибка!
Комментарий не сохранен!'); }); }; function delete_comment_opinion (comment_id) { $.post('/ajax.php?page=opinions&action=delete_owner_comment&comment_id='+comment_id, function(response) { if (response){ var reply = json_decode(response); if (reply.result) { showNotification(N_JS_DELETED); close_edit_forms(); window.location.reload(); } else showWarning('Ошибка!
Комментарий не удалён!'); } else showWarning('Ошибка!
Комментарий не удалён!'); }); }; function saveCountryOpinion (countryIds, countryUrl, criterionUrl) { var parameters = $('#formOpinion').formSerialize(); $.post('/ajax.php?page=opinions&action=saveCountryOpinions&country_ids='+countryIds, parameters, function(response) { eval( "var reply = "+response+";"); if (reply.result) { $('#savebad').hide(); showNotification(N_JS_SAVED); var htab = $('#htab').val(); var curl = $('#crit_url').val(); if (htab!='') htab = '&'+htab; if (curl!='') curl = '&'+curl; location.href = '/profile/travel_opinions/country'+reply.encoded_id+htab+curl; } else { $('#savebad').css('display', ''); } }); } function checkEmptyFields() { result = false; var message = ''; $('textarea[name^=answer]').each(function(item){ if ($(this).val() != '') result = true; }); if (result == true) { if ((document.getElementById("selectType").value == 0) && (document.getElementById("selectMonth").value == 0) && (document.getElementById("selectYear").value == 0)) { message = "Введите как и когда Вы отдыхали!"; result = false; } else if ((document.getElementById("selectType").value == 0) && (document.getElementById("selectMonth").value == 0)) { message = "Введите как и в каком месяце Вы отдыхали"; result = false; } else if ((document.getElementById("selectType").value == 0) && (document.getElementById("selectYear").value == 0)) { message = "Введите как и в каком году Вы отдыхали"; result = false; } else if ((document.getElementById("selectMonth").value == 0) && (document.getElementById("selectYear").value == 0)) { message = "Введите месяц и год, в котором Вы отдыхали"; result = false; } else if (document.getElementById("selectMonth").value == 0) { message = "Введите месяц, в котором Вы отдыхали"; result = false; } else if (document.getElementById("selectYear").value == 0) { message = "Введите год, в котором Вы отдыхали"; result = false; } else if (document.getElementById("selectType").value == 0) { message = "Введите как Вы отдыхали"; result = false; } else if ((document.getElementById("selectType").value == 0) || (document.getElementById("selectMonth").value == 0) || (document.getElementById("selectYear").value == 0)) { result = false; } else if (document.getElementById("selectTitle") && ((document.getElementById("selectTitle").value == 0) || (document.getElementById("selectTitle").value == ''))) { message = "Введите заголовок отзыва"; result = false; } else if ($('input[name*=scale]').size()) { $('input[name*=scale]').each(function(item){ if($(this).val() == '0'){ message = "Вы не поставили свою оценку (количество звезд)"; result = false; } }); } else{ $('textarea[name^=answer]').each(function(item){ if($(this).val() != '' && $(this).val().length<100){ message = "Длинна комментария не менее 100 символов"; result = false; } }); } } else message = 'Оставьте хоть один комментарий!'; if (!result) showWarning(message); return result; } function show_image_dialog_travel (comment_id,index_no) { $.getJSON( '/ajax.php', {page: 'dialogs', action:'uploadimage', type: 'image_opinion'}, function(json){ temp_comment_id = $('#temp_comment_id').val(); var uploadImageHandler = {url: '/ajax.php?page=opinions&action=upload_image&index_no='+index_no+ '&comment_id='+comment_id+'&tci='+temp_comment_id, type: 'post', dataType: 'json', success: uploadImageComplete}; completeDialogBox(json); $('#uploadImage').ajaxForm(uploadImageHandler); }); } function show_image_dialog_travel_all(comment_id,index_no,criterion_id){ $.getJSON( '/ajax.php', {page: 'dialogs', action:'uploadimage', type: 'image_opinion'}, function(json){ temp_comment_id = $('#temp_comment_id').val(); var uploadImageHandler = {url: '/ajax.php?page=opinions&action=upload_image&index_no='+index_no+ '&comment_id='+comment_id+'&tci='+temp_comment_id+'&criterion_id='+criterion_id, type: 'post', dataType: 'json', success: uploadImageCompleteAll}; completeDialogBox(json); $('#uploadImage').ajaxForm(uploadImageHandler); }); } function delete_image_travel_all(photo_id) { $.getJSON( '/ajax.php', {page :'opinions', action :'delete_image', photo_id: photo_id}, function(json){ json = eval(json); if (json.result){ del_image_complete_all(json); } }); } function delete_image (photo_id) { $.getJSON( '/ajax.php', {page :'opinions', action :'delete_image', photo_id: photo_id}, function(json){ json = eval(json); if (json.result){ del_image_complete(json); } }); } function uploadImageComplete(json) { if (json=eval(json)){ $('#pic_'+json.comment_id+'_'+json.index_no).attr('src',json.surl); $('#pic_a_'+json.comment_id+'_'+json.index_no).attr('onclick','delete_image('+json.image_id+');'); $('#pic_a_'+json.comment_id+'_'+json.index_no).removeClass().addClass('img_del'); if (json.temp_comment_id>0) $('#temp_comment_id').val(json.temp_comment_id); } closeDialog(); } function uploadImageCompleteAll(json) { if (json=eval(json)){ $('#pic_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).attr('src',json.surl); $('#pic_a_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).attr('onclick','delete_image('+json.image_id+');'); $('#pic_a_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).removeClass().addClass('img_del'); if (json.temp_comment_id>0) $('#temp_comment_id').val(json.temp_comment_id); } closeDialog(); } function del_image_complete_all(json){ $('#pic_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).attr('src',''); $('#pic_a_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).attr('onclick','show_image_dialog_travel_all('+json.comment_id+','+json.index_no+','+json.criterion_id+');'); $('#pic_a_'+json.comment_id+'_'+json.index_no+'_'+json.criterion_id).removeClass().addClass('img_add'); } function del_image_complete(json){ $('#pic_'+json.comment_id+'_'+json.index_no).attr('src',''); $('#pic_a_'+json.comment_id+'_'+json.index_no).attr('onclick','show_image_dialog_travel('+json.comment_id+','+json.index_no+');'); $('#pic_a_'+json.comment_id+'_'+json.index_no).removeClass().addClass('img_add'); } function showEditForm(comment_id,encoded_id) { if ($('#edtfrm'+comment_id).is(':hidden')){ showAjaxLoading(); $.post('/ajax.php?page=opinions&action=get_comment_form&comment_id='+comment_id, {countryid:encoded_id}, function(reply) { reply = eval('reply ='+reply); if (reply.result) { close_edit_forms(); $('#opblock'+reply.comment_id).hide(); $('#edtfrm'+reply.comment_id).html(reply.content); $('#edtfrm'+reply.comment_id).show(); hideAjaxLoading(); } }); } else{ close_edit_forms(); $('#opblock'+comment_id).show(); } }; function cancelEditComment(comment_id,kind) { $('#eddiv'+comment_id+'_'+kind).hide(); $('#content'+comment_id+'_'+kind).show(); }; function close_edit_forms () { $('div[id^=edtfrm]').each(function(item){ $(this).hide(); }); $('div[id^=opblock]').each(function(item){ $(this).show(); }); } function showCommentForm(comment_id, objectId) { if ($('#cmtfrm'+comment_id).is(':hidden')){ showAjaxLoading(); $.post('/ajax.php?page=opinions&action=get_owner_comment_form&comment_id='+comment_id, {objectId: objectId}, function(reply) { reply = eval('reply ='+reply); if (reply.result) { close_edit_forms(); $('#cmtfrm'+reply.comment_id).html(reply.content); $('#cmtfrm'+reply.comment_id).show(); hideAjaxLoading(); } }); } else{ close_comment_forms(); } }; function close_comment_forms () { $('div[id^=cmtfrm]').each(function(item){ $(this).hide(); }); } function close_comment_edit_forms () { $('div[id^=ocmtfrm]').each(function(item){ $(this).hide(); }); } function showEditOwnerCommentForm(owner_comment_id){ if ($('#ocmtfrm'+owner_comment_id).is(':hidden')){ showAjaxLoading(); $.post('/ajax.php?page=opinions&action=get_owner_edit_comment_form&comment_id='+owner_comment_id, function(reply) { reply = eval('reply ='+reply); if (reply.result) { close_edit_forms(); $('#ocmtfrm'+reply.comment_id).html(reply.content); $('#ocmtfrm'+reply.comment_id).show(); hideAjaxLoading(); } }); } else{ close_comment_edit_forms(); } }; function update_text_conts(json){ if (json!=null){ var rest_extra = ''; if (json.from_country_name!=''){ rest_extra = ', из '+json.from_country_name; } $('#opblock'+json.comment_id+' #div_rest'+json.comment_id).html(''+json.rest_month+' '+json.rest_year+', '+json.rest_type+rest_extra+''); $('div#content'+json.comment_id+'_1').html(json.bodyPositive); $('div#content'+json.comment_id+'_0').html(json.bodyNegative); for (var i=0 ;inum; i--){ document.getElementById(scaleId+'_'+i).src = "/images/opinions/star-off.gif"; } return true; }; function hideStar(scaleId, num) { var inputTag = document.getElementById("star_"+scaleId); //if(inputTag.hasAttribute("value")) getStar(scaleId, parseInt(inputTag.value)); return true; }; function getStar(scaleId, num) { for(var i=1; inum; i--){ document.getElementById(scaleId+'_'+i).src = "/images/opinions/star-off.gif"; } var inputTag = document.getElementById("star_"+scaleId); //if(inputTag.hasAttribute("value")) inputTag.value = num; return true; };