PageSourceSearch

https://asso-resonance.surge.sh/public/assets/js/cookiechoices.js

js asso-resonance.surge.sh collected 2026-10-03 14:55:46 UTC 6,320 bytes, 174 lines download raw bytes

1/*
2 Copyright 2014 Google Inc. All rights reserved.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17(function(window) {
18
19  if (!!window.cookieChoices) {
20    return window.cookieChoices;
21  }
22
23  var document = window.document;
24  // IE8 does not support textContent, so we should fallback to innerText.
25  var supportsTextContent = 'textContent' in document.body;
26
27  var cookieChoices = (function() {
28
29    var cookieName = 'displayCookieConsent';
30    var cookieConsentId = 'cookieChoiceInfo';
31    var dismissLinkId = 'cookieChoiceDismiss';
32
33    function _createHeaderElement(cookieText, dismissText, linkText, linkHref) {
34      var butterBarStyles = 'position:fixed;width:100%;background-color:#d1eeeb;color:#000000;' +
35          'margin:0; left:0; bottom:0; padding:10px;z-index:1000;text-align:center;';
36
37      var cookieConsentElement = document.createElement('div');
38      cookieConsentElement.id = cookieConsentId;
39      cookieConsentElement.style.cssText = butterBarStyles;
40      cookieConsentElement.appendChild(_createConsentText(cookieText));
41
42			      if (!!linkText && !!linkHref) {
43        cookieConsentElement.appendChild(_createInformationLink(linkText, linkHref));
44      }
45      cookieConsentElement.appendChild(_createDismissLink(dismissText));
46			      
47      return cookieConsentElement;
48    }
49
50    function _createDialogElement(cookieText, dismissText, linkText, linkHref) {
51      var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' +
52          'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' +
53          'background-color:#ccc;';
54      var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%';
55      var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' +
56          'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;';
57
58      var cookieConsentElement = document.createElement('div');
59      cookieConsentElement.id = cookieConsentId;
60
61      var glassPanel = document.createElement('div');
62      glassPanel.style.cssText = glassStyle;
63
64      var content = document.createElement('div');
65      content.style.cssText = contentStyle;
66
67      var dialog = document.createElement('div');
68      dialog.style.cssText = dialogStyle;
69
70      var dismissLink = _createDismissLink(dismissText);
71      dismissLink.style.display = 'block';
72      dismissLink.style.textAlign = 'right';
73      dismissLink.style.marginTop = '8px';
74
75      content.appendChild(_createConsentText(cookieText));
76      if (!!linkText && !!linkHref) {
77        content.appendChild(_createInformationLink(linkText, linkHref));
78      }
79      content.appendChild(dismissLink);
80      dialog.appendChild(content);
81      cookieConsentElement.appendChild(glassPanel);
82      cookieConsentElement.appendChild(dialog);
83      return cookieConsentElement;
84    }
85
86    function _setElementText(element, text) {
87      if (supportsTextContent) {
88        element.textContent = text;
89      } else {
90        element.innerText = text;
91      }
92    }
93
94    function _createConsentText(cookieText) {
95      var consentText = document.createElement('span');
96      _setElementText(consentText, cookieText);
97      return consentText;
98    }
99
100    function _createDismissLink(dismissText) {
101      var dismissLink = document.createElement('a');
102      _setElementText(dismissLink, dismissText);
103      dismissLink.id = dismissLinkId;
104      dismissLink.href = '#';
105      dismissLink.style.marginLeft = '15px';
106      dismissLink.style.color = '#000000';
107      return dismissLink;
108    }
109
110    function _createInformationLink(linkText, linkHref) {
111      var infoLink = document.createElement('a');
112      _setElementText(infoLink, linkText);
113      infoLink.href = linkHref;
114      infoLink.target = '_blank';
115      infoLink.style.marginLeft = '15px';
116      infoLink.style.color = '#000000';
117      return infoLink;
118    }
119
120    function _dismissLinkClick() {
121      _saveUserPreference();
122      _removeCookieConsent();
123      return false;
124    }
125
126    function _showCookieConsent(cookieText, dismissText, linkText, linkHref, isDialog) {
127      if (_shouldDisplayConsent()) {
128        _removeCookieConsent();
129        var consentElement = (isDialog) ?
130            _createDialogElement(cookieText, dismissText, linkText, linkHref) :
131            _createHeaderElement(cookieText, dismissText, linkText, linkHref);
132        var fragment = document.createDocumentFragment();
133        fragment.appendChild(consentElement);
134        document.body.appendChild(fragment.cloneNode(true));
135        document.getElementById(dismissLinkId).onclick = _dismissLinkClick;
136      }
137    }
138
139    function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) {
140      _showCookieConsent(cookieText, dismissText, linkText, linkHref, false);
141    }
142
143    function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) {
144      _showCookieConsent(cookieText, dismissText, linkText, linkHref, true);
145    }
146
147    function _removeCookieConsent() {
148      var cookieChoiceElement = document.getElementById(cookieConsentId);
149      if (cookieChoiceElement != null) {
150        cookieChoiceElement.parentNode.removeChild(cookieChoiceElement);
151      }
152    }
153
154    function _saveUserPreference() {
155      // Set the cookie expiry to one year after today.
156      var expiryDate = new Date();
157      expiryDate.setFullYear(expiryDate.getFullYear() + 1);
158      document.cookie = cookieName + '=y; path=/; expires=' + expiryDate.toGMTString();
159    }
160
161    function _shouldDisplayConsent() {
162      // Display the header only if the cookie has not been set.
163      return !document.cookie.match(new RegExp(cookieName + '=([^;]+)'));
164    }
165
166    var exports = {};
167    exports.showCookieConsentBar = showCookieConsentBar;
168    exports.showCookieConsentDialog = showCookieConsentDialog;
169    return exports;
170  })();
171
172  window.cookieChoices = cookieChoices;
173  return cookieChoices;
174})(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.