Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Miroslav Kratochvil
jekyll-theme-lcsb-default
Commits
fa4cdef9
Verified
Commit
fa4cdef9
authored
Apr 09, 2020
by
Laurent Heirendt
✈
Browse files
POC
parent
434d98ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
_includes/css-imports.html
View file @
fa4cdef9
...
...
@@ -113,12 +113,32 @@
<script>
/* Piwik global variable */
var
_paq
=
_paq
||
[];
var
_paq
=
window
.
_paq
||
_paq
||
[];
var
settings
=
[];
settings
.
expires
=
180
;
settings
.
matomoURL
=
"
https://analytics.lcsb.uni.lu/hub/
"
;
settings
.
siteID
=
4
;
function
getCookie
(
cname
)
{
var
name
=
cname
+
"
=
"
;
var
decodedCookie
=
decodeURIComponent
(
document
.
cookie
);
var
ca
=
decodedCookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
ca
.
length
;
i
++
)
{
var
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
'
'
)
{
c
=
c
.
substring
(
1
);
}
if
(
c
.
indexOf
(
name
)
==
0
)
{
return
c
.
substring
(
name
.
length
,
c
.
length
);
}
}
return
""
;
}
function
loadPiwik
()
{
var
u
=
settings
.
edp_cookies_popup
.
piwik
URL
;
_paq
.
push
([
'
setSiteId
'
,
settings
.
edp_cookies_popup
.
siteID
]);
_paq
.
push
([
'
setTrackerUrl
'
,
u
+
'
piwik
.php
'
]);
var
u
=
settings
.
matomo
URL
;
_paq
.
push
([
'
setSiteId
'
,
settings
.
siteID
]);
_paq
.
push
([
'
setTrackerUrl
'
,
u
+
'
matomo
.php
'
]);
_paq
.
push
([
'
setDoNotTrack
'
,
1
]);
_paq
.
push
([
'
trackPageView
'
]);
_paq
.
push
([
'
setIgnoreClasses
'
,
[
'
no-tracking
'
,
'
colorbox
'
]]);
...
...
@@ -127,7 +147,7 @@ function loadPiwik() {
g
.
type
=
'
text/javascript
'
;
g
.
defer
=
true
;
g
.
async
=
true
;
g
.
src
=
u
+
'
piwik
.js
'
;
g
.
src
=
u
+
'
matomo
.js
'
;
s
.
parentNode
.
insertBefore
(
g
,
s
);
}
function
showEdpCookieBanner
()
{
...
...
@@ -136,6 +156,11 @@ function showEdpCookieBanner() {
popup
.
slideDown
(
'
slow
'
);
console
.
log
(
'
popped the banner
'
);
}
function
hideEdpCookieBanner
()
{
var
popup
=
jQuery
(
'
#edp-cookies-banner
'
);
popup
.
hide
();
console
.
log
(
'
removed the banner
'
);
}
function
clearPiwik
()
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
in
cookies
)
{
...
...
@@ -144,19 +169,24 @@ function clearPiwik() {
Cookies
.
set
(
name
,
0
,
{
expires
:
-
1
,
path
:
'
/
'
});
}
}
console
.
log
(
'
cleared all cookies
'
);
}
$
(
document
).
ready
(
function
()
{
hideEdpCookieBanner
();
/* accept */
$
(
'
.edp-cookies-accept
'
).
click
(
function
(
e
)
{
e
.
preventDefault
(
true
);
console
.
log
(
'
clicked on accept
'
);
Cookies
.
set
(
'
edp_cookie_agree
'
,
1
,
{
expires
:
parseInt
(
200
),
path
:
'
/
'
});
jQuery
(
'
#edp-cookies-banner
'
).
slideUp
(
'
slow
'
);
Cookies
.
set
(
'
edp_cookie_agree
'
,
1
,
{
expires
:
parseInt
(
settings
.
expires
),
path
:
'
/
'
});
hideEdpCookieBanner
();
//jQuery('#edp-cookies-banner').slideUp('slow');
jQuery
(
'
.edp-cookies-accept
'
).
addClass
(
'
disabled
'
);
jQuery
(
'
.edp-cookies-refuse
'
).
removeClass
(
'
disabled
'
);
jQuery
(
this
).
blur
();
//
loadPiwik();
loadPiwik
();
});
/* refuse */
...
...
@@ -164,8 +194,9 @@ $( document ).ready(function() {
e
.
preventDefault
(
true
);
console
.
log
(
'
clicked on refuse
'
);
clearPiwik
();
Cookies
.
set
(
'
edp_cookie_agree
'
,
0
,
{
expires
:
parseInt
(
200
),
path
:
'
/
'
});
jQuery
(
'
#edp-cookies-banner
'
).
slideUp
(
'
slow
'
);
Cookies
.
set
(
'
edp_cookie_agree
'
,
0
,
{
expires
:
parseInt
(
settings
.
expires
),
path
:
'
/
'
});
hideEdpCookieBanner
();
//jQuery('#edp-cookies-banner').slideUp('slow');
jQuery
(
'
.edp-cookies-refuse
'
).
addClass
(
'
disabled
'
);
jQuery
(
'
.edp-cookies-accept
'
).
removeClass
(
'
disabled
'
);
jQuery
(
this
).
blur
();
...
...
@@ -180,9 +211,9 @@ $( document ).ready(function() {
jQuery
(
'
.edp-cookies-dnt-inactive
'
).
hide
();
// Hide no DNT message.
jQuery
(
'
.edp-cookies-accept, .edp-cookies-refuse
'
).
addClass
(
'
disabled
'
);
}
}
else
{
}
jQuery
(
'
.edp-cookies-dnt-active
'
).
hide
();
// Hide DNT message.
var
edpCookieAgree
=
Cookie
s
.
set
(
'
edp_cookie_agree
'
,
{
path
:
'
/
'
}
);
edpCookieAgree
=
get
Cookie
(
'
edp_cookie_agree
'
);
console
.
log
(
edpCookieAgree
);
if
(
edpCookieAgree
==
'
0
'
)
{
/* Visitor refused our cookies => remove piwik trace if present */
...
...
@@ -196,9 +227,10 @@ $( document ).ready(function() {
}
else
{
/* Visitor did not choose yet */
//var edpCookieAgree = Cookies.set('edp_cookie_agree', {path: '/'}); // do not set cookie
showEdpCookieBanner
();
}
}
}
});
</script>
...
...
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