// Вспомогательные переменные var using_wp_cache = false; var site_url = "https://www.linkexchanger.su"; var ratings_ajax_url = "/wp-content/plugins/postratings/postratings.php"; var ratings_text_wait = "Спасибо, Ваш голос уже учтен."; var ratings_image = "squares"; var ratings_max = "5"; var ratings_page_hash = ""; var ratings_mouseover_image = new Image();ratings_mouseover_image.src = site_url + "/wp-content/plugins/postratings/images/" + ratings_image + "/rating_over.gif"; //var ratings = new sack(ratings_ajax_url); var post_id = 0; var post_rating = 0; var rate_fadein_opacity = 0; var rate_fadeout_opacity = 100; var ratings_show_loading = 1; var ratings_show_fading = 1; var ratings_custom = 0; var is_ie = (document.all && document.getElementById); var is_moz = (!document.all && document.getElementById); var is_opera = (navigator.userAgent.indexOf("Opera") > -1); var is_being_rated = false; function declension(num){ num = parseInt(num); ret = ""; if (((num%10)>=2 && (num%10)<=4) && (num < 10 || num > 20)) {ret = 'голоса';} else if (((num%10) >= 5 && (num%10) <= 9) || (num%10) == 0 || (num >= 10 && num <= 20)) {ret = 'голосов';} else {ret = 'голос';} return ret; //alert(ret); } // Post Ratings Fade In Text function rade_fadein_text() { if(rate_fadein_opacity < 100) { rate_fadein_opacity += 10; if(is_opera) { rate_fadein_opacity = 100; } else if(is_ie) { if(ratings_show_fading) { document.getElementById('post-ratings-' + post_id).filters.alpha.opacity = rate_fadein_opacity; } else { rate_fadein_opacity = 100; } } else if(is_moz) { if(ratings_show_fading) { document.getElementById('post-ratings-' + post_id).style.MozOpacity = (rate_fadein_opacity/100); } else { rate_fadein_opacity = 100; } } setTimeout("rade_fadein_text()", 100); } else { rate_fadein_opacity = 100; rate_unloading_text(); is_being_rated = false; } } // Функция обработки наведения курсора на очередной пункт рейтинга function current_rating(id, rating, rating_text) { //alert("ratings_" + rating + "_mouseover_image.src"); //ratings_5_mouseover_image.src if(!is_being_rated) { post_id = id; post_rating = rating; if(ratings_custom && ratings_max == 2) { //document.images['rating_' + post_id + '_' + rating].src = eval("ratings_" + rating + "_mouseover_image.src"); } else { for(i = 1; i <= rating; i++) { document.images['rating_' + post_id + '_' + i].src = "/images/on_rating.gif"; } } if(document.getElementById('ratings_' + post_id + '_text')) { document.getElementById('ratings_' + post_id + '_text').style.display = 'inline'; document.getElementById('ratings_' + post_id + '_text').innerHTML = rating_text; } } } // Функция обработки снятия курсора с очередной пункта рейтинга function ratings_off(rating_score, insert_half) { if(!is_being_rated) { for(i = 1; i <= ratings_max; i++) { if(i <= rating_score) { document.images['rating_' + post_id + '_' + i].src = "/images/off_rating.gif"; } else if(i == insert_half) { document.images['rating_' + post_id + '_' + i].src = "/images/off_rating.gif"; } else { document.images['rating_' + post_id + '_' + i].src = "/images/off_rating.gif"; } } if(document.getElementById('ratings_' + post_id + '_text')) { document.getElementById('ratings_' + post_id + '_text').style.display = 'none'; document.getElementById('ratings_' + post_id + '_text').innerHTML = ''; } } } // Функция пост - загрузки текста рейтинга function rate_loading_text() { if(ratings_show_loading) { document.getElementById('post-ratings-' + post_id + '-loading').style.display = 'block'; } } // Post Ratings Finish Loading Text function rate_unloading_text() { if(ratings_show_loading) { document.getElementById('post-ratings-' + post_id + '-loading').style.display = 'none'; } } // Функция фиксации рейтинга пользователя в БД и фиксация его отображения function rate_post(mark,id,flag) { if (flag == 0){ if(id == 0) exit(); $.post('/save_raiting.php', {'mark':mark, 'id_recept':id},onAjax_voite); } if (flag == 1){ if(id == 0) exit(); $.get('/save_eat.php', {'mark':mark, 'id_eat':id},onAjax_voite); } if (flag == 2){ if(id == 0) exit(); $.get('/save_bar.php', {'mark':mark, 'id_place':id},onAjax_voite); } //посылка Ajax-запроса для занесения голоса в БД } //function onAjax_voite(data) //Функция обработки Ajax - запроса: направлена на изменение текущего //рейтинга коктейля, после того, как пользователь проголосует // // @data - данные, пришедшие с сервера // //Возвращаемое значение - нет function onAjax_voite(data) { mdata = data.split('&'); mark_all = parseFloat(mdata[1],1); arr_rait = Array(); arr_rait[0] = ""; arr_rait[1] = "rated_one"; arr_rait[2] = "rated_two"; arr_rait[3] = "rated_three"; arr_rait[4] = "rated_four"; arr_rait[5] = "rated_five"; arr = Array(); arr[1] = "one"; arr[2] = "two"; arr[3] = "three"; arr[4] = "four"; arr[5] = "five"; $(".vote .one").removeClass('rated'); $(".vote .two").removeClass('rated'); $(".vote .three").removeClass('rated'); $(".vote .four").removeClass('rated'); $(".vote .five").removeClass('rated'); $(".vote ."+arr[parseInt(mdata[0])]).addClass('rated'); //alert(parseInt(mdata[0])); $("#rait_word").html('Рейтинг: '+parseInt(mdata[0])+' ('+mdata[2]+' '+declension(mdata[2]) +')'); $(".yourRating").html('
Ваша оценка: '+mark_all+''); } // Process Post Ratings function rate_process() { if(rate_fadeout_opacity > 0) { rate_fadeout_opacity -= 10; if(is_opera) { rate_fadein_opacity = 0; } else if(is_ie) { if(ratings_show_fading) { document.getElementById('post-ratings-' + post_id).filters.alpha.opacity = rate_fadeout_opacity; } else { rate_fadein_opacity = 0; } } else if(is_moz) { if(ratings_show_fading) { document.getElementById('post-ratings-' + post_id).style.MozOpacity = (rate_fadeout_opacity/100); } else { rate_fadein_opacity = 0; } } setTimeout("rate_process()", 100); } else { rate_fadeout_opacity = 0; ratings.reset(); ratings.setVar("pid", post_id); ratings.setVar("rate", post_rating); if(using_wp_cache) { ratings.setVar("page_hash", ratings_page_hash); } ratings.method = 'GET'; ratings.element = 'post-ratings-' + post_id; ratings.onCompletion = rade_fadein_text; ratings.runAJAX(); rate_fadein_opacity = 0; rate_fadeout_opacity = 100; } }