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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
51 deletions
+76
-51
bg_az-counter.php
bg_az-counter.php
+2
-2
counter.js
js/counter.js
+14
-10
rating.js
js/rating.js
+60
-39
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
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
.
data
));
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
));
}
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,12 +317,14 @@ function fullBatchQuery(socket) {
}
});
// Отправляем данные, как только сокет будет подключен
if
(
socket
.
readyState
==
WebSocket
.
OPEN
)
{
socket
.
send
(
json
);
}
else
{
socket
.
onopen
=
function
()
{
if
(
socket
!==
undefined
)
{
// Отправляем данные, как только сокет будет подключен
if
(
socket
.
readyState
==
WebSocket
.
OPEN
)
{
socket
.
send
(
json
);
}
else
{
socket
.
onopen
=
function
()
{
socket
.
send
(
json
);
}
}
}
}
...
...
js/rating.js
View file @
f0f0a175
...
...
@@ -87,32 +87,35 @@ function getRate(type, id) {
url
:
request
,
type
:
"GET"
,
success
:
function
(
response
){
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
));
if
(
response
.
success
)
{
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
));
}
m
=
response
.
data
.
votes
%
10
;
j
=
response
.
data
.
votes
%
100
;
if
(
m
==
0
||
m
>=
5
||
(
j
>=
10
&&
j
<=
20
))
txt_votes
=
bg_counter
.
votes5
;
else
if
(
m
>=
2
&&
m
<=
4
)
txt_votes
=
bg_counter
.
votes2
;
else
txt_votes
=
bg_counter
.
vote1
;
start_rate_index
=
parseFloat
(
response
.
data
.
score
).
toFixed
(
1
);
jQuery
(
'#bg_counter_votes'
).
html
(
response
.
data
.
votes
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
txt_votes
);
jQuery
(
'#bg_counter_score'
).
html
(
start_rate_index
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
response
.
data
.
votes
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
start_rate_index
);
rating_voted
=
response
.
data
.
alreadyVoted
;
iniRatingState
(
start_rate_index
,
rating_voted
);
}
else
{
jQuery
(
'#bg_counter_votes'
).
html
(
'0'
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
bg_counter
.
votes5
);
jQuery
(
'#bg_counter_score'
).
html
(
'0'
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
0
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
0
);
iniRatingState
(
0
,
false
);
}
m
=
response
.
data
.
votes
%
10
;
j
=
response
.
data
.
votes
%
100
;
if
(
m
==
0
||
m
>=
5
||
(
j
>=
10
&&
j
<=
20
))
txt_votes
=
bg_counter
.
votes5
;
else
if
(
m
>=
2
&&
m
<=
4
)
txt_votes
=
bg_counter
.
votes2
;
else
txt_votes
=
bg_counter
.
vote1
;
start_rate_index
=
parseFloat
(
response
.
data
.
score
).
toFixed
(
1
);
jQuery
(
'#bg_counter_votes'
).
html
(
response
.
data
.
votes
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
txt_votes
);
jQuery
(
'#bg_counter_score'
).
html
(
start_rate_index
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
response
.
data
.
votes
);
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
);
jQuery
(
'#bg_counter_votes'
).
html
(
'0'
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
bg_counter
.
votes5
);
jQuery
(
'#bg_counter_score'
).
html
(
'0'
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
0
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
0
);
iniRatingState
(
0
,
false
);
}
});
}
...
...
@@ -146,25 +149,43 @@ function sendRate(type, id, number) {
jQuery
.
ajax
({
url
:
request
,
type
:
"POST"
,
data
:
'{"rating": '
+
number
+
'}'
,
success
:
function
(
response
){
// Вывод данных на экран
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
));
if
(
response
.
success
)
{
// Вывод данных на экран
if
(
bg_counter
.
debug
)
{
console
.
log
(
'POST REQUEST: '
+
request
+
' result:'
);
console
.
log
(
JSON
.
stringify
(
response
));
}
m
=
response
.
data
.
votes
%
10
;
j
=
response
.
data
.
votes
%
100
;
if
(
m
==
0
||
m
>=
5
||
(
j
>=
10
&&
j
<=
20
))
txt_votes
=
bg_counter
.
votes5
;
else
if
(
m
>=
2
&&
m
<=
4
)
txt_votes
=
bg_counter
.
votes2
;
else
txt_votes
=
bg_counter
.
vote1
;
start_rate_index
=
parseFloat
(
response
.
data
.
score
).
toFixed
(
1
);
jQuery
(
'#bg_counter_votes'
).
html
(
response
.
data
.
votes
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
txt_votes
);
jQuery
(
'#bg_counter_score'
).
html
(
start_rate_index
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
response
.
data
.
votes
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
start_rate_index
);
iniRatingState
(
start_rate_index
,
true
);
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();
}
m
=
response
.
data
.
votes
%
10
;
j
=
response
.
data
.
votes
%
100
;
if
(
m
==
0
||
m
>=
5
||
(
j
>=
10
&&
j
<=
20
))
txt_votes
=
bg_counter
.
votes5
;
else
if
(
m
>=
2
&&
m
<=
4
)
txt_votes
=
bg_counter
.
votes2
;
else
txt_votes
=
bg_counter
.
vote1
;
start_rate_index
=
parseFloat
(
response
.
data
.
score
).
toFixed
(
1
);
jQuery
(
'#bg_counter_votes'
).
html
(
response
.
data
.
votes
);
jQuery
(
'#bg_counter_votes_txt'
).
html
(
txt_votes
);
jQuery
(
'#bg_counter_score'
).
html
(
start_rate_index
);
jQuery
(
'meta[itemprop=ratingCount]'
).
attr
(
"content"
,
response
.
data
.
votes
);
jQuery
(
'meta[itemprop=ratingValue]'
).
attr
(
"content"
,
start_rate_index
);
iniRatingState
(
start_rate_index
,
true
);
getAllRates
();
},
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