j1-template 2022.0.5 → 2022.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_layouts/default.html +0 -57
- data/assets/error_pages/HTTP444.html +4 -4
- data/assets/error_pages/HTTP445.html +3 -3
- data/assets/error_pages/HTTP446.html +110 -0
- data/assets/themes/j1/adapter/js/cookieConsent.js +64 -34
- data/assets/themes/j1/adapter/js/j1.js +114 -210
- data/assets/themes/j1/adapter/js/themer.js +0 -1
- data/assets/themes/j1/adapter/js/translator.js +146 -97
- data/assets/themes/j1/core/css/themes/unodark/bootstrap.css +6 -0
- data/assets/themes/j1/core/css/themes/unodark/bootstrap.min.css +1 -1
- data/assets/themes/j1/core/js/template.js +2 -6
- data/assets/themes/j1/core/js/template.min.js +1 -1
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +29 -13
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +0 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +1 -1
- data/assets/themes/j1/modules/translator/js/translator.js +98 -63
- data/assets/themes/j1/modules/translator/js/translator.min.js +1 -1
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +2 -3
- data/lib/starter_web/_data/modules/cookies.yml +30 -0
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +3 -3
- data/lib/starter_web/_data/modules/defaults/cookies.yml +112 -0
- data/lib/starter_web/_data/modules/navigator_menu.yml +10 -1
- data/lib/starter_web/_includes/attributes.asciidoc +6 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/_test_pages/google-translate-tester.1.adoc +0 -2
- data/lib/starter_web/pages/_test_pages/google-translate-tester.4.adoc +0 -2
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/100_converter.adoc +1 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/200_themes.adoc +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive.html +1 -1
- data/lib/starter_web/pages/public/blog/navigator/index.html +1 -1
- data/lib/starter_web/pages/public/learn/quickstart.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +2 -2
- data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/500_themes.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/600_quicksearch.adoc +1 -1
- data/lib/starter_web/pages/public/legal/de/300_privacy.adoc +2 -12
- data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +2 -12
- data/lib/starter_web/pages/public/manuals/dropdown-help.adoc +1 -1
- data/lib/starter_web/pages/public/panels/intro_panel/panel.adoc +1 -1
- data/lib/starter_web/pages/public/previewer/preview_bootstrap_theme.adoc +1 -1
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +5 -2
@@ -54,6 +54,9 @@ regenerate: true
|
|
54
54
|
{% assign footer_config_defaults = blocks.defaults.footer.defaults %}
|
55
55
|
{% assign toccer_defaults = modules.defaults.toccer.defaults %}
|
56
56
|
|
57
|
+
{% assign cookie_defaults = modules.defaults.cookies.defaults %}
|
58
|
+
{% assign cookie_settings = modules.cookies.settings %}
|
59
|
+
|
57
60
|
{% assign themer_defaults = modules.defaults.themer.defaults %}
|
58
61
|
{% assign themer_settings = modules.themer.settings %}
|
59
62
|
|
@@ -67,6 +70,7 @@ regenerate: true
|
|
67
70
|
-------------------------------------------------------------------------------- {% endcomment %}
|
68
71
|
{% assign toccer_options = toccer_defaults | merge: toccer_settings %}
|
69
72
|
{% assign themer_options = themer_defaults| merge: themer_settings %}
|
73
|
+
{% assign cookie_options = cookie_defaults | merge: cookie_settings %}
|
70
74
|
|
71
75
|
{% assign authentication_options = authentication_defaults | merge: authentication_settings %}
|
72
76
|
|
@@ -170,9 +174,7 @@ var j1 = (function () {
|
|
170
174
|
// Default comment provider information
|
171
175
|
var comment_provider = '{{comment_provider}}';
|
172
176
|
var site_id = '{{site_id}}';
|
173
|
-
|
174
|
-
// Default translator settings (currently NOT supported)
|
175
|
-
// var translation_enabled = {{template_config.translation.enabled}};
|
177
|
+
var check_cookies = {{cookie_options.check_cookies}};
|
176
178
|
|
177
179
|
var current_user_data;
|
178
180
|
var current_page;
|
@@ -305,7 +307,7 @@ var j1 = (function () {
|
|
305
307
|
j1['xhrDOMState'] = {};
|
306
308
|
|
307
309
|
// -----------------------------------------------------------------------
|
308
|
-
//
|
310
|
+
// final updates before browser page|tab
|
309
311
|
// see: https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing
|
310
312
|
// -----------------------------------------------------------------------
|
311
313
|
window.addEventListener('beforeunload', function (event) {
|
@@ -318,52 +320,27 @@ var j1 = (function () {
|
|
318
320
|
var url;
|
319
321
|
var baseUrl;
|
320
322
|
|
321
|
-
// final update of the user state cookie
|
322
|
-
|
323
|
-
|
324
|
-
user_state.session_active = false;
|
325
|
-
user_state.last_session_ts = timestamp_now;
|
323
|
+
// final update of the user state cookie
|
324
|
+
user_state.session_active = false;
|
325
|
+
user_state.last_session_ts = timestamp_now;
|
326
326
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
});
|
337
|
-
if (!cookie_written) {
|
338
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_consent);
|
339
|
-
}
|
340
|
-
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
341
|
-
cookie_written = j1.writeCookie({
|
342
|
-
name: cookie_names.user_state,
|
343
|
-
data: user_state,
|
344
|
-
samesite: 'Strict',
|
345
|
-
secure: secure,
|
346
|
-
expires: 0
|
347
|
-
});
|
348
|
-
if (!cookie_written) {
|
349
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_consent);
|
350
|
-
}
|
351
|
-
} else {
|
352
|
-
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
353
|
-
cookie_written = j1.writeCookie({
|
354
|
-
name: cookie_names.user_state,
|
355
|
-
data: user_state,
|
356
|
-
samesite: 'Strict',
|
357
|
-
secure: secure,
|
358
|
-
expires: 365
|
359
|
-
});
|
360
|
-
if (!cookie_written) {
|
361
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
362
|
-
}
|
363
|
-
}
|
327
|
+
if (!user_consent.analysis || !user_consent.personalization) {
|
328
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
329
|
+
|
330
|
+
cookie_written = j1.writeCookie({
|
331
|
+
name: cookie_names.user_state,
|
332
|
+
data: user_state,
|
333
|
+
secure: secure,
|
334
|
+
expires: 0
|
335
|
+
});
|
364
336
|
} else {
|
365
|
-
|
366
|
-
|
337
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
338
|
+
cookie_written = j1.writeCookie({
|
339
|
+
name: cookie_names.user_state,
|
340
|
+
data: user_state,
|
341
|
+
secure: secure,
|
342
|
+
expires: 365
|
343
|
+
});
|
367
344
|
}
|
368
345
|
}); // END beforeunload
|
369
346
|
|
@@ -379,115 +356,37 @@ var j1 = (function () {
|
|
379
356
|
: cookie_written = j1.writeCookie({
|
380
357
|
name: cookie_names.user_session,
|
381
358
|
data: user_session,
|
382
|
-
samesite: 'Strict',
|
383
359
|
secure: secure,
|
384
360
|
expires: 0
|
385
361
|
});
|
386
|
-
if (!cookie_written) {
|
387
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
388
|
-
}
|
389
362
|
|
390
363
|
user_state = j1.existsCookie(cookie_names.user_state)
|
391
364
|
? j1.readCookie(cookie_names.user_state)
|
392
365
|
: cookie_written = j1.writeCookie({
|
393
366
|
name: cookie_names.user_state,
|
394
367
|
data: user_state,
|
395
|
-
samesite: 'Strict',
|
396
368
|
secure: secure,
|
397
369
|
expires: 365
|
398
370
|
});
|
399
|
-
if (!cookie_written) {
|
400
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
401
|
-
}
|
402
371
|
|
403
|
-
// jadams, 2021-
|
404
|
-
//
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
gaCookies.forEach(item => console.log('j1.core.switcher: ' + item));
|
413
|
-
user_state = j1.readCookie(cookie_names.user_state);
|
414
|
-
user_state.session_active = true;
|
372
|
+
// jadams, 2021-12-06: Check if access to cookies for this site failed.
|
373
|
+
// Possibly, a third-party domain or an attacker tries to access it.
|
374
|
+
if (check_cookies) {
|
375
|
+
if (!user_state) {
|
376
|
+
logger.error('\n' + 'Access to cookie failed or cookie not found: ' + cookie_names.user_state);
|
377
|
+
logger.debug('\n' + 'j1 cookies found:' + j1Cookies.length);
|
378
|
+
// redirect to error page: blocked content
|
379
|
+
window.location.href = '/446.html';
|
380
|
+
}
|
415
381
|
}
|
416
382
|
|
417
383
|
if (!user_consent.analysis || !user_consent.personalization) {
|
418
|
-
//
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
data: user_state,
|
423
|
-
samesite: 'Strict',
|
424
|
-
secure: secure,
|
425
|
-
expires: 0
|
426
|
-
});
|
427
|
-
if (!cookie_written) {
|
428
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
429
|
-
}
|
430
|
-
} else {
|
431
|
-
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_state);
|
432
|
-
cookie_written = j1.writeCookie({
|
433
|
-
name: cookie_names.user_state,
|
434
|
-
data: user_state,
|
435
|
-
samesite: 'Strict',
|
436
|
-
secure: secure,
|
437
|
-
expires: 365
|
438
|
-
});
|
439
|
-
if (!cookie_written) {
|
440
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_state);
|
441
|
-
}
|
384
|
+
// expire permanent cookies to session
|
385
|
+
j1.expireCookie({ name: cookie_names.user_state });
|
386
|
+
j1.expireCookie({ name: cookie_names.user_consent });
|
387
|
+
j1.expireCookie({ name: cookie_names.user_translate });
|
442
388
|
}
|
443
389
|
|
444
|
-
// jadams, 2021-11-10: anchor links of type #void are used/managed
|
445
|
-
// by the FAB module. No geneneraL use for NOW.
|
446
|
-
// -----------------------------------------------------------------------
|
447
|
-
// initialize event handler for smooth scroll on in-page anchors
|
448
|
-
// $('a[href*=\\#]').on('click', function (event) {
|
449
|
-
// // ignore void links
|
450
|
-
// if (window.location.href.includes('#void')||this.href.includes('#void')) {
|
451
|
-
// return false;
|
452
|
-
// }
|
453
|
-
// // for external links, redirect to this page
|
454
|
-
// if (window.location.pathname !== this.pathname) {
|
455
|
-
// window.location.href = this.href;
|
456
|
-
// } else {
|
457
|
-
// // continue on in-page anchor
|
458
|
-
// var toccerScrollDuration = 300;
|
459
|
-
// var toccerScrollOffset = 10;
|
460
|
-
//
|
461
|
-
// // calculate offset value for correct (smooth) scroll position
|
462
|
-
// //
|
463
|
-
// var $pagehead = $('.attic');
|
464
|
-
// var $navbar = $('nav.navbar');
|
465
|
-
// var $adblock = $('#adblock');
|
466
|
-
// var navbarType = $navbar.hasClass('navbar-fixed') ? 'fixed' : 'scrolled';
|
467
|
-
// var fontSize = $('body').css('font-size').replace('px','');
|
468
|
-
// var start = window.pageYOffset;
|
469
|
-
// var l = parseInt(fontSize);
|
470
|
-
// var h = $pagehead.length ? $pagehead.height() : 0;
|
471
|
-
// var n = $navbar.length ? $navbar.height() : 0;
|
472
|
-
// var a = $adblock.length ? $adblock.height() : 0;
|
473
|
-
// var scrollOffset = navbarType == 'fixed' ? -1*(n + a + l) : -1*(h + n + a + l);
|
474
|
-
//
|
475
|
-
// // TODO: to be checked why this static offset (toccerScrollOffset)
|
476
|
-
// // is needed
|
477
|
-
// scrollOffset = scrollOffset + toccerScrollOffset;
|
478
|
-
//
|
479
|
-
// logger.debug('\n' + 'scroll to anchor: ' + this.hash);
|
480
|
-
// $("html, body").animate({
|
481
|
-
// scrollTop: $($(this).attr("href")).offset().top + scrollOffset + "px"
|
482
|
-
// }, {
|
483
|
-
// duration: toccerScrollDuration,
|
484
|
-
// easing: "swing"
|
485
|
-
// });
|
486
|
-
// // disable bubble up the event
|
487
|
-
// return false;
|
488
|
-
// } // End in-page link
|
489
|
-
// }); // END click event on anchors
|
490
|
-
|
491
390
|
// initialize event handler for window/history/back on <ESC>
|
492
391
|
// -----------------------------------------------------------------------
|
493
392
|
window.onkeyup = function (event) {
|
@@ -522,15 +421,10 @@ var j1 = (function () {
|
|
522
421
|
cookie_written = j1.writeCookie({
|
523
422
|
name: cookie_names.user_session,
|
524
423
|
data: user_session,
|
525
|
-
samesite: 'Strict',
|
526
424
|
secure: secure,
|
527
425
|
expires: 0
|
528
426
|
});
|
529
427
|
|
530
|
-
if (!cookie_written) {
|
531
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
532
|
-
}
|
533
|
-
|
534
428
|
j1.setState(curr_state);
|
535
429
|
logger.info('\n' + 'state: ' + j1.getState());
|
536
430
|
|
@@ -571,13 +465,9 @@ var j1 = (function () {
|
|
571
465
|
cookie_written = j1.writeCookie({
|
572
466
|
name: cookie_names.user_session,
|
573
467
|
data: user_session,
|
574
|
-
samesite: 'Strict',
|
575
468
|
secure: secure,
|
576
469
|
expires: 0
|
577
470
|
});
|
578
|
-
if (!cookie_written) {
|
579
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
580
|
-
}
|
581
471
|
|
582
472
|
j1.setState(curr_state);
|
583
473
|
logger.info('\n' + 'state: ' + j1.getState());
|
@@ -606,7 +496,8 @@ var j1 = (function () {
|
|
606
496
|
themeName = user_session.theme_name;
|
607
497
|
themeCss = user_session.theme_css;
|
608
498
|
|
609
|
-
//
|
499
|
+
// -----------------------------------------------------------------------
|
500
|
+
// Save last page access
|
610
501
|
// see: https://stackoverflow.com/questions/3528324/how-to-get-the-previous-url-in-javascript
|
611
502
|
// see: https://developer.mozilla.org/de/docs/Web/API/Window/history
|
612
503
|
//
|
@@ -634,15 +525,10 @@ var j1 = (function () {
|
|
634
525
|
cookie_written = j1.writeCookie({
|
635
526
|
name: cookie_names.user_session,
|
636
527
|
data: user_session,
|
637
|
-
samesite: 'Strict',
|
638
528
|
secure: secure,
|
639
529
|
expires: 0
|
640
530
|
});
|
641
531
|
|
642
|
-
if (!cookie_written) {
|
643
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
644
|
-
}
|
645
|
-
|
646
532
|
// NOTE: asynchronous calls should be rewitten to xhrData
|
647
533
|
// initialize page resources for blocks
|
648
534
|
j1.initBanner(settings);
|
@@ -651,20 +537,15 @@ var j1 = (function () {
|
|
651
537
|
|
652
538
|
state = 'running';
|
653
539
|
logger.info('\n' + 'state: ' + state);
|
654
|
-
// logger.info(logText);
|
655
540
|
|
656
541
|
user_session.timestamp = timestamp_now;
|
657
542
|
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_session);
|
658
543
|
cookie_written = j1.writeCookie({
|
659
544
|
name: cookie_names.user_session,
|
660
545
|
data: user_session,
|
661
|
-
samesite: 'Strict',
|
662
546
|
secure: secure,
|
663
547
|
expires: 0
|
664
548
|
});
|
665
|
-
if (!cookie_written) {
|
666
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
667
|
-
}
|
668
549
|
|
669
550
|
// -----------------------------------------------------------------------
|
670
551
|
// additional BS helpers from j1.core
|
@@ -786,7 +667,6 @@ var j1 = (function () {
|
|
786
667
|
// initPanel()
|
787
668
|
// AJAX fetcher to load and place all panel used for a page
|
788
669
|
// -------------------------------------------------------------------------
|
789
|
-
// ToDo:
|
790
670
|
initPanel: function ( options ) {
|
791
671
|
var logger = log4javascript.getLogger('j1.initPanel');
|
792
672
|
var panel = [];
|
@@ -1007,20 +887,17 @@ var j1 = (function () {
|
|
1007
887
|
cookie_written = j1.writeCookie({
|
1008
888
|
name: cookie_names.user_session,
|
1009
889
|
data: user_session,
|
1010
|
-
samesite: 'Strict',
|
1011
890
|
secure: secure,
|
1012
891
|
expires: 0
|
1013
892
|
});
|
1014
|
-
if (!cookie_written) {
|
1015
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
1016
|
-
}
|
1017
893
|
|
1018
894
|
providerPermissions = user_session.provider_permissions;
|
1019
895
|
categoryAllowed = providerPermissions.includes(user_session.page_permission);
|
1020
896
|
|
897
|
+
// -------------------------------------------------------------------
|
1021
898
|
// check protected pages (applies for APP only)
|
1022
899
|
// make sure that protected pages are ALWAYS checked for permissions
|
1023
|
-
//
|
900
|
+
//
|
1024
901
|
if (
|
1025
902
|
j1.authEnabled() &&
|
1026
903
|
user_session.page_permission !== 'public' &&
|
@@ -1123,13 +1000,7 @@ var j1 = (function () {
|
|
1123
1000
|
$('#quickLinksCookieButton').css('display', 'none');
|
1124
1001
|
}
|
1125
1002
|
|
1126
|
-
//
|
1127
|
-
// if (translation_enabled) {
|
1128
|
-
// logger.info('\n' + 'translator detected: google');
|
1129
|
-
// logger.info('\n' + 'initialize language selector');
|
1130
|
-
// $('.goog-te-combo').addClass('form-control');
|
1131
|
-
// }
|
1132
|
-
|
1003
|
+
// -----------------------------------------------------------------
|
1133
1004
|
// show cc icon (currently NOT supported)
|
1134
1005
|
// $('#quickLinksControlCenterButton').css('display', 'block');
|
1135
1006
|
|
@@ -1301,20 +1172,9 @@ var j1 = (function () {
|
|
1301
1172
|
cookie_written = j1.writeCookie({
|
1302
1173
|
name: cookie_names.user_session,
|
1303
1174
|
data: user_session,
|
1304
|
-
samesite: 'Strict',
|
1305
1175
|
secure: secure,
|
1306
1176
|
expires: 0
|
1307
1177
|
});
|
1308
|
-
if (!cookie_written) {
|
1309
|
-
logger.error('\n' + 'failed to write cookie: ' + cookie_names.user_session);
|
1310
|
-
}
|
1311
|
-
|
1312
|
-
// show|hide translator icon (currently NOT supported)
|
1313
|
-
// if (translation_enabled) {
|
1314
|
-
// logger.info('\n' + 'translator detected: google');
|
1315
|
-
// logger.info('\n' + 'initialize language selector');
|
1316
|
-
// $('.goog-te-combo').addClass('form-control');
|
1317
|
-
// }
|
1318
1178
|
|
1319
1179
|
// show cc icon (currently NOT supported)
|
1320
1180
|
// $('#quickLinksControlCenterButton').css('display', 'block');
|
@@ -1450,6 +1310,7 @@ var j1 = (function () {
|
|
1450
1310
|
|
1451
1311
|
return scrollOffset;
|
1452
1312
|
},
|
1313
|
+
|
1453
1314
|
// -------------------------------------------------------------------------
|
1454
1315
|
// scrollTo()
|
1455
1316
|
// Scrolls smooth to any anchor referenced by an page URL on
|
@@ -1754,25 +1615,29 @@ var j1 = (function () {
|
|
1754
1615
|
// context/HTTPS).
|
1755
1616
|
// -------------------------------------------------------------------------
|
1756
1617
|
writeCookie: function (options /*name, data, [path, expires, domain, samesite, http_only, secure]*/) {
|
1757
|
-
var date
|
1758
|
-
var timestamp_now
|
1759
|
-
var
|
1618
|
+
var date = new Date();
|
1619
|
+
var timestamp_now = date.toISOString()
|
1620
|
+
var url = new liteURL(window.location.href);
|
1621
|
+
var baseUrl = url.origin;;
|
1622
|
+
var hostname = url.hostname;
|
1623
|
+
var domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
1624
|
+
var stringifiedAttributes = '';
|
1625
|
+
var cookie_data = {};
|
1760
1626
|
var data_json;
|
1761
1627
|
var data_encoded;
|
1762
1628
|
var expires;
|
1763
|
-
var
|
1629
|
+
var domainAttribute;
|
1764
1630
|
|
1765
1631
|
var defaults = {
|
1766
|
-
data:
|
1767
|
-
name:
|
1768
|
-
path:
|
1769
|
-
expires:
|
1770
|
-
domain:
|
1771
|
-
samesite:
|
1772
|
-
http_only:
|
1773
|
-
secure:
|
1632
|
+
data: {},
|
1633
|
+
name: '',
|
1634
|
+
path: '{{cookie_options.path}}',
|
1635
|
+
expires: '{{cookie_options.expires}}',
|
1636
|
+
domain: '{{cookie_options.domain}}',
|
1637
|
+
samesite: '{{cookie_options.same_site}}',
|
1638
|
+
http_only: '{{cookie_options.http_only}}',
|
1639
|
+
secure: '{{cookie_options.secure}}'
|
1774
1640
|
};
|
1775
|
-
|
1776
1641
|
var settings = $.extend(defaults, options);
|
1777
1642
|
|
1778
1643
|
cookie_data.timestamp = timestamp_now;
|
@@ -1788,17 +1653,26 @@ var j1 = (function () {
|
|
1788
1653
|
data_encoded = window.btoa(data_json);
|
1789
1654
|
}
|
1790
1655
|
|
1791
|
-
stringifiedAttributes += '; ' + '
|
1656
|
+
stringifiedAttributes += '; ' + 'Path=' + settings.path;
|
1792
1657
|
|
1793
1658
|
if (settings.expires > 0) {
|
1794
1659
|
date.setTime(date.getTime() + (settings.expires * 24 * 60 * 60 * 1000));
|
1795
|
-
stringifiedAttributes += '; ' + '
|
1660
|
+
stringifiedAttributes += '; ' + 'Expires=' + date.toUTCString();
|
1796
1661
|
}
|
1797
1662
|
|
1798
1663
|
stringifiedAttributes += '; ' + 'SameSite=' + settings.samesite;
|
1799
1664
|
|
1800
|
-
|
1801
|
-
|
1665
|
+
// set domain used by cookies
|
1666
|
+
if (settings.domain == 'auto') {
|
1667
|
+
domainAttribute = domain;
|
1668
|
+
stringifiedAttributes += '; ' + 'Domain=' + domainAttribute;
|
1669
|
+
} else {
|
1670
|
+
domainAttribute = '';
|
1671
|
+
stringifiedAttributes += '; ' + 'Domain=' + domainAttribute;
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
if (settings.secure == 'true') {
|
1675
|
+
stringifiedAttributes += '; ' + 'Secure=' + settings.secure;
|
1802
1676
|
}
|
1803
1677
|
|
1804
1678
|
// write the cookie
|
@@ -1833,16 +1707,29 @@ var j1 = (function () {
|
|
1833
1707
|
// removeCookie (Vanilla JS)
|
1834
1708
|
// -------------------------------------------------------------------------
|
1835
1709
|
removeCookie: function (options /*name, [path, domain]*/) {
|
1836
|
-
var cookieExists;
|
1837
1710
|
var defaults = {
|
1838
|
-
|
1839
|
-
|
1711
|
+
path: '{{cookie_options.path}}',
|
1712
|
+
expires: '{{cookie_options.expires}}',
|
1713
|
+
domain: '{{cookie_options.domain}}',
|
1714
|
+
samesite: '{{cookie_options.same_site}}',
|
1715
|
+
http_only: '{{cookie_options.http_only}}',
|
1716
|
+
secure: '{{cookie_options.secure}}'
|
1840
1717
|
};
|
1718
|
+
var cookieExists;
|
1719
|
+
|
1841
1720
|
var settings = $.extend(defaults, options);
|
1842
1721
|
|
1722
|
+
// set domain used by cookies
|
1723
|
+
if (settings.domain == 'auto') {
|
1724
|
+
domainAttribute = domain ;
|
1725
|
+
} else {
|
1726
|
+
// domainAttribute = hostname;
|
1727
|
+
domainAttribute = '';
|
1728
|
+
}
|
1729
|
+
|
1843
1730
|
if (j1.findCookie(settings.name)) {
|
1844
1731
|
// clear cookie CONTENT and set expiry date in the PAST
|
1845
|
-
document.cookie = settings.name + '=;
|
1732
|
+
document.cookie = settings.name + '=; Domain=' + domainAttribute + '; Expires=Thu, 01 Jan 1970 00:00:00 UTC; Path=/;';
|
1846
1733
|
return true;
|
1847
1734
|
} else {
|
1848
1735
|
return false;
|
@@ -1868,13 +1755,30 @@ var j1 = (function () {
|
|
1868
1755
|
// to JavaScript. For that reason, attributes needs to be set explicitly.
|
1869
1756
|
// -------------------------------------------------------------------------
|
1870
1757
|
expireCookie: function (options /*name [,path, samesite, secure]*/) {
|
1758
|
+
var url = new liteURL(window.location.href);
|
1759
|
+
var baseUrl = url.origin;;
|
1760
|
+
var hostname = url.hostname;
|
1761
|
+
var domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
1762
|
+
var domainAttribute;
|
1763
|
+
|
1871
1764
|
var defaults = {
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1765
|
+
path: '{{cookie_options.path}}',
|
1766
|
+
expires: '{{cookie_options.expires}}',
|
1767
|
+
domain: '{{cookie_options.domain}}',
|
1768
|
+
samesite: '{{cookie_options.same_site}}',
|
1769
|
+
http_only: '{{cookie_options.http_only}}',
|
1770
|
+
secure: '{{cookie_options.secure}}'
|
1875
1771
|
};
|
1876
1772
|
var settings = $.extend(defaults, options);
|
1877
1773
|
|
1774
|
+
// set domain used by cookies
|
1775
|
+
if (settings.domain == 'auto') {
|
1776
|
+
domainAttribute = domain ;
|
1777
|
+
} else {
|
1778
|
+
// domainAttribute = hostname;
|
1779
|
+
domainAttribute = '';
|
1780
|
+
}
|
1781
|
+
|
1878
1782
|
var dc = document.cookie; // all cookies in page
|
1879
1783
|
var end = dc.length; // default to end of the string
|
1880
1784
|
var prefix = settings.name + '='; // search string for the cookie name given
|
@@ -1902,10 +1806,10 @@ var j1 = (function () {
|
|
1902
1806
|
|
1903
1807
|
// expire cookie to session
|
1904
1808
|
content = decodeURI(dc.substring(begin + prefix.length, end) ).replace(/"/g, '');
|
1905
|
-
if (settings.secure) {
|
1906
|
-
document.cookie = settings.name + '=' + content +';
|
1809
|
+
if (settings.secure == 'true') {
|
1810
|
+
document.cookie = settings.name + '=' + content +'; Path=' + settings.path + '; ' + 'SameSite=' + settings.samesite + '; ' + 'Domain=' + domainAttribute + '; Secure' + '; ';
|
1907
1811
|
} else {
|
1908
|
-
document.cookie = settings.name + '=' + content +';
|
1812
|
+
document.cookie = settings.name + '=' + content +'; Path=' + settings.path + '; ' + 'SameSite=' + settings.samesite + '; ' + 'Domain=' + domainAttribute + '; ';
|
1909
1813
|
}
|
1910
1814
|
|
1911
1815
|
return true;
|