Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bg-az-counter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
azbyka_bg
bg-az-counter
Commits
f0f0a175
Commit
f0f0a175
authored
Nov 11, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.7.2
Были нарушены 2 принципа: "Лучшее - враг хорошего", "Не трожь, если работает" - исправил
parent
abed3e03
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
bg_az-counter.php
bg_az-counter.php
+2
-2
counter.js
js/counter.js
+4
-0
rating.js
js/rating.js
+25
-4
No files found.
bg_az-counter.php
View file @
f0f0a175
...
...
@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.7.
1
Version: 2.7.
2
Author: VBog
Author URI: https://bogaiskov.ru
License: GPL2
...
...
@@ -38,7 +38,7 @@
if
(
!
defined
(
'ABSPATH'
)
)
{
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_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
...
...
js/counter.js
View file @
f0f0a175
...
...
@@ -139,12 +139,14 @@ function SendOnce(type, id) {
url
:
request
,
type
:
"POST"
,
success
:
function
(
response
){
if
(
response
.
success
)
{
// Здесь надо будет добавить вывод данных на экран
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
.
data
));
}
setViewCount
(
type
,
id
,
bg_counter_number_format
(
response
.
data
.
value
),
addDelimiter
(
response
.
data
.
now
+
1
));
}
},
error
:
function
(
xhr
)
{
if
(
bg_counter
.
debug
)
console
.
warn
(
'POST REQUEST: '
+
request
+
' ERROR '
+
xhr
.
status
+
': '
+
xhr
.
statusText
);
...
...
@@ -315,6 +317,7 @@ function fullBatchQuery(socket) {
}
});
if
(
socket
!==
undefined
)
{
// Отправляем данные, как только сокет будет подключен
if
(
socket
.
readyState
==
WebSocket
.
OPEN
)
{
socket
.
send
(
json
);
...
...
@@ -325,5 +328,6 @@ function fullBatchQuery(socket) {
}
}
}
}
return
true
;
}
js/rating.js
View file @
f0f0a175
...
...
@@ -87,6 +87,7 @@ function getRate(type, id) {
url
:
request
,
type
:
"GET"
,
success
:
function
(
response
){
if
(
response
.
success
)
{
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
));
...
...
@@ -104,9 +105,7 @@ function getRate(type, id) {
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
start_rate_index
);
rating_voted
=
response
.
data
.
alreadyVoted
;
iniRatingState
(
start_rate_index
,
rating_voted
);
},
error
:
function
(
xhr
)
{
if
(
bg_counter
.
debug
)
console
.
warn
(
'POST REQUEST: '
+
request
+
' ERROR '
+
xhr
.
status
+
': '
+
xhr
.
statusText
);
}
else
{
jQuery
(
'#bg_counter_votes'
).
html
(
'0'
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
bg_counter
.
votes5
);
jQuery
(
'#bg_counter_score'
).
html
(
'0'
);
...
...
@@ -114,6 +113,10 @@ function getRate(type, id) {
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
0
);
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) {
jQuery
.
ajax
({
url
:
request
,
type
:
"POST"
,
data
:
'{"rating": '
+
number
+
'}'
,
success
:
function
(
response
){
if
(
response
.
success
)
{
// Вывод данных на экран
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
...
...
@@ -164,7 +169,23 @@ function sendRate(type, id, number) {
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
response
.
data
.
votes
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
start_rate_index
);
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
)
{
if
(
bg_counter
.
debug
)
console
.
warn
(
'POST REQUEST: '
+
request
+
' ERROR '
+
xhr
.
status
+
': '
+
xhr
.
statusText
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment