Commit f0f0a175 authored by Vadim's avatar Vadim

Version 2.7.2

Были нарушены 2 принципа: "Лучшее - враг хорошего", "Не трожь, если работает" - исправил
parent abed3e03
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.7.1 Version: 2.7.2
Author: VBog Author: VBog
Author URI: https://bogaiskov.ru Author URI: https://bogaiskov.ru
License: GPL2 License: GPL2
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
if ( !defined('ABSPATH') ) { if ( !defined('ABSPATH') ) {
die( 'Sorry, you are not allowed to access this page directly.' ); die( 'Sorry, you are not allowed to access this page directly.' );
} }
define('BG_COUNTER_VERSION', '2.7.1'); define('BG_COUNTER_VERSION', '2.7.2');
define('BG_COUNTER_LOG', dirname(__FILE__ ).'/bg_counter.log'); define('BG_COUNTER_LOG', dirname(__FILE__ ).'/bg_counter.log');
define('BG_COUNTER_STAT_COUNTERS','https://stat.azbyka.ru/counters'); define('BG_COUNTER_STAT_COUNTERS','https://stat.azbyka.ru/counters');
......
...@@ -139,12 +139,14 @@ function SendOnce(type, id) { ...@@ -139,12 +139,14 @@ function SendOnce(type, id) {
url: request, url: request,
type: "POST", type: "POST",
success: function(response){ success: function(response){
if (response.success) {
// Здесь надо будет добавить вывод данных на экран // Здесь надо будет добавить вывод данных на экран
if (bg_counter.debug) { if (bg_counter.debug) {
console.log('POST REQUEST: '+request+' result:'); console.log('POST REQUEST: '+request+' result:');
console.log(JSON.stringify(response.data)); console.log(JSON.stringify(response.data));
} }
setViewCount (type, id, bg_counter_number_format(response.data.value), addDelimiter(response.data.now+1)); setViewCount (type, id, bg_counter_number_format(response.data.value), addDelimiter(response.data.now+1));
}
}, },
error: function(xhr) { error: function(xhr) {
if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText); if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText);
...@@ -315,6 +317,7 @@ function fullBatchQuery(socket) { ...@@ -315,6 +317,7 @@ function fullBatchQuery(socket) {
} }
}); });
if (socket !== undefined) {
// Отправляем данные, как только сокет будет подключен // Отправляем данные, как только сокет будет подключен
if (socket.readyState == WebSocket.OPEN) { if (socket.readyState == WebSocket.OPEN) {
socket.send(json); socket.send(json);
...@@ -325,5 +328,6 @@ function fullBatchQuery(socket) { ...@@ -325,5 +328,6 @@ function fullBatchQuery(socket) {
} }
} }
} }
}
return true; return true;
} }
...@@ -87,6 +87,7 @@ function getRate(type, id) { ...@@ -87,6 +87,7 @@ function getRate(type, id) {
url: request, url: request,
type: "GET", type: "GET",
success: function(response){ success: function(response){
if (response.success) {
if (bg_counter.debug) { if (bg_counter.debug) {
console.log('POST REQUEST: '+request+' result:'); console.log('POST REQUEST: '+request+' result:');
console.log(JSON.stringify(response)); console.log(JSON.stringify(response));
...@@ -104,9 +105,7 @@ function getRate(type, id) { ...@@ -104,9 +105,7 @@ function getRate(type, id) {
jQuery('meta[itemprop=ratingValue]').attr("content", start_rate_index); jQuery('meta[itemprop=ratingValue]').attr("content", start_rate_index);
rating_voted = response.data.alreadyVoted; rating_voted = response.data.alreadyVoted;
iniRatingState(start_rate_index, rating_voted); iniRatingState(start_rate_index, rating_voted);
}, } else {
error: function(xhr) {
if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText);
jQuery('#bg_counter_votes').html('0'); jQuery('#bg_counter_votes').html('0');
jQuery('#bg_counter_votes_txt').html(bg_counter.votes5); jQuery('#bg_counter_votes_txt').html(bg_counter.votes5);
jQuery('#bg_counter_score').html('0'); jQuery('#bg_counter_score').html('0');
...@@ -114,6 +113,10 @@ function getRate(type, id) { ...@@ -114,6 +113,10 @@ function getRate(type, id) {
jQuery('meta[itemprop=ratingValue]').attr("content", 0); jQuery('meta[itemprop=ratingValue]').attr("content", 0);
iniRatingState(0, false); iniRatingState(0, false);
} }
},
error: function(xhr) {
if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText);
}
}); });
} }
/********************************************************************************* /*********************************************************************************
...@@ -146,7 +149,9 @@ function sendRate(type, id, number) { ...@@ -146,7 +149,9 @@ function sendRate(type, id, number) {
jQuery.ajax ({ jQuery.ajax ({
url: request, url: request,
type: "POST", type: "POST",
data: '{"rating": '+number+'}',
success: function(response){ success: function(response){
if (response.success) {
// Вывод данных на экран // Вывод данных на экран
if (bg_counter.debug) { if (bg_counter.debug) {
console.log('POST REQUEST: '+request+' result:'); console.log('POST REQUEST: '+request+' result:');
...@@ -164,7 +169,23 @@ function sendRate(type, id, number) { ...@@ -164,7 +169,23 @@ function sendRate(type, id, number) {
jQuery('meta[itemprop=ratingCount]').attr("content", response.data.votes); jQuery('meta[itemprop=ratingCount]').attr("content", response.data.votes);
jQuery('meta[itemprop=ratingValue]').attr("content", start_rate_index); jQuery('meta[itemprop=ratingValue]').attr("content", start_rate_index);
iniRatingState(start_rate_index, true); iniRatingState(start_rate_index, true);
getAllRates();
jQuery('span.bg-az-counter').each (function () {
var el = jQuery(this);
var type = el.attr('data-type');
var id = el.attr('data-ID');
var project = el.attr('data-project');
if (project == "") path = "/"; // Формируем путь
else {
if (project == undefined) project = bg_counter.project;
else project = '/project/'+project;
if (!type || !id) var path = project;
else var path = project+"/"+type+"/"+id;
}
if (request == bg_counter.rateurl+path) el.find('span.bg-az-counter-score').text(parseFloat(response.data.score).toFixed(1));
});
// fullBatchQuery();
}
}, },
error: function(xhr) { error: function(xhr) {
if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText); if (bg_counter.debug) console.warn('POST REQUEST: '+request+' ERROR '+xhr.status+': '+xhr.statusText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment