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
6c8bfeb2
Commit
6c8bfeb2
authored
Nov 05, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.6.3
Первичная загрузка счетчиков
parent
d0f71b3a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
45 deletions
+29
-45
bg_az-counter.php
bg_az-counter.php
+2
-2
counter.js
js/counter.js
+13
-21
rating.js
js/rating.js
+14
-22
No files found.
bg_az-counter.php
View file @
6c8bfeb2
...
...
@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.6.
2
Version: 2.6.
3
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.6.
2
'
);
define
(
'BG_COUNTER_VERSION'
,
'2.6.
3
'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
...
...
js/counter.js
View file @
6c8bfeb2
...
...
@@ -31,7 +31,10 @@ jQuery( document ).ready(function() {
}
}
else
GetAllCounters
();
bg_counter_elements_reloaded_on_scroll
();
// Обновляет счетчики после прокрутки страницы, если добавлены элементы.
jQuery
(
window
).
on
(
'scroll'
,
function
()
{
GetAllCounters
();
});
/*********************************************************************************
Просомтр счетчиков читающих в реальном времени.
...
...
@@ -190,9 +193,16 @@ GET /counters/project/test/author/1/book/3
**********************************************************************************/
function
GetAllCounters
()
{
var
elem
=
jQuery
(
'span.bg-az-counter'
);
if
(
typeof
elem
==
'undefined'
)
{
return
;
}
if
(
elem
.
length
>
bg_counter_elements
)
{
bg_counter_elements
=
elem
.
length
;
jQuery
(
'span.bg-az-counter'
).
each
(
function
()
{
var
el
=
jQuery
(
this
);
// bg_counter_elements = el.length;
// bg_counter_elements = el.length;
var
type
=
el
.
attr
(
'data-type'
);
var
id
=
el
.
attr
(
'data-ID'
);
var
project
=
el
.
attr
(
'data-project'
);
...
...
@@ -235,6 +245,7 @@ function GetAllCounters() {
}
xhr
.
send
();
});
}
}
/*********************************************************************************
Отображает значения счетчика на странице
...
...
@@ -280,22 +291,3 @@ function bg_counter_number_format (num) {
return
num
;
}
/*********************************************************************************
Обновляет счетчики после прокрутки страницы,
если добавлены элементы.
**********************************************************************************/
function
bg_counter_elements_reloaded_on_scroll
()
{
jQuery
(
window
).
on
(
'scroll'
,
function
()
{
var
elem
=
jQuery
(
'span.bg-az-counter'
);
if
(
typeof
elem
==
'undefined'
)
{
return
;
}
if
(
elem
.
length
>
bg_counter_elements
)
{
bg_counter_elements
=
elem
.
length
;
GetAllCounters
();
// getAllRates();
}
});
}
js/rating.js
View file @
6c8bfeb2
...
...
@@ -6,9 +6,12 @@ var bg_counter_ratings = 0;
jQuery
(
document
).
ready
(
function
()
{
getAllRates
();
// Обновлять рейтинги после прокрутки страницы, если добавлены элементы.
jQuery
(
window
).
on
(
'scroll'
,
function
()
{
getAllRates
();
});
// getAllRates();
bg_counter_ratings_reloaded_on_scroll
();
if
(
!
bg_counter
.
ID
)
return
;
// У объекта нет ID
if
(
jQuery
(
"div"
).
is
(
".bg_counter_rating"
)
==
false
)
return
;
// На странице нет счетчика
...
...
@@ -130,9 +133,16 @@ function getRate(type, id) {
function
getAllRates
()
{
var
elem
=
jQuery
(
'span.bg-az-counter'
);
if
(
typeof
elem
==
'undefined'
)
{
return
;
}
if
(
elem
.
length
>
bg_counter_ratings
)
{
bg_counter_ratings
=
elem
.
length
;
jQuery
(
'span.bg-az-counter'
).
each
(
function
()
{
var
el
=
jQuery
(
this
);
// bg_counter_ratings = el.length;
// bg_counter_ratings = el.length;
var
type
=
el
.
attr
(
'data-type'
);
var
id
=
el
.
attr
(
'data-ID'
);
var
project
=
el
.
attr
(
'data-project'
);
...
...
@@ -164,7 +174,7 @@ function getAllRates() {
}
xhr
.
send
();
});
}
}
...
...
@@ -226,21 +236,3 @@ function sendRate(type, id, number) {
xhr
.
send
(
'{"rating": '
+
number
+
'}'
);
}
/*********************************************************************************
Обновляет рейтинги после прокрутки страницы,
если добавлены элементы.
**********************************************************************************/
function
bg_counter_ratings_reloaded_on_scroll
()
{
jQuery
(
window
).
on
(
'scroll'
,
function
()
{
var
elem
=
jQuery
(
'span.bg-az-counter'
);
if
(
typeof
elem
==
'undefined'
)
{
return
;
}
if
(
elem
.
length
>
bg_counter_ratings
)
{
bg_counter_ratings
=
elem
.
length
;
getAllRates
();
}
});
}
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