j1-template 2021.1.13 → 2021.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/themes/j1/adapter/js/cookieConsent.js +4 -5
- data/assets/themes/j1/adapter/js/j1.js +66 -36
- data/assets/themes/j1/adapter/js/navigator.js +7 -0
- data/assets/themes/j1/adapter/js/themer.js +8 -6
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +2 -288
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +60 -41
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +75 -57
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +10 -9
- data/lib/starter_web/_data/modules/defaults/themer.yml +2 -0
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/assets/images/modules/attics/matthew-dockery-1920x1280.jpg +0 -0
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/learn/quickstart.adoc +473 -0
- data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +5 -5
- data/lib/starter_web/pages/public/legal/en/400_comment_policy.adoc +31 -15
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a61d65c241fc1b44dd4a784051991dbaec031f03627fd44d2071e72417a9b77
|
4
|
+
data.tar.gz: 1183eb75312c578769e06b377d5a1d65d8b458fa49d5fb92fd580795d14eea69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90a12b81819c1f04faf679fd8fe944fc28cf6750e7b60ab21b5f9eff697d54ad4d6a1387e576b8c968c845a1d2ef79fd095b14b8e110d5467ec72957f0bbded5
|
7
|
+
data.tar.gz: 3098d620a9bb16025e033f62379d166694976acdfe38ce0c8eb8952d6f40655da4f377c93238f747c24bf8ccc7cd5440fd1657064cddccdf0a5070e6ff9947d1
|
@@ -263,11 +263,10 @@ j1.adapter['cookieConsent'] = (function (j1, window) {
|
|
263
263
|
// logger.warn('\n' + 'tracking enabled, tracking id found: ' + tracking_id);
|
264
264
|
// }
|
265
265
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
}
|
266
|
+
logger.debug('\n' + 'j1 cookies found:' + j1Cookies.length);
|
267
|
+
j1Cookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
268
|
+
logger.debug('\n' + 'ga cookies found:' + gaCookies.length);
|
269
|
+
gaCookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
271
270
|
|
272
271
|
if (user_agent.includes('iPad')) {
|
273
272
|
logger.warn('\n' + 'product detected : ' + platform.product);
|
@@ -212,9 +212,8 @@ var j1 = (function () {
|
|
212
212
|
};
|
213
213
|
var user_state = {
|
214
214
|
'writer': 'j1.adapter',
|
215
|
-
'theme_css': '',
|
216
|
-
'theme_css': '',
|
217
215
|
'theme_name': '',
|
216
|
+
'theme_css': '',
|
218
217
|
'theme_author': '',
|
219
218
|
'theme_version': '{{template_version}}',
|
220
219
|
'session_active': false,
|
@@ -260,6 +259,8 @@ var j1 = (function () {
|
|
260
259
|
var date = new Date();
|
261
260
|
var timestamp_now = date.toISOString();
|
262
261
|
var curr_state = 'started';
|
262
|
+
var gaCookies = j1.findCookie('_ga');
|
263
|
+
var j1Cookies = j1.findCookie('j1');
|
263
264
|
|
264
265
|
// -----------------------------------------------------------------------
|
265
266
|
// options loader
|
@@ -300,26 +301,31 @@ var j1 = (function () {
|
|
300
301
|
user_state.last_session_ts = timestamp_now;
|
301
302
|
|
302
303
|
if (!user_consent.analyses || !user_consent.personalization) {
|
303
|
-
//
|
304
|
+
// rewrite consent|state cookies to session
|
305
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_consent);
|
304
306
|
cookie_written = j1.writeCookie({
|
305
307
|
name: cookie_names.user_consent,
|
306
308
|
data: user_consent,
|
307
309
|
samesite: 'Strict',
|
308
|
-
secure: secure
|
310
|
+
secure: secure,
|
311
|
+
expires: 0
|
309
312
|
});
|
310
313
|
if (!cookie_written) {
|
311
314
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_consent);
|
312
315
|
}
|
316
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
313
317
|
cookie_written = j1.writeCookie({
|
314
318
|
name: cookie_names.user_state,
|
315
319
|
data: user_state,
|
316
320
|
samesite: 'Strict',
|
317
|
-
secure: secure
|
321
|
+
secure: secure,
|
322
|
+
expires: 0
|
318
323
|
});
|
319
324
|
if (!cookie_written) {
|
320
325
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_consent);
|
321
326
|
}
|
322
327
|
} else {
|
328
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
323
329
|
cookie_written = j1.writeCookie({
|
324
330
|
name: cookie_names.user_state,
|
325
331
|
data: user_state,
|
@@ -332,9 +338,8 @@ var j1 = (function () {
|
|
332
338
|
}
|
333
339
|
}
|
334
340
|
} else {
|
335
|
-
// jadams, 2021-07-11: on beforeunload, a
|
336
|
-
|
337
|
-
logger.fatal('\n' + 'missing cookie detected: ' + cookie_names.user_state);
|
341
|
+
// jadams, 2021-07-11: on beforeunload, a user state cookie is expected
|
342
|
+
logger.error('\n' + 'missing cookie detected: ' + cookie_names.user_state);
|
338
343
|
}
|
339
344
|
}); // END beforeunload
|
340
345
|
|
@@ -351,7 +356,8 @@ var j1 = (function () {
|
|
351
356
|
name: cookie_names.user_session,
|
352
357
|
data: user_session,
|
353
358
|
samesite: 'Strict',
|
354
|
-
secure: secure
|
359
|
+
secure: secure,
|
360
|
+
expires: 0
|
355
361
|
});
|
356
362
|
if (!cookie_written) {
|
357
363
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
@@ -376,22 +382,29 @@ var j1 = (function () {
|
|
376
382
|
// for what reason.
|
377
383
|
if (!user_state) {
|
378
384
|
logger.error('\n' + 'cookie not found: ' + cookie_names.user_state);
|
385
|
+
logger.debug('\n' + 'j1 cookies found:' + j1Cookies.length);
|
386
|
+
j1Cookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
387
|
+
logger.debug('\n' + 'ga cookies found:' + gaCookies.length);
|
388
|
+
gaCookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
379
389
|
user_state = j1.readCookie(cookie_names.user_state);
|
380
390
|
user_state.session_active = true;
|
381
391
|
}
|
382
392
|
|
383
393
|
if (!user_consent.analyses || !user_consent.personalization) {
|
384
|
-
//
|
394
|
+
// rewrite consent|state cookies to session
|
395
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
385
396
|
cookie_written = j1.writeCookie({
|
386
397
|
name: cookie_names.user_state,
|
387
398
|
data: user_state,
|
388
399
|
samesite: 'Strict',
|
389
|
-
secure: secure
|
400
|
+
secure: secure,
|
401
|
+
expires: 0
|
390
402
|
});
|
391
403
|
if (!cookie_written) {
|
392
404
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
393
405
|
}
|
394
406
|
} else {
|
407
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
395
408
|
cookie_written = j1.writeCookie({
|
396
409
|
name: cookie_names.user_state,
|
397
410
|
data: user_state,
|
@@ -428,11 +441,13 @@ var j1 = (function () {
|
|
428
441
|
|
429
442
|
logger.info(logText);
|
430
443
|
logger.info('\n' + 'update user session cookie');
|
444
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
431
445
|
cookie_written = j1.writeCookie({
|
432
446
|
name: cookie_names.user_session,
|
433
447
|
data: user_session,
|
434
448
|
samesite: 'Strict',
|
435
|
-
secure: secure
|
449
|
+
secure: secure,
|
450
|
+
expires: 0
|
436
451
|
});
|
437
452
|
|
438
453
|
if (!cookie_written) {
|
@@ -475,11 +490,13 @@ var j1 = (function () {
|
|
475
490
|
logText = '\n' + 'mode detected: ' + user_session.mode;
|
476
491
|
|
477
492
|
logger.info(logText);
|
493
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
478
494
|
cookie_written = j1.writeCookie({
|
479
495
|
name: cookie_names.user_session,
|
480
496
|
data: user_session,
|
481
497
|
samesite: 'Strict',
|
482
|
-
secure: secure
|
498
|
+
secure: secure,
|
499
|
+
expires: 0
|
483
500
|
});
|
484
501
|
if (!cookie_written) {
|
485
502
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
@@ -535,11 +552,13 @@ var j1 = (function () {
|
|
535
552
|
}
|
536
553
|
|
537
554
|
logger.info('\n' + 'update user session cookie');
|
555
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
538
556
|
cookie_written = j1.writeCookie({
|
539
557
|
name: cookie_names.user_session,
|
540
558
|
data: user_session,
|
541
559
|
samesite: 'Strict',
|
542
|
-
secure: secure
|
560
|
+
secure: secure,
|
561
|
+
expires: 0
|
543
562
|
});
|
544
563
|
|
545
564
|
if (!cookie_written) {
|
@@ -557,11 +576,13 @@ var j1 = (function () {
|
|
557
576
|
// logger.info(logText);
|
558
577
|
|
559
578
|
user_session.timestamp = timestamp_now;
|
579
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
560
580
|
cookie_written = j1.writeCookie({
|
561
581
|
name: cookie_names.user_session,
|
562
582
|
data: user_session,
|
563
583
|
samesite: 'Strict',
|
564
|
-
secure: secure
|
584
|
+
secure: secure,
|
585
|
+
expires: 0
|
565
586
|
});
|
566
587
|
if (!cookie_written) {
|
567
588
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
@@ -906,11 +927,13 @@ var j1 = (function () {
|
|
906
927
|
user_session = j1.mergeData(user_session, data);
|
907
928
|
|
908
929
|
user_session.current_page = current_url.pathname;
|
930
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
909
931
|
cookie_written = j1.writeCookie({
|
910
932
|
name: cookie_names.user_session,
|
911
933
|
data: user_session,
|
912
934
|
samesite: 'Strict',
|
913
|
-
secure: secure
|
935
|
+
secure: secure,
|
936
|
+
expires: 0
|
914
937
|
});
|
915
938
|
if (!cookie_written) {
|
916
939
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
@@ -1122,11 +1145,13 @@ var j1 = (function () {
|
|
1122
1145
|
$('#quickLinksSignInOutButton').css('display', 'none');
|
1123
1146
|
|
1124
1147
|
user_session.current_page = current_url.pathname;
|
1148
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
1125
1149
|
cookie_written = j1.writeCookie({
|
1126
1150
|
name: cookie_names.user_session,
|
1127
1151
|
data: user_session,
|
1128
1152
|
samesite: 'Strict',
|
1129
|
-
secure: secure
|
1153
|
+
secure: secure,
|
1154
|
+
expires: 0
|
1130
1155
|
});
|
1131
1156
|
if (!cookie_written) {
|
1132
1157
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
@@ -1501,6 +1526,14 @@ var j1 = (function () {
|
|
1501
1526
|
// https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Set-Cookie/SameSite
|
1502
1527
|
// https://www.smarketer.de/blog/chrome-update-80-cookies/
|
1503
1528
|
// -------------------------------------------------------------------------
|
1529
|
+
// SESSION Cookies:
|
1530
|
+
// NOT putting an EXPIRES part in will create a session cookie.
|
1531
|
+
// -------------------------------------------------------------------------
|
1532
|
+
// REMOVING Cookies: Cookies get removed immediately, if the expires
|
1533
|
+
// part points to a PAST date (e.g. 01 Jan 1970 00:00:00 UTC).
|
1534
|
+
// -------------------------------------------------------------------------
|
1535
|
+
// MAX-AGE Cookies: To leave cookies for a specific time, set the expires
|
1536
|
+
// part into a FUTUTE date. FOR GDPR compliance, MAX-AGE is 365 days.
|
1504
1537
|
// TODO:
|
1505
1538
|
// Change attribute "Secure" to true, if HTTPS is used.
|
1506
1539
|
// Checks and config changes are to be done.
|
@@ -1517,25 +1550,27 @@ var j1 = (function () {
|
|
1517
1550
|
// must now also specify the Secure attribute (they require a secure
|
1518
1551
|
// context/HTTPS).
|
1519
1552
|
// -------------------------------------------------------------------------
|
1520
|
-
writeCookie: function (options /*name, data, [path, expires, samesite, http_only, secure]*/) {
|
1553
|
+
writeCookie: function (options /*name, data, [path, expires, domain, samesite, http_only, secure]*/) {
|
1554
|
+
var date = new Date();
|
1555
|
+
var timestamp_now = date.toISOString();
|
1556
|
+
var cookie_data = {};
|
1557
|
+
var data_json;
|
1558
|
+
var data_encoded;
|
1559
|
+
var expires;
|
1560
|
+
var stringifiedAttributes = '';
|
1561
|
+
|
1521
1562
|
var defaults = {
|
1522
1563
|
data: {},
|
1523
1564
|
name: '',
|
1524
1565
|
path: '/',
|
1525
1566
|
expires: 0,
|
1567
|
+
domain: 'localhost',
|
1526
1568
|
samesite: 'Strict',
|
1527
1569
|
http_only: false,
|
1528
1570
|
secure: false
|
1529
1571
|
};
|
1530
|
-
var settings = $.extend(defaults, options);
|
1531
1572
|
|
1532
|
-
var
|
1533
|
-
var timestamp_now = date.toISOString();
|
1534
|
-
var cookie_data = {};
|
1535
|
-
var data_json;
|
1536
|
-
var data_encoded;
|
1537
|
-
var expires;
|
1538
|
-
var stringifiedAttributes = '';
|
1573
|
+
var settings = $.extend(defaults, options);
|
1539
1574
|
|
1540
1575
|
cookie_data.timestamp = timestamp_now;
|
1541
1576
|
|
@@ -1550,26 +1585,21 @@ var j1 = (function () {
|
|
1550
1585
|
data_encoded = window.btoa(data_json);
|
1551
1586
|
}
|
1552
1587
|
|
1553
|
-
|
1554
|
-
stringifiedAttributes += '; ' + 'path=' + settings.path;
|
1555
|
-
// }
|
1588
|
+
stringifiedAttributes += '; ' + 'path=' + settings.path;
|
1556
1589
|
|
1557
1590
|
if (settings.expires > 0) {
|
1558
|
-
|
1559
|
-
stringifiedAttributes += '; ' + 'expires=' +
|
1591
|
+
date.setTime(date.getTime() + (settings.expires * 24 * 60 * 60 * 1000));
|
1592
|
+
stringifiedAttributes += '; ' + 'expires=' + date.toUTCString();
|
1560
1593
|
}
|
1561
1594
|
|
1562
|
-
|
1563
|
-
stringifiedAttributes += '; ' + 'SameSite=' + settings.samesite;
|
1564
|
-
// }
|
1595
|
+
stringifiedAttributes += '; ' + 'SameSite=' + settings.samesite;
|
1565
1596
|
|
1566
|
-
// stringify cookie attributes
|
1567
1597
|
if (settings.secure) {
|
1568
1598
|
stringifiedAttributes += '; ' + 'secure=' + settings.secure;
|
1569
|
-
// document.cookie = settings.name + '=' + content +'; path=' + settings.path + '; ' + 'SameSite=' + settings.samesite + '; secure';
|
1570
1599
|
}
|
1571
1600
|
|
1572
1601
|
// write the cookie
|
1602
|
+
// document.cookie = settings.name + '=' + content + '; path=' + settings.path + '; domain=' + settings.domain + '; ' + 'SameSite=' + settings.samesite + '; secure';
|
1573
1603
|
document.cookie = settings.name + '=' + data_encoded + stringifiedAttributes;
|
1574
1604
|
|
1575
1605
|
if (j1.existsCookie(settings.name)) {
|
@@ -249,6 +249,9 @@ j1.adapter['navigator'] = (function (j1, window) {
|
|
249
249
|
var themes_count;
|
250
250
|
var max_count = 100;
|
251
251
|
|
252
|
+
var gaCookies = j1.findCookie('_ga');
|
253
|
+
var j1Cookies = j1.findCookie('j1');
|
254
|
+
|
252
255
|
navDefaults = $.extend({}, {{navigator_defaults | replace: '=>', ':' }});
|
253
256
|
navBarConfig = $.extend({}, {{nav_bar_options | replace: '=>', ':' }});
|
254
257
|
navMenuConfig = $.extend({}, {{nav_menu_options | replace: '=>', ':' }});
|
@@ -346,6 +349,10 @@ j1.adapter['navigator'] = (function (j1, window) {
|
|
346
349
|
user_state = j1.readCookie(cookie_user_state_name);
|
347
350
|
} else {
|
348
351
|
logger.error('\n' + 'cookie not found: j1.user.state');
|
352
|
+
logger.debug('\n' + 'j1 cookies found:' + j1Cookies.length);
|
353
|
+
j1Cookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
354
|
+
logger.debug('\n' + 'ga cookies found:' + gaCookies.length);
|
355
|
+
gaCookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
349
356
|
}
|
350
357
|
|
351
358
|
// jadams, 2021-07-03: wait until navigator CORE get finished
|
@@ -218,16 +218,19 @@ j1.adapter['themer'] = (function (j1, window) {
|
|
218
218
|
// jadams, 2021-07-11: unclear why the cookie consent is checked here
|
219
219
|
if (!user_consent.analyses || !user_consent.personalization) {
|
220
220
|
// expire state cookie to session
|
221
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
221
222
|
cookie_written = j1.writeCookie({
|
222
223
|
name: cookie_names.user_state,
|
223
224
|
data: user_state,
|
224
225
|
samesite: 'Strict',
|
225
|
-
secure: secure
|
226
|
+
secure: secure,
|
227
|
+
expires: 0
|
226
228
|
});
|
227
229
|
if (!cookie_written) {
|
228
230
|
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
229
231
|
}
|
230
232
|
} else {
|
233
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
231
234
|
cookie_written = j1.writeCookie({
|
232
235
|
name: cookie_names.user_state,
|
233
236
|
data: user_state,
|
@@ -286,11 +289,10 @@ j1.adapter['themer'] = (function (j1, window) {
|
|
286
289
|
logger.error('\n' + 'check failed after: ' + max_count * 25 + ' ms');
|
287
290
|
logger.error('\n' + 'loading cookie failed: ' + cookie_names.user_state);
|
288
291
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
}
|
292
|
+
logger.debug('\n' + 'j1 cookies found:' + j1Cookies.length);
|
293
|
+
j1Cookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
294
|
+
logger.debug('\n' + 'ga cookies found:' + gaCookies.length);
|
295
|
+
gaCookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
294
296
|
|
295
297
|
// jadams, 2021-07-15: redirect to homepage
|
296
298
|
// NOTE: UNCLEAR why it is needed to create the user state
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
# -----------------------------------------------------------------------------
|
3
|
-
# ~/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js
|
3
|
+
# ~/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js
|
4
4
|
# Provides JS Core for J1 Module BS Cookie Consent
|
5
5
|
#
|
6
6
|
# Product/Info:
|
@@ -24,290 +24,4 @@
|
|
24
24
|
# outside of J1 Template!
|
25
25
|
# -----------------------------------------------------------------------------
|
26
26
|
*/
|
27
|
-
'
|
28
|
-
|
29
|
-
// -----------------------------------------------------------------------------
|
30
|
-
// ESLint shimming
|
31
|
-
// -----------------------------------------------------------------------------
|
32
|
-
/* eslint indent: "off" */
|
33
|
-
/* eslint no-unused-vars: "off" */
|
34
|
-
/* eslint no-undef: "off" */
|
35
|
-
/* eslint no-redeclare: "off" */
|
36
|
-
/* eslint indent: "off" */
|
37
|
-
/* eslint JSUnfilteredForInLoop: "off" */
|
38
|
-
// -----------------------------------------------------------------------------
|
39
|
-
|
40
|
-
function BootstrapCookieConsent(props) {
|
41
|
-
var logger = log4javascript.getLogger('j1.core.bsCookieConsent');
|
42
|
-
var modalId = 'bccs-modal';
|
43
|
-
var self = this;
|
44
|
-
var detailedSettingsShown = false;
|
45
|
-
var url = new liteURL(window.location.href);
|
46
|
-
var secure = (url.protocol.includes('https')) ? true : false;
|
47
|
-
var logText;
|
48
|
-
var current_page;
|
49
|
-
var whitelisted;
|
50
|
-
|
51
|
-
logger.info('\n' + 'initializing core module: started');
|
52
|
-
logger.info('\n' + 'state: started');
|
53
|
-
|
54
|
-
this.props = {
|
55
|
-
autoShowDialog: true, // disable autoShowModal on the privacy policy and legal notice pages, to make these pages readable
|
56
|
-
language: navigator.language, // the language, in which the modal is shown
|
57
|
-
languages: ["en", "de"], // supported languages (in ./content/), defaults to first in array
|
58
|
-
contentURL: "./content", // this URL must contain the dialogs content in the needed languages
|
59
|
-
cookieName: "cookie-consent-settings", // the name of the cookie in which the configuration is stored as JSON
|
60
|
-
cookieStorageDays: 365, // the duration the cookie configuration is stored on the client
|
61
|
-
postSelectionCallback: undefined, // callback function, called after the user has made his selection
|
62
|
-
whitelisted: [], // pages NO consent modal page is issued
|
63
|
-
xhr_data_element: "", // container for the language-specific consent modal taken from /assets/data/cookieconsent.html
|
64
|
-
sameSite: "Strict", // restrict consent cookie to first-party, do NOT send cookie to other domains
|
65
|
-
secure: false //
|
66
|
-
}
|
67
|
-
|
68
|
-
for (var property in props) {
|
69
|
-
this.props[property] = props[property];
|
70
|
-
}
|
71
|
-
|
72
|
-
this.language = this.props.language
|
73
|
-
if (this.language.indexOf("-") !== -1) {
|
74
|
-
this.language = this.language.split("-")[0];
|
75
|
-
}
|
76
|
-
|
77
|
-
if (!this.props.languages.includes(this.language)) {
|
78
|
-
this.language = this.props.languages[0]; // fallback on default language
|
79
|
-
}
|
80
|
-
|
81
|
-
var Cookie = {
|
82
|
-
set: function (name, value, days, samesite, secure) {
|
83
|
-
var value_encoded = window.btoa(value);
|
84
|
-
var expires = "";
|
85
|
-
if (days) {
|
86
|
-
var date = new Date();
|
87
|
-
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
88
|
-
expires = "; expires=" + date.toUTCString();
|
89
|
-
}
|
90
|
-
if (secure) {
|
91
|
-
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + samesite + '; ' + 'secure=' + secure + ';';
|
92
|
-
} else {
|
93
|
-
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + samesite + ';';
|
94
|
-
}
|
95
|
-
},
|
96
|
-
get: function (name) {
|
97
|
-
var nameEQ = name + "=";
|
98
|
-
var ca = document.cookie.split(';');
|
99
|
-
for (var i = 0; i < ca.length; i++) {
|
100
|
-
var c = ca[i];
|
101
|
-
while (c.charAt(0) === ' ') {
|
102
|
-
c = c.substring(1, c.length);
|
103
|
-
}
|
104
|
-
if (c.indexOf(nameEQ) === 0) {
|
105
|
-
var value_encoded = c.substring(nameEQ.length, c.length);
|
106
|
-
var value = window.atob(value_encoded);
|
107
|
-
return value;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
return undefined
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
var Events = {
|
115
|
-
documentReady: function (onDocumentReady) {
|
116
|
-
if (document.readyState !== 'loading') {
|
117
|
-
onDocumentReady();
|
118
|
-
} else {
|
119
|
-
document.addEventListener('DOMContentLoaded', onDocumentReady);
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
function showDialog(options) {
|
125
|
-
Events.documentReady(function () {
|
126
|
-
|
127
|
-
self.modal = document.getElementById(modalId);
|
128
|
-
if (!self.modal) {
|
129
|
-
logger.info('\n' + 'load consent modal');
|
130
|
-
self.modal = document.createElement("div");
|
131
|
-
self.modal.id = modalId;
|
132
|
-
self.modal.setAttribute("class", "modal fade");
|
133
|
-
self.modal.setAttribute("tabindex", "-1");
|
134
|
-
self.modal.setAttribute("role", "dialog");
|
135
|
-
self.modal.setAttribute("aria-labelledby", modalId);
|
136
|
-
document.body.append(self.modal);
|
137
|
-
self.$modal = $(self.modal);
|
138
|
-
|
139
|
-
if (self.props.postSelectionCallback) {
|
140
|
-
self.$modal.on("hidden.bs.modal", function () {
|
141
|
-
self.props.postSelectionCallback();
|
142
|
-
});
|
143
|
-
}
|
144
|
-
|
145
|
-
// load modal content
|
146
|
-
//
|
147
|
-
var templateUrl = self.props.contentURL + '/' + 'index.html';
|
148
|
-
$.get(templateUrl)
|
149
|
-
.done(function (data) {
|
150
|
-
logger.info('\n' + 'loading consent modal: successfully');
|
151
|
-
self.modal.innerHTML = data;
|
152
|
-
self.modal.innerHTML = $('#' + self.props.xhr_data_element).eq(0).html();
|
153
|
-
|
154
|
-
$(self.modal).modal({
|
155
|
-
backdrop: "static",
|
156
|
-
keyboard: false
|
157
|
-
});
|
158
|
-
|
159
|
-
self.$buttonDoNotAgree = $("#bccs-buttonDoNotAgree");
|
160
|
-
self.$buttonAgree = $("#bccs-buttonAgree");
|
161
|
-
self.$buttonSave = $("#bccs-buttonSave");
|
162
|
-
self.$buttonAgreeAll = $("#bccs-buttonAgreeAll");
|
163
|
-
|
164
|
-
logger.info('\n' + 'load/initialze options from cookie');
|
165
|
-
|
166
|
-
updateButtons();
|
167
|
-
updateOptionsFromCookie();
|
168
|
-
|
169
|
-
$("#bccs-options").on("hide.bs.collapse", function () {
|
170
|
-
detailedSettingsShown = false;
|
171
|
-
updateButtons();
|
172
|
-
}).on("show.bs.collapse", function () {
|
173
|
-
detailedSettingsShown = true;
|
174
|
-
updateButtons();
|
175
|
-
});
|
176
|
-
|
177
|
-
logger.info('\n' + 'initialze event handler');
|
178
|
-
|
179
|
-
self.$buttonDoNotAgree.click(function () {
|
180
|
-
doNotAgree();
|
181
|
-
});
|
182
|
-
self.$buttonAgree.click(function () {
|
183
|
-
agreeAll();
|
184
|
-
});
|
185
|
-
self.$buttonSave.click(function () {
|
186
|
-
$("#bccs-options").collapse('hide');
|
187
|
-
saveSettings();
|
188
|
-
updateOptionsFromCookie();
|
189
|
-
});
|
190
|
-
self.$buttonAgreeAll.click(function () {
|
191
|
-
$("#bccs-options").collapse('hide');
|
192
|
-
agreeAll();
|
193
|
-
updateOptionsFromCookie();
|
194
|
-
});
|
195
|
-
})
|
196
|
-
.fail(function () {
|
197
|
-
logger.error('\n' + 'loading consent modal: failed');
|
198
|
-
logger.warn('\n' + 'probably no `contentURL` set');
|
199
|
-
})
|
200
|
-
} else {
|
201
|
-
self.$modal.modal("show")
|
202
|
-
}
|
203
|
-
}.bind(this))
|
204
|
-
}
|
205
|
-
|
206
|
-
function updateOptionsFromCookie() {
|
207
|
-
var settings = self.getSettings();
|
208
|
-
if (settings) {
|
209
|
-
for (var setting in settings) {
|
210
|
-
var $checkbox = self.$modal.find("#bccs-options .bccs-option[data-name='" + setting + "'] input[type='checkbox']");
|
211
|
-
$checkbox.prop("checked", settings[setting]);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
function updateButtons() {
|
217
|
-
if (detailedSettingsShown) {
|
218
|
-
self.$buttonDoNotAgree.hide();
|
219
|
-
self.$buttonAgree.hide();
|
220
|
-
self.$buttonSave.show();
|
221
|
-
self.$buttonAgreeAll.show();
|
222
|
-
} else {
|
223
|
-
self.$buttonDoNotAgree.show();
|
224
|
-
self.$buttonAgree.show();
|
225
|
-
self.$buttonSave.hide();
|
226
|
-
self.$buttonAgreeAll.hide();
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
function gatherOptions(setAllExceptNecessary) {
|
231
|
-
var $options = self.$modal.find("#bccs-options .bccs-option");
|
232
|
-
var options = {};
|
233
|
-
for (var i = 0; i < $options.length; i++) {
|
234
|
-
var option = $options[i];
|
235
|
-
var name = option.getAttribute("data-name");
|
236
|
-
if (name === "necessary") {
|
237
|
-
options[name] = true;
|
238
|
-
} else if (setAllExceptNecessary === undefined) {
|
239
|
-
var $checkbox = $(option).find("input[type='checkbox']");
|
240
|
-
options[name] = $checkbox.prop("checked");
|
241
|
-
} else {
|
242
|
-
options[name] = !!setAllExceptNecessary;
|
243
|
-
}
|
244
|
-
}
|
245
|
-
return options
|
246
|
-
}
|
247
|
-
|
248
|
-
function agreeAll() {
|
249
|
-
Cookie.set(self.props.cookieName, JSON.stringify(gatherOptions(true)), self.props.cookieStorageDays, self.props.sameSite, self.props.secure);
|
250
|
-
self.$modal.modal("hide");
|
251
|
-
}
|
252
|
-
|
253
|
-
function doNotAgree() {
|
254
|
-
Cookie.set(self.props.cookieName, JSON.stringify(gatherOptions(false)), self.props.cookieStorageDays, self.props.sameSite, self.props.secure);
|
255
|
-
|
256
|
-
// jadams, 2021-07-15: all cookies NOT longer supported by j1.expireCookie
|
257
|
-
// TODO: Create loop over all cookies found in page
|
258
|
-
//
|
259
|
-
// logger.warn('expire all cookies');
|
260
|
-
// j1.expireCookie('all');
|
261
|
-
|
262
|
-
self.$modal.modal('hide')
|
263
|
-
j1.goHome();
|
264
|
-
}
|
265
|
-
|
266
|
-
function saveSettings() {
|
267
|
-
Cookie.set(self.props.cookieName, JSON.stringify(gatherOptions()), self.props.cookieStorageDays, self.props.sameSite, self.props.secure);
|
268
|
-
self.$modal.modal("hide");
|
269
|
-
}
|
270
|
-
|
271
|
-
// call consent dialog if no cookie found (except pages whitelisted)
|
272
|
-
//
|
273
|
-
whitelisted = (this.props.whitelisted.indexOf(window.location.pathname) > -1);
|
274
|
-
if (Cookie.get(this.props.cookieName) === undefined && this.props.autoShowDialog && !whitelisted) {
|
275
|
-
showDialog();
|
276
|
-
}
|
277
|
-
|
278
|
-
// API functions
|
279
|
-
// ---------------------------------------------------------------------------
|
280
|
-
|
281
|
-
logger.info('\n' + 'initializing core module finished');
|
282
|
-
logger.info('\n' + 'state: finished');
|
283
|
-
|
284
|
-
// show the consent dialog (modal)
|
285
|
-
// ---------------------------------------------------------------------------
|
286
|
-
this.showDialog = function () {
|
287
|
-
whitelisted = (this.props.whitelisted.indexOf(window.location.pathname) > -1);
|
288
|
-
if (!whitelisted) {
|
289
|
-
showDialog();
|
290
|
-
}
|
291
|
-
}
|
292
|
-
|
293
|
-
// collect settings from consent cookie
|
294
|
-
// ---------------------------------------------------------------------------
|
295
|
-
this.getSettings = function (optionName) {
|
296
|
-
var cookie = Cookie.get(self.props.cookieName);
|
297
|
-
if (cookie) {
|
298
|
-
var settings = JSON.parse(Cookie.get(self.props.cookieName));
|
299
|
-
if (optionName === undefined) {
|
300
|
-
return settings;
|
301
|
-
} else {
|
302
|
-
if (settings) {
|
303
|
-
return settings[optionName];
|
304
|
-
} else {
|
305
|
-
return false;
|
306
|
-
}
|
307
|
-
}
|
308
|
-
} else {
|
309
|
-
return undefined;
|
310
|
-
}
|
311
|
-
} // END getSettings
|
312
|
-
|
313
|
-
} // END BootstrapCookieConsent
|
27
|
+
function BootstrapCookieConsent(c){var t=log4javascript.getLogger("j1.core.bsCookieConsent");var r="bccs-modal";var o=this;var p=false;var d=new liteURL(window.location.href);var m=(d.protocol.includes("https"))?true:false;var h;var f;var s;t.info("\ninitializing core module: started");t.info("\nstate: started");this.props={autoShowDialog:true,language:navigator.language,languages:["en","de"],contentURL:"./content",cookieName:"cookie-consent-settings",cookieStorageDays:365,postSelectionCallback:undefined,whitelisted:[],xhr_data_element:"",sameSite:"Strict",secure:false};for(var e in c){this.props[e]=c[e]}this.language=this.props.language;if(this.language.indexOf("-")!==-1){this.language=this.language.split("-")[0]}if(!this.props.languages.includes(this.language)){this.language=this.props.languages[0]}var g={set:function(w,y,B,x,z){var A=window.btoa(y);var u="";if(B){var v=new Date();v.setTime(v.getTime()+(B*24*60*60*1000));u="; expires="+v.toUTCString()}if(z){document.cookie=w+"="+(A||"")+u+"; Path=/; SameSite="+x+"; secure="+z+";"}else{document.cookie=w+"="+(A||"")+u+"; Path=/; SameSite="+x+";"}},get:function(v){var y=v+"=";var u=document.cookie.split(";");for(var w=0;w<u.length;w++){var A=u[w];while(A.charAt(0)===" "){A=A.substring(1,A.length)}if(A.indexOf(y)===0){var z=A.substring(y.length,A.length);var x=window.atob(z);return x}}return undefined}};var l={documentReady:function(u){if(document.readyState!=="loading"){u()}else{document.addEventListener("DOMContentLoaded",u)}}};function k(u){l.documentReady(function(){o.modal=document.getElementById(r);if(!o.modal){t.info("\nload consent modal");o.modal=document.createElement("div");o.modal.id=r;o.modal.setAttribute("class","modal fade");o.modal.setAttribute("tabindex","-1");o.modal.setAttribute("role","dialog");o.modal.setAttribute("aria-labelledby",r);document.body.append(o.modal);o.$modal=$(o.modal);if(o.props.postSelectionCallback){o.$modal.on("hidden.bs.modal",function(){o.props.postSelectionCallback()})}var v=o.props.contentURL+"/index.html";$.get(v).done(function(w){t.info("\nloading consent modal: successfully");o.modal.innerHTML=w;o.modal.innerHTML=$("#"+o.props.xhr_data_element).eq(0).html();$(o.modal).modal({backdrop:"static",keyboard:false});o.$buttonDoNotAgree=$("#bccs-buttonDoNotAgree");o.$buttonAgree=$("#bccs-buttonAgree");o.$buttonSave=$("#bccs-buttonSave");o.$buttonAgreeAll=$("#bccs-buttonAgreeAll");t.info("\nload/initialze options from cookie");j();i();$("#bccs-options").on("hide.bs.collapse",function(){p=false;j()}).on("show.bs.collapse",function(){p=true;j()});t.info("\ninitialze event handler");o.$buttonDoNotAgree.click(function(){b()});o.$buttonAgree.click(function(){n()});o.$buttonSave.click(function(){$("#bccs-options").collapse("hide");q();i()});o.$buttonAgreeAll.click(function(){$("#bccs-options").collapse("hide");n();i()})}).fail(function(){t.error("\nloading consent modal: failed");t.warn("\nprobably no `contentURL` set")})}else{o.$modal.modal("show")}}.bind(this))}function i(){var w=o.getSettings();if(w){for(var v in w){var u=o.$modal.find("#bccs-options .bccs-option[data-name='"+v+"'] input[type='checkbox']");u.prop("checked",w[v])}}}function j(){if(p){o.$buttonDoNotAgree.hide();o.$buttonAgree.hide();o.$buttonSave.show();o.$buttonAgreeAll.show()}else{o.$buttonDoNotAgree.show();o.$buttonAgree.show();o.$buttonSave.hide();o.$buttonAgreeAll.hide()}}function a(v){var u=o.$modal.find("#bccs-options .bccs-option");var x={};for(var y=0;y<u.length;y++){var A=u[y];var w=A.getAttribute("data-name");if(w==="necessary"){x[w]=true}else{if(v===undefined){var z=$(A).find("input[type='checkbox']");x[w]=z.prop("checked")}else{x[w]=!!v}}}return x}function n(){g.set(o.props.cookieName,JSON.stringify(a(true)),o.props.cookieStorageDays,o.props.sameSite,o.props.secure);o.$modal.modal("hide")}function b(){g.set(o.props.cookieName,JSON.stringify(a(false)),o.props.cookieStorageDays,o.props.sameSite,o.props.secure);o.$modal.modal("hide");j1.goHome()}function q(){g.set(o.props.cookieName,JSON.stringify(a()),o.props.cookieStorageDays,o.props.sameSite,o.props.secure);o.$modal.modal("hide")}s=(this.props.whitelisted.indexOf(window.location.pathname)>-1);if(g.get(this.props.cookieName)===undefined&&this.props.autoShowDialog&&!s){k()}t.info("\ninitializing core module finished");t.info("\nstate: finished");this.showDialog=function(){s=(this.props.whitelisted.indexOf(window.location.pathname)>-1);if(!s){k()}};this.getSettings=function(v){var u=g.get(o.props.cookieName);if(u){var w=JSON.parse(g.get(o.props.cookieName));if(v===undefined){return w}else{if(w){return w[v]}else{return false}}}else{return undefined}}};
|