| 1 | {{- $cfg := .Site.Data.cookieconsent -}} |
| 2 | {{- $cfgJSON := $cfg | jsonify -}} |
| 3 | {{- $cfgJSON = replace $cfgJSON "__PRIVACY_URL__" ("privacy/" | relURL) -}} |
| 4 | <link rel="stylesheet" href="{{ "vendor/cookieconsent/cookieconsent.css" | relURL }}"> |
| 5 | <script> |
| 6 | window.SquadScopeCookieConsent = {{ $cfgJSON | safeJS }}; |
| 7 | </script> |
| 8 | <script> |
| 9 | (function () { |
| 10 | var script = document.createElement('script'); |
| 11 | script.src = '{{ "vendor/cookieconsent/cookieconsent.umd.js" | relURL }}'; |
| 12 | script.async = true; |
| 13 | script.onload = function () { |
| 14 | var cfg = window.SquadScopeCookieConsent || {}; |
| 15 | |
| 16 | function reviveCookiePattern(cookie) { |
| 17 | if (!cookie || typeof cookie.name !== 'string') return cookie; |
| 18 | var match = cookie.name.match(/^\/(.*)\/([gimsuy]*)$/); |
| 19 | if (!match) return cookie; |
| 20 | |
| 21 | return Object.assign({}, cookie, { |
| 22 | name: new RegExp(match[1], match[2]) |
| 23 | }); |
| 24 | } |
| 25 | |
| 26 | function reviveCookiePatterns(categories) { |
| 27 | Object.keys(categories || {}).forEach(function (categoryName) { |
| 28 | var category = categories[categoryName]; |
| 29 | if (category.autoClear && Array.isArray(category.autoClear.cookies)) { |
| 30 | category.autoClear.cookies = category.autoClear.cookies.map(reviveCookiePattern); |
| 31 | } |
| 32 | |
| 33 | Object.keys(category.services || {}).forEach(function (serviceName) { |
| 34 | var service = category.services[serviceName]; |
| 35 | if (Array.isArray(service.cookies)) { |
| 36 | service.cookies = service.cookies.map(reviveCookiePattern); |
| 37 | } |
| 38 | }); |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | reviveCookiePatterns(cfg.categories); |
| 43 | |
| 44 | CookieConsent.run(Object.assign({ |
| 45 | mode: 'opt-in', |
| 46 | revision: 1, |
| 47 | hideFromBots: false, |
| 48 | manageScriptTags: true, |
| 49 | cookie: { |
| 50 | name: 'squadscope_cookie_consent', |
| 51 | sameSite: 'Lax', |
| 52 | expiresAfterDays: 182 |
| 53 | }, |
| 54 | guiOptions: { |
| 55 | consentModal: { |
| 56 | layout: 'cloud inline', |
| 57 | position: 'bottom center', |
| 58 | equalWeightButtons: true, |
| 59 | flipButtons: false |
| 60 | }, |
| 61 | preferencesModal: { |
| 62 | layout: 'box', |
| 63 | equalWeightButtons: true, |
| 64 | flipButtons: false |
| 65 | } |
| 66 | } |
| 67 | }, cfg)); |
| 68 | }; |
| 69 | document.head.appendChild(script); |
| 70 | })(); |
| 71 | </script> |