j1-template 2022.0.7 → 2022.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_layouts/default.html +0 -56
- 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 +53 -24
- data/assets/themes/j1/adapter/js/j1.js +70 -176
- data/assets/themes/j1/adapter/js/translator.js +106 -52
- 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/translator/js/translator.js +97 -62
- 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 +1 -1
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +3 -3
- data/lib/starter_web/_data/modules/defaults/cookies.yml +70 -6
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +3 -2
@@ -35,6 +35,9 @@ regenerate: true
|
|
35
35
|
|
36
36
|
{% comment %} Set config data
|
37
37
|
-------------------------------------------------------------------------------- {% endcomment %}
|
38
|
+
{% assign cookie_defaults = modules.defaults.cookies.defaults %}
|
39
|
+
{% assign cookie_settings = modules.cookies.settings %}
|
40
|
+
|
38
41
|
{% assign translator_defaults = modules.defaults.translator.defaults %}
|
39
42
|
{% assign translator_settings = modules.translator.settings %}
|
40
43
|
{% assign tracking_enabled = template_config.analytics.enabled %}
|
@@ -42,6 +45,7 @@ regenerate: true
|
|
42
45
|
{% comment %} Set config options
|
43
46
|
-------------------------------------------------------------------------------- {% endcomment %}
|
44
47
|
{% assign translator_options = translator_defaults | merge: translator_settings %}
|
48
|
+
{% assign cookie_options = cookie_defaults | merge: cookie_settings %}
|
45
49
|
|
46
50
|
{% assign production = false %}
|
47
51
|
{% if environment == 'prod' or environment == 'production' %}
|
@@ -95,6 +99,7 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
95
99
|
var hostname;
|
96
100
|
var domain;
|
97
101
|
var cookie_domain;
|
102
|
+
var domain_enabled;
|
98
103
|
var secure;
|
99
104
|
var logText;
|
100
105
|
var cookie_written;
|
@@ -111,10 +116,17 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
111
116
|
|
112
117
|
// ---------------------------------------------------------------------------
|
113
118
|
// setCookie()
|
114
|
-
// writes a
|
119
|
+
// writes a FLAT cookie (not using an encoded JSON string)
|
115
120
|
// ---------------------------------------------------------------------------
|
116
121
|
function setCookie(options /*cName, cValue, expDays*/) {
|
117
|
-
var
|
122
|
+
var date = new Date();
|
123
|
+
var timestamp_now = date.toISOString()
|
124
|
+
var url = new liteURL(window.location.href);
|
125
|
+
var baseUrl = url.origin;;
|
126
|
+
var hostname = url.hostname;
|
127
|
+
var domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
128
|
+
var domain_enabled = '{{cookie_options.domain}}';
|
129
|
+
var defaults = {};
|
118
130
|
var settings;
|
119
131
|
var document_cookie;
|
120
132
|
var stringifiedAttributes = '';
|
@@ -123,7 +135,7 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
123
135
|
name: '',
|
124
136
|
path: '/',
|
125
137
|
expires: 0,
|
126
|
-
domain:
|
138
|
+
domain: true,
|
127
139
|
samesite: 'Lax',
|
128
140
|
http_only: false,
|
129
141
|
secure: false
|
@@ -137,6 +149,13 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
137
149
|
stringifiedAttributes += '; ' + 'expires=' + date.toUTCString();
|
138
150
|
}
|
139
151
|
|
152
|
+
if (domain != hostname) {
|
153
|
+
settings.domain = domain_enabled ? '.' + domain : hostname;
|
154
|
+
} else {
|
155
|
+
settings.domain = hostname;
|
156
|
+
}
|
157
|
+
stringifiedAttributes += '; ' + 'domain=' + settings.domain;
|
158
|
+
|
140
159
|
stringifiedAttributes += '; ' + 'SameSite=' + settings.samesite;
|
141
160
|
|
142
161
|
if (settings.secure) {
|
@@ -168,7 +187,7 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
168
187
|
baseUrl = url.origin;
|
169
188
|
hostname = url.hostname;
|
170
189
|
domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
171
|
-
|
190
|
+
domain_enabled = '{{cookie_options.domain}}';
|
172
191
|
secure = (url.protocol.includes('https')) ? true : false;
|
173
192
|
navigator_language = navigator.language || navigator.userLanguage; // userLanguage for MS IE compatibility
|
174
193
|
translation_language = navigator_language.split('-')[0];
|
@@ -188,22 +207,8 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
188
207
|
'translationLanguage': translation_language,
|
189
208
|
};
|
190
209
|
|
191
|
-
// load|initialize user translate cookie
|
192
|
-
if (j1.existsCookie(cookie_names.user_translate)) {
|
193
|
-
user_translate = j1.readCookie(cookie_names.user_translate);
|
194
|
-
} else {
|
195
|
-
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_translate);
|
196
|
-
cookie_written = j1.writeCookie({
|
197
|
-
name: cookie_names.user_translate,
|
198
|
-
data: user_translate,
|
199
|
-
secure: secure,
|
200
|
-
expires: 365
|
201
|
-
});
|
202
|
-
}
|
203
|
-
|
204
210
|
// initialize state flag
|
205
211
|
_this.state = 'pending';
|
206
|
-
// _this.settings.languageList = '/assets/data/ms_select.json';
|
207
212
|
|
208
213
|
// -----------------------------------------------------------------------
|
209
214
|
// Default module settings
|
@@ -228,7 +233,30 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
228
233
|
// initializer
|
229
234
|
// -----------------------------------------------------------------------
|
230
235
|
var dependencies_met_page_ready = setInterval (function (options) {
|
231
|
-
|
236
|
+
var expires = '{{cookie_options.expires}}';
|
237
|
+
var same_site = '{{cookie_options.same_site}}';
|
238
|
+
user_consent = j1.readCookie(cookie_names.user_consent);
|
239
|
+
|
240
|
+
// set domain used by cookies
|
241
|
+
if (domain != hostname) {
|
242
|
+
cookie_domain = domain_enabled ? '.' + domain : hostname;
|
243
|
+
} else {
|
244
|
+
cookie_domain = hostname;
|
245
|
+
}
|
246
|
+
|
247
|
+
// load|initialize user translate cookie
|
248
|
+
if (j1.existsCookie(cookie_names.user_translate)) {
|
249
|
+
user_translate = j1.readCookie(cookie_names.user_translate);
|
250
|
+
} else {
|
251
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_translate);
|
252
|
+
cookie_written = j1.writeCookie({
|
253
|
+
name: cookie_names.user_translate,
|
254
|
+
data: user_translate,
|
255
|
+
samesite: 'Strict',
|
256
|
+
secure: secure,
|
257
|
+
expires: 365
|
258
|
+
});
|
259
|
+
}
|
232
260
|
|
233
261
|
if ( j1.getState() === 'finished' ) {
|
234
262
|
_this.setState('started');
|
@@ -256,15 +284,28 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
256
284
|
}
|
257
285
|
}
|
258
286
|
|
259
|
-
//
|
260
|
-
user_translate
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
287
|
+
// load|set user translate cookie
|
288
|
+
user_translate = j1.readCookie(cookie_names.user_translate);
|
289
|
+
if (!user_consent.analysis || !user_consent.personalization) {
|
290
|
+
// disable translation service
|
291
|
+
user_translate.translationEnabled = false;
|
292
|
+
cookie_written = j1.writeCookie({
|
293
|
+
name: cookie_names.user_translate,
|
294
|
+
data: user_translate,
|
295
|
+
secure: secure
|
296
|
+
});
|
297
|
+
|
298
|
+
// expire permanent cookie to session
|
299
|
+
j1.expireCookie({ name: cookie_names.user_translate });
|
300
|
+
} else {
|
301
|
+
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_translate);
|
302
|
+
cookie_written = j1.writeCookie({
|
303
|
+
name: cookie_names.user_translate,
|
304
|
+
data: user_translate,
|
305
|
+
secure: secure,
|
306
|
+
expires: 365
|
307
|
+
});
|
308
|
+
}
|
268
309
|
|
269
310
|
if (moduleOptions.dialogLanguage === 'auto') {
|
270
311
|
moduleOptions.dialogLanguage = '{{contentLanguage}}';
|
@@ -272,7 +313,11 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
272
313
|
|
273
314
|
j1.translator = new Translator({
|
274
315
|
contentURL: moduleOptions.contentURL, // dialog content (modals) for all supported languages
|
275
|
-
cookieName:
|
316
|
+
cookieName: cookie_names.user_translate, // name of the translator cookie
|
317
|
+
cookieStorageDays: expires, // lifetime of a cookie [0..365], 0: session cookie
|
318
|
+
cookieSameSite: same_site, // restrict consent cookie
|
319
|
+
cookieDomain: cookie_domain, // set domain (hostname|domain)
|
320
|
+
cookieSecure: secure, // set
|
276
321
|
cookieConsentName: moduleOptions.cookieConsentName, // the name of the Cookie Consent Cookie (secondary data)
|
277
322
|
disableLanguageSelector: moduleOptions.disableLanguageSelector, // disable language dropdown for translation in dialog (modal)
|
278
323
|
dialogContainerID: moduleOptions.dialogContainerID, // dest container, the dialog modal is loaded (dynamically)
|
@@ -286,7 +331,7 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
286
331
|
});
|
287
332
|
|
288
333
|
// enable|disable translation (after callback)
|
289
|
-
if (
|
334
|
+
if (user_translate.analysis && user_translate.personalization && user_translate.translationEnabled) {
|
290
335
|
if (moduleOptions.translatorName === 'google') {
|
291
336
|
head.appendChild(script);
|
292
337
|
if ($('google_translate_element')) {
|
@@ -302,12 +347,9 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
302
347
|
}
|
303
348
|
}
|
304
349
|
|
305
|
-
//
|
306
|
-
//
|
307
|
-
//
|
308
|
-
// logger.info('\n' + 'call default action');
|
309
|
-
// j1.translator.showDialog();
|
310
|
-
// });
|
350
|
+
// -------------------------------------------------------------------
|
351
|
+
// NOTE: Click events moved to Navigator (core)
|
352
|
+
// -------------------------------------------------------------------
|
311
353
|
|
312
354
|
_this.setState('finished');
|
313
355
|
logger.info('\n' + 'state: ' + _this.getState());
|
@@ -374,34 +416,37 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
374
416
|
|
375
417
|
// -------------------------------------------------------------------------
|
376
418
|
// cbGoogle()
|
377
|
-
// Called by the translator CORE module after the user made
|
378
|
-
// selection for a translation|language
|
419
|
+
// Called by the translator CORE module after the user has made
|
420
|
+
// the selection for a translation|language
|
379
421
|
// -------------------------------------------------------------------------
|
380
422
|
cbGoogle: function () {
|
381
423
|
var logger = log4javascript.getLogger('j1.adapter.translator.cbGoogle');
|
382
424
|
var cookie_names = j1.getCookieNames();
|
383
|
-
var user_state = j1.readCookie(cookie_names.user_state);
|
384
425
|
var user_consent = j1.readCookie(cookie_names.user_consent);
|
385
426
|
var user_translate = j1.readCookie(cookie_names.user_translate);
|
386
427
|
var msDropdown = document.getElementById('dropdownJSON').msDropdown;
|
428
|
+
var url = new liteURL(window.location.href);
|
429
|
+
var baseUrl = url.origin;;
|
430
|
+
var hostname = url.hostname;
|
431
|
+
var domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
432
|
+
var domain_enabled = '{{cookie_options.domain}}';
|
433
|
+
var same_site = '{{cookie_options.same_site}}';
|
434
|
+
|
387
435
|
var selectedTranslationLanguage;
|
388
436
|
var srcLang;
|
389
437
|
var destLang;
|
390
438
|
var transCode;
|
391
439
|
|
392
|
-
selectedTranslationLanguage = msDropdown.value;
|
393
|
-
logger.info('\n' + 'selected translation language: ' + selectedTranslationLanguage);
|
394
440
|
|
395
|
-
//
|
396
|
-
|
397
|
-
|
441
|
+
// set domain used by cookies
|
442
|
+
if (domain != hostname) {
|
443
|
+
cookie_domain = domain_enabled ? '.' + domain : hostname;
|
444
|
+
} else {
|
445
|
+
cookie_domain = hostname;
|
446
|
+
}
|
398
447
|
|
399
|
-
|
400
|
-
|
401
|
-
data: user_consent,
|
402
|
-
secure: secure,
|
403
|
-
expires: 365
|
404
|
-
});
|
448
|
+
selectedTranslationLanguage = msDropdown.value;
|
449
|
+
logger.info('\n' + 'selected translation language: ' + selectedTranslationLanguage);
|
405
450
|
|
406
451
|
// set content language
|
407
452
|
if (moduleOptions.contentLanguage === 'auto') {
|
@@ -427,8 +472,17 @@ j1.adapter['translator'] = (function (j1, window) {
|
|
427
472
|
Cookies.remove('googtrans', { domain: hostname });
|
428
473
|
Cookies.remove('googtrans');
|
429
474
|
|
430
|
-
//
|
431
|
-
|
475
|
+
// -----------------------------------------------------------------------
|
476
|
+
// NOTE: googtrans cookie will be rewritten (by Google!?) for
|
477
|
+
// attributes 'SameSite' and potentially 'Domain'. This results
|
478
|
+
// for 'SameSite' in an empty field!
|
479
|
+
// -----------------------------------------------------------------------
|
480
|
+
|
481
|
+
// write the googtrans cookie (w/o DOMAIN?!)
|
482
|
+
Cookies.set('googtrans', transCode, {
|
483
|
+
Domain: cookie_domain,
|
484
|
+
sameSite: 'Lax'
|
485
|
+
});
|
432
486
|
|
433
487
|
// reload current page (skip cache)
|
434
488
|
location.reload(true);
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
'use strict';
|
40
40
|
function CookieConsent(props) {
|
41
|
-
var logger = log4javascript.getLogger('j1.core.
|
41
|
+
var logger = log4javascript.getLogger('j1.core.CookieConsent');
|
42
42
|
var self = this;
|
43
43
|
var detailedSettingsShown = false;
|
44
44
|
var url = new liteURL(window.location.href);
|
@@ -56,14 +56,10 @@ function CookieConsent(props) {
|
|
56
56
|
dialogLanguage: 'content', // language used for the consent dialog (modal)
|
57
57
|
dialogLanguages: ['en','de'], // supported languages for the consent dialog (modal), defaults to first in array
|
58
58
|
contentURL: '/assets/data/cookieconsent', // URL contain the consent dialogs (modals) for ALL supported languages
|
59
|
-
cookieName: 'j1.user.translate', // name of the cookie, in which the configuration is stored
|
60
|
-
cookieStorageDays: 365, // duration the configuration cookie is stored on the client
|
61
59
|
postSelectionCallback: '', // callback function, called after the user has made his selection
|
62
60
|
whitelisted: [], // pages NO consent modal dialog is issued
|
63
61
|
xhrDataElement: 'consent-data', // src container for all language-specific consent dialogs (taken from contentURL)
|
64
|
-
dialogContainerID: 'consent-modal'
|
65
|
-
cookieSameSite: 'Lax', // restrict the consent cookie to first-party (do NOT send cookie to other domains)
|
66
|
-
cookieSecure: true
|
62
|
+
dialogContainerID: 'consent-modal' // dest container, the dialog modal is loaded (dynamically)
|
67
63
|
};
|
68
64
|
|
69
65
|
// merge property settings
|
@@ -87,7 +83,7 @@ function CookieConsent(props) {
|
|
87
83
|
this.props.cookieSecure = cookieSecure;
|
88
84
|
|
89
85
|
var Cookie = {
|
90
|
-
set: function (name, value, days, cookieSameSite, cookieSecure) {
|
86
|
+
set: function (name, value, days, cookieSameSite, cookieDomain, cookieSecure) {
|
91
87
|
var value_encoded = window.btoa(value);
|
92
88
|
var expires = '; expires=Thu, 01 Jan 1970 00:00:00 UTC';
|
93
89
|
if (days>0) {
|
@@ -96,9 +92,9 @@ function CookieConsent(props) {
|
|
96
92
|
expires = "; expires=" + date.toUTCString();
|
97
93
|
}
|
98
94
|
if (cookieSecure) {
|
99
|
-
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/;
|
95
|
+
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + cookieSameSite + '; ' + 'Domain=' + cookieDomain + '; ' + 'Secure=' + cookieSecure + ';';
|
100
96
|
} else {
|
101
|
-
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/;
|
97
|
+
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + cookieSameSite + ';' + 'Domain=' + cookieDomain + '; ';
|
102
98
|
}
|
103
99
|
},
|
104
100
|
get: function (name) {
|
@@ -319,20 +315,41 @@ function CookieConsent(props) {
|
|
319
315
|
}
|
320
316
|
|
321
317
|
function agreeAll() {
|
322
|
-
Cookie.set(
|
318
|
+
Cookie.set(
|
319
|
+
self.props.cookieName,
|
320
|
+
JSON.stringify(gatherOptions(true)),
|
321
|
+
self.props.cookieStorageDays,
|
322
|
+
self.props.cookieSameSite,
|
323
|
+
self.props.cookieDomain,
|
324
|
+
cookieSecure
|
325
|
+
);
|
323
326
|
self.$modal.modal('hide');
|
324
327
|
}
|
325
328
|
|
326
329
|
function doNotAgree() {
|
327
330
|
// Remove consent cookie
|
328
|
-
Cookie.set(
|
331
|
+
Cookie.set(
|
332
|
+
self.props.cookieName,
|
333
|
+
JSON.stringify(gatherOptions(false)),
|
334
|
+
0,
|
335
|
+
self.props.cookieSameSite,
|
336
|
+
self.props.cookieDomain,
|
337
|
+
cookieSecure
|
338
|
+
);
|
329
339
|
self.$modal.modal('hide');
|
330
340
|
// redirect to error page: blocked site
|
331
341
|
window.location.href = '/445.html';
|
332
342
|
}
|
333
343
|
|
334
344
|
function saveSettings() {
|
335
|
-
Cookie.set(
|
345
|
+
Cookie.set(
|
346
|
+
self.props.cookieName,
|
347
|
+
JSON.stringify(gatherOptions()),
|
348
|
+
self.props.cookieStorageDays,
|
349
|
+
self.props.cookieSameSite,
|
350
|
+
self.props.cookieDomain,
|
351
|
+
cookieSecure
|
352
|
+
);
|
336
353
|
self.$modal.modal('hide');
|
337
354
|
}
|
338
355
|
|
@@ -346,7 +363,6 @@ function CookieConsent(props) {
|
|
346
363
|
|
347
364
|
// API functions
|
348
365
|
// ---------------------------------------------------------------------------
|
349
|
-
|
350
366
|
logger.info('\n' + 'initializing core module finished');
|
351
367
|
logger.info('\n' + 'state: finished');
|
352
368
|
|
@@ -24,4 +24,4 @@
|
|
24
24
|
# outside of J1 Template!
|
25
25
|
# -----------------------------------------------------------------------------
|
26
26
|
*/
|
27
|
-
"use strict";function CookieConsent(d){var v=log4javascript.getLogger("j1.core.
|
27
|
+
"use strict";function CookieConsent(d){var v=log4javascript.getLogger("j1.core.CookieConsent");var p=this;var q=false;var e=new liteURL(window.location.href);var c=(e.protocol.includes("https"))?true:false;var j;var g;var t;v.info("\ninitializing core module: started");v.info("\nstate: started");this.props={autoShowDialog:true,dialogLanguage:"content",dialogLanguages:["en","de"],contentURL:"/assets/data/cookieconsent",postSelectionCallback:"",whitelisted:[],xhrDataElement:"consent-data",dialogContainerID:"consent-modal"};for(var f in d){this.props[f]=d[f]}if(this.props.dialogLanguage.indexOf("-")!==-1){this.props.dialogLanguage=this.props.dialogLanguage.split("-")[0]}if(!this.props.dialogLanguages.includes(this.props.dialogLanguage)){this.props.dialogLanguage=this.props.dialogLanguages[0]}this.props.xhrDataElement=this.props.xhrDataElement+"-"+this.props.dialogLanguage;this.props.cookieSecure=c;var h={set:function(w,C,E,z,D,A){var B=window.btoa(C);var x="; expires=Thu, 01 Jan 1970 00:00:00 UTC";if(E>0){var y=new Date();y.setTime(y.getTime()+(E*24*60*60*1000));x="; expires="+y.toUTCString()}if(A){document.cookie=w+"="+(B||"")+x+"; Path=/; SameSite="+z+"; Domain="+D+"; Secure="+A+";"}else{document.cookie=w+"="+(B||"")+x+"; Path=/; SameSite="+z+";Domain="+D+"; "}},get:function(x){var A=x+"=";var w=document.cookie.split(";");for(var y=0;y<w.length;y++){var C=w[y];while(C.charAt(0)===" "){C=C.substring(1,C.length)}if(C.indexOf(A)===0){var B=C.substring(A.length,C.length);var z=window.atob(B);return z}}return undefined}};var n={documentReady:function(w){if(document.readyState!=="loading"){w()}else{document.addEventListener("DOMContentLoaded",w)}}};function u(){var w={};var x=false;var y=0;var z=arguments.length;if(Object.prototype.toString.call(arguments[0])==="[object Boolean]"){x=arguments[0];y++}var B=function(C){for(var D in C){if(Object.prototype.hasOwnProperty.call(C,D)){if(x&&Object.prototype.toString.call(C[D])==="[object Object]"){w[D]=u(true,w[D],C[D])}else{w[D]=C[D]}}}};for(;y<z;y++){var A=arguments[y];B(A)}return w}function i(B,y){var w=Array.prototype.slice.call(arguments,2);var A=B.split(".");var z=A.pop();for(var x=0;x<A.length;x++){y=y[A[x]]}return y[z].apply(y,w)}function m(w){n.documentReady(function(){p.modal=document.getElementById(p.props.dialogContainerID);if(!p.modal){v.info("\nload consent modal");p.modal=document.createElement("div");p.modal.id=p.props.dialogContainerID;p.modal.style.display="none";p.modal.setAttribute("class","modal fade");p.modal.setAttribute("tabindex","-1");p.modal.setAttribute("role","dialog");p.modal.setAttribute("aria-labelledby",p.props.dialogContainerID);document.body.append(p.modal);p.$modal=$(p.modal);p.$modal.on("hidden.bs.modal",function(){i(p.props.postSelectionCallback,window)});var x=p.props.contentURL+"/index.html";$.get(x).done(function(y){v.info("\nloading consent modal: successfully");p.modal.innerHTML=y;p.modal.innerHTML=$("#"+p.props.xhrDataElement).eq(0).html();p.modal.style.display="block";$(p.modal).modal({backdrop:"static",keyboard:false});p.$buttonDoNotAgree=$("#bccs-buttonDoNotAgree");p.$buttonAgree=$("#bccs-buttonAgree");p.$buttonSave=$("#bccs-buttonSave");p.$buttonAgreeAll=$("#bccs-buttonAgreeAll");v.info("\nload/initialze options from cookie");l();k();$("#bccs-options").on("hide.bs.collapse",function(){q=false;l()}).on("show.bs.collapse",function(){q=true;l()});v.info("\ninitialze event handler");p.$buttonDoNotAgree.click(function(){b()});p.$buttonAgree.click(function(){o()});p.$buttonSave.click(function(){$("#bccs-options").collapse("hide");s();k()});p.$buttonAgreeAll.click(function(){$("#bccs-options").collapse("hide");o();k()});p.$modal.modal("show")}).fail(function(){v.error("\nloading consent modal: failed");v.warn("\nprobably no `contentURL` set")})}else{p.$modal.modal("show")}}.bind(this))}function k(){var y=p.getSettings();if(y){for(var x in y){var w=p.$modal.find("#bccs-options .bccs-option[data-name='"+x+"'] input[type='checkbox']");w.prop("checked",y[x])}}}function l(){if(q){p.$buttonDoNotAgree.hide();p.$buttonAgree.hide();p.$buttonSave.show();p.$buttonAgreeAll.show()}else{p.$buttonDoNotAgree.show();p.$buttonAgree.show();p.$buttonSave.hide();p.$buttonAgreeAll.hide()}}function a(x){var w=p.$modal.find("#bccs-options .bccs-option");var z={};for(var A=0;A<w.length;A++){var C=w[A];var y=C.getAttribute("data-name");if(y==="necessary"){z[y]=true}else{if(x===undefined){var B=$(C).find("input[type='checkbox']");z[y]=B.prop("checked")}else{z[y]=!!x}}}return z}function o(){h.set(p.props.cookieName,JSON.stringify(a(true)),p.props.cookieStorageDays,p.props.cookieSameSite,p.props.cookieDomain,c);p.$modal.modal("hide")}function b(){h.set(p.props.cookieName,JSON.stringify(a(false)),0,p.props.cookieSameSite,p.props.cookieDomain,c);p.$modal.modal("hide");window.location.href="/445.html"}function s(){h.set(p.props.cookieName,JSON.stringify(a()),p.props.cookieStorageDays,p.props.cookieSameSite,p.props.cookieDomain,c);p.$modal.modal("hide")}t=(this.props.whitelisted.indexOf(window.location.pathname)>-1);var r=h.get(this.props.cookieName);if((r===undefined||r==="false")&&this.props.autoShowDialog&&!t){m()}v.info("\ninitializing core module finished");v.info("\nstate: finished");this.showDialog=function(){t=(this.props.whitelisted.indexOf(window.location.pathname)>-1);if(!t){m()}};this.getSettings=function(x){var w=h.get(p.props.cookieName);if(w){var y=JSON.parse(h.get(p.props.cookieName));if(x===undefined){return y}else{if(y){return y[x]}else{return false}}}else{return undefined}}};
|
@@ -37,6 +37,46 @@ function Translator(props) {
|
|
37
37
|
var navigator_language;
|
38
38
|
var translation_language;
|
39
39
|
|
40
|
+
// ---------------------------------------------------------------------------
|
41
|
+
// Cookie()
|
42
|
+
// manage cookies
|
43
|
+
// ---------------------------------------------------------------------------
|
44
|
+
var Cookie = {
|
45
|
+
set: function (name, value, days, cookieSameSite, cookieDomain, cookieSecure) {
|
46
|
+
var value_encoded = window.btoa(value);
|
47
|
+
var expires = '; expires=Thu, 01 Jan 1970 00:00:00 UTC';
|
48
|
+
if (days>0) {
|
49
|
+
var date = new Date();
|
50
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
51
|
+
expires = "; expires=" + date.toUTCString();
|
52
|
+
}
|
53
|
+
if (cookieSecure) {
|
54
|
+
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + cookieSameSite + '; ' + 'Domain=' + cookieDomain + '; ' + 'Secure=' + cookieSecure + ';';
|
55
|
+
} else {
|
56
|
+
document.cookie = name + "=" + (value_encoded || '') + expires + '; Path=/; SameSite=' + cookieSameSite + ';' + 'Domain=' + cookieDomain + '; ';
|
57
|
+
}
|
58
|
+
},
|
59
|
+
get: function (name) {
|
60
|
+
var nameEQ = name + '=';
|
61
|
+
var ca = document.cookie.split(';');
|
62
|
+
for (var i = 0; i < ca.length; i++) {
|
63
|
+
var c = ca[i];
|
64
|
+
while (c.charAt(0) === ' ') {
|
65
|
+
c = c.substring(1, c.length);
|
66
|
+
}
|
67
|
+
if (c.indexOf(nameEQ) === 0) {
|
68
|
+
var value_encoded = c.substring(nameEQ.length, c.length);
|
69
|
+
var value = window.atob(value_encoded);
|
70
|
+
return value;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return undefined;
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
logger.info('\n' + 'initializing core module: started');
|
78
|
+
logger.info('\n' + 'state: started');
|
79
|
+
|
40
80
|
// ---------------------------------------------------------------------------
|
41
81
|
// default property settings
|
42
82
|
// ---------------------------------------------------------------------------
|
@@ -84,46 +124,33 @@ function Translator(props) {
|
|
84
124
|
logger.info('\n' + 'initializing core module: started');
|
85
125
|
logger.info('\n' + 'state: started');
|
86
126
|
|
87
|
-
|
88
|
-
|
89
|
-
|
127
|
+
var translationDefaultSettings = {
|
128
|
+
"translatorName": "google",
|
129
|
+
"translationEnabled": false,
|
130
|
+
"translateAllPages": true,
|
131
|
+
"useLanguageFromBrowser": true,
|
132
|
+
"translationLanguage": "de",
|
133
|
+
"analysis": true,
|
134
|
+
"personalization": true
|
135
|
+
};
|
136
|
+
|
137
|
+
var translatorCookie = Cookie.get(self.props.cookieName);
|
138
|
+
if (!translatorCookie) {
|
139
|
+
logger.info('\n' + 'initializing translator cookie: ' + self.props.cookieName);
|
140
|
+
// enable and write all settings required for translation (translation cookie)
|
141
|
+
Cookie.set(
|
142
|
+
self.props.cookieName,
|
143
|
+
JSON.stringify(translationDefaultSettings),
|
144
|
+
self.props.cookieStorageDays,
|
145
|
+
self.props.cookieSameSite,
|
146
|
+
self.props.cookieDomain,
|
147
|
+
self.props.cookieSecure
|
148
|
+
);
|
149
|
+
}
|
90
150
|
|
91
151
|
// ---------------------------------------------------------------------------
|
92
|
-
//
|
93
|
-
// manage cookies
|
152
|
+
// internal functions
|
94
153
|
// ---------------------------------------------------------------------------
|
95
|
-
var Cookie = {
|
96
|
-
set: function (name, value, days, samesite, secure) {
|
97
|
-
var value_encoded = window.btoa(value);
|
98
|
-
var expires = '';
|
99
|
-
if (days) {
|
100
|
-
var date = new Date();
|
101
|
-
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
102
|
-
expires = '; expires=' + date.toUTCString();
|
103
|
-
}
|
104
|
-
if (secure) {
|
105
|
-
document.cookie = name + '=' + (value_encoded || '') + expires + '; Path=/; SameSite=' + samesite + '; ' + 'secure=' + secure + ';';
|
106
|
-
} else {
|
107
|
-
document.cookie = name + '=' + (value_encoded || '') + expires + '; Path=/; SameSite=' + samesite + ';';
|
108
|
-
}
|
109
|
-
},
|
110
|
-
get: function (name) {
|
111
|
-
var nameEQ = name + '=';
|
112
|
-
var ca = document.cookie.split(';');
|
113
|
-
for (var i = 0; i < ca.length; i++) {
|
114
|
-
var c = ca[i];
|
115
|
-
while (c.charAt(0) === ' ') {
|
116
|
-
c = c.substring(1, c.length);
|
117
|
-
}
|
118
|
-
if (c.indexOf(nameEQ) === 0) {
|
119
|
-
var value_encoded = c.substring(nameEQ.length, c.length);
|
120
|
-
var value = window.atob(value_encoded);
|
121
|
-
return value;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
return undefined;
|
125
|
-
}
|
126
|
-
};
|
127
154
|
|
128
155
|
// ---------------------------------------------------------------------------
|
129
156
|
// global event handler
|
@@ -486,11 +513,15 @@ function Translator(props) {
|
|
486
513
|
// On 'agreeAll', enable ALL settings required for translation
|
487
514
|
// ---------------------------------------------------------------------------
|
488
515
|
function agreeAll() {
|
489
|
-
var
|
490
|
-
var
|
516
|
+
var consentSettings = JSON.parse(Cookie.get(self.props.cookieConsentName));
|
517
|
+
var translationSettings = {};
|
491
518
|
|
492
|
-
// enable
|
493
|
-
|
519
|
+
// enable all settings required for translation
|
520
|
+
translationSettings.analysis = true;
|
521
|
+
translationSettings.personalization = true;
|
522
|
+
translationSettings.translationEnabled = true;
|
523
|
+
|
524
|
+
// overload user consent settings (consent cookie)
|
494
525
|
consentSettings.analysis = translationSettings.analysis;
|
495
526
|
consentSettings.personalization = translationSettings.personalization;
|
496
527
|
|
@@ -498,17 +529,19 @@ function Translator(props) {
|
|
498
529
|
self.props.cookieConsentName,
|
499
530
|
JSON.stringify(consentSettings),
|
500
531
|
self.props.cookieStorageDays,
|
501
|
-
self.props.
|
502
|
-
self.props.
|
532
|
+
self.props.cookieSameSite,
|
533
|
+
self.props.cookieDomain,
|
534
|
+
self.props.cookieSecure
|
503
535
|
);
|
504
536
|
|
505
|
-
//
|
537
|
+
// write all settings required for translation (translation cookie)
|
506
538
|
Cookie.set(
|
507
539
|
self.props.cookieName,
|
508
540
|
JSON.stringify(translationSettings),
|
509
541
|
self.props.cookieStorageDays,
|
510
|
-
self.props.
|
511
|
-
self.props.
|
542
|
+
self.props.cookieSameSite,
|
543
|
+
self.props.cookieDomain,
|
544
|
+
self.props.cookieSecure
|
512
545
|
);
|
513
546
|
|
514
547
|
self.$modal.modal('hide');
|
@@ -519,15 +552,17 @@ function Translator(props) {
|
|
519
552
|
// process current settings from checkboxes for button `doNotAgree`
|
520
553
|
// ---------------------------------------------------------------------------
|
521
554
|
function doNotAgree() {
|
522
|
-
var
|
555
|
+
var translationSettings = gatherOptions();
|
523
556
|
|
524
|
-
settings
|
557
|
+
// disable all settings required for translation (translation cookie)
|
558
|
+
translationSettings.translationEnabled = false;
|
525
559
|
Cookie.set(
|
526
560
|
self.props.cookieName,
|
527
|
-
JSON.stringify(
|
561
|
+
JSON.stringify(translationSettings),
|
528
562
|
self.props.cookieStorageDays,
|
529
|
-
self.props.
|
530
|
-
self.props.
|
563
|
+
self.props.cookieSameSite,
|
564
|
+
self.props.cookieDomain,
|
565
|
+
self.props.cookieSecure
|
531
566
|
);
|
532
567
|
self.$modal.modal('hide');
|
533
568
|
}
|
@@ -537,29 +572,29 @@ function Translator(props) {
|
|
537
572
|
// write current settings from checkboxes to cookie
|
538
573
|
// ---------------------------------------------------------------------------
|
539
574
|
function saveSettings() {
|
540
|
-
var
|
541
|
-
var consentSettings
|
575
|
+
var translationSettings = gatherOptions();
|
576
|
+
var consentSettings = JSON.parse(Cookie.get(self.props.cookieConsentName));
|
542
577
|
|
543
578
|
// update all cookies required for (google-)translation
|
544
579
|
//
|
545
|
-
|
546
|
-
consentSettings
|
547
|
-
consentSettings.analysis = settings.analysis;
|
548
|
-
consentSettings.personalization = settings.personalization;
|
580
|
+
consentSettings.analysis = translationSettings.analysis;
|
581
|
+
consentSettings.personalization = translationSettings.personalization;
|
549
582
|
|
550
583
|
Cookie.set(
|
551
584
|
self.props.cookieConsentName,
|
552
585
|
JSON.stringify(consentSettings),
|
553
586
|
self.props.cookieStorageDays,
|
554
|
-
self.props.
|
555
|
-
self.props.
|
587
|
+
self.props.cookieSameSite,
|
588
|
+
self.props.cookieDomain,
|
589
|
+
self.props.cookieSecure
|
556
590
|
);
|
557
591
|
Cookie.set(
|
558
592
|
self.props.cookieName,
|
559
|
-
JSON.stringify(
|
593
|
+
JSON.stringify(translationSettings),
|
560
594
|
self.props.cookieStorageDays,
|
561
|
-
self.props.
|
562
|
-
self.props.
|
595
|
+
self.props.cookieSameSite,
|
596
|
+
self.props.cookieDomain,
|
597
|
+
self.props.cookieSecure
|
563
598
|
);
|
564
599
|
self.$modal.modal('hide');
|
565
600
|
}
|