PageSourceSearch

https://www.philpenman.com/lib/g/2.0/scripts/artlogic_modules/gall…=a084b1f&g=aac226233bd4ebc9fc075ea7f1bcd440

js philpenman.com collected 2026-09-28 12:32:19 UTC 9,576 bytes, 265 lines download raw bytes

1var cookie_notification = {
2
3  init: function () {
4      var cookie_settings = {
5          time_to_wait: 2000
6      };
7      var custom_cookie_settings = $('#cookie_notification').data('cookie-notification-settings') || {};
8      $.extend(cookie_settings, custom_cookie_settings);
9
10      $('#cookie_notification').each(function () {
11          var mode = 'notify';
12          if ($(this).attr('data-mode')){
13              mode = $(this).attr('data-mode');
14          }
15          if(mode == 'consent'){
16              var has_preferences = window.galleries.cookie_notification.get_cookie_preferences();
17              if(!has_preferences){
18                  // Display the cookie notification after a set amount of time
19                  setTimeout(function () {
20                      $('#cookie_notification').addClass('active')
21                  }, cookie_settings.time_to_wait)
22
23                  // Accept btn event listener
24                  $('#cookie_notification_accept').click(
25                      window.galleries.cookie_notification.cookie_consent_accept_btn_callback
26                  );
27
28                  // Reject btn event listener
29                  $('#cookie_notification_reject').click(
30                      window.galleries.cookie_notification.cookie_consent_reject_btn_callback
31                  );
32
33                  window.galleries.cookie_notification.manage_cookies_popup.init();
34              }
35              else {
36                  $(this).hide();
37              }
38              
39          } else {
40              var notification_cookie = h.getCookie('cookie_notification_dismissed');
41              if (!notification_cookie) {
42                  // Display the cookie notification after a set amount of time
43                  setTimeout(function () {
44                      $('#cookie_notification').addClass('active')
45                  }, cookie_settings.time_to_wait)
46
47                  // Accept btn event listener
48                  $('#cookie_notification_accept').click(
49                      window.galleries.cookie_notification.cookie_notification_accept_btn_callback
50                  );
51
52              }
53              else {
54                  $(this).hide();
55              }
56          }
57          
58      });
59
60      
61  },
62
63  cookie_notification_accept_btn_callback: function (e) {
64      h.setCookie('cookie_notification_dismissed', '1', 365);
65      /* Display:none the banner once it's transformed off the screen 
66          - do this instead of $.hide because it's janky */
67      $('#cookie_notification').on('transitionend', function (te) {
68          if (te.originalEvent.propertyName == 'transform') {
69              $('#cookie_notification').hide();
70          }
71      });
72      $('#cookie_notification').removeClass('active');
73      e.preventDefault();
74  },
75
76  cookie_consent_accept_btn_callback: function (e) {
77
78      // Set all cookie consent options to true as they have accepted all
79      var cookie_consent = {
80          'essential': true,
81          'functionality': true,
82          'statistics': true,
83          'marketing': true
84      }
85
86      // h.setCookie('cookie_consent', JSON.stringify(cookie_consent), 365);
87      window.galleries.cookie_notification.set_cookie_preferences(
88        cookie_consent
89      );
90      window.galleries.cookie_notification.hide_cookie_notification_banner();
91      e.preventDefault();
92  },
93
94  cookie_consent_reject_btn_callback: function (e) {
95
96      // Set only essential cookies to true, reject all others
97      var cookie_consent = {
98          'essential': true,
99          'functionality': false,
100          'statistics': false,
101          'marketing': false
102      }
103
104      window.galleries.cookie_notification.set_cookie_preferences(
105        cookie_consent
106      );
107      window.galleries.cookie_notification.hide_cookie_notification_banner();
108      e.preventDefault();
109  },
110
111  hide_cookie_notification_banner: function (e) {
112      
113      /* Display:none the banner once it's transformed off the screen 
114          - do this instead of $.hide because it's janky */
115      $('#cookie_notification').on('transitionend', function (te) {
116          if (te.originalEvent.propertyName == 'transform') {
117              $('#cookie_notification').hide();
118          }
119      });
120      $('#cookie_notification').removeClass('active');
121      
122  },
123
124  set_cookie_preferences: function (cookie_preferences) {
125
126      if (g.has_local_storage()) {
127          var today = new Date();
128          today = today.toISOString().substr(0, 10);
129          cookie_preferences['date'] = today;
130          localStorage.setItem(
131              "cookie_preferences",
132              JSON.stringify(cookie_preferences)
133          );
134          var update_consent = {}
135          for (const [key, value] of Object.entries(cookie_preferences)) {
136            if (key == 'date') continue;
137            if (value == true) update_consent[key] = 'granted'
138            if (key == 'marketing' && value == true) {
139                update_consent['ad_storage'] = 'granted'
140                update_consent['ad_user_data'] = 'granted'
141                update_consent['ad_personalization'] = 'granted'
142                update_consent['analytics_storage'] = 'granted'
143            }
144          }
145          
146          if (window.gtag) {
147            gtag('consent', 'update', update_consent)
148          }
149
150          window.archimedes.archimedes_core.analytics.track_campaigns.init();
151      }
152
153  },
154
155  get_cookie_preferences: function(){
156      var result = false;
157      if(g.has_local_storage()){
158          var cookie_preferences = localStorage.getItem('cookie_preferences') || "";
159          if (cookie_preferences) {
160              cookie_preferences = JSON.parse(cookie_preferences);
161              if (cookie_preferences.date) {
162                  var expires_on = new Date(cookie_preferences.date);
163                  expires_on.setDate(expires_on.getDate() + 365);
164                //   console.log('cookie preferences expire on', expires_on.toISOString());
165                  var valid = expires_on > new Date();
166                  if (valid){
167                      result = cookie_preferences;
168                  }
169              }
170          }
171      }
172      return result;
173  },
174
175  get_cookie_preference: function (category) {
176      var result = false;
177      try {
178          var cookie_preferences = localStorage.getItem('cookie_preferences') || "";
179          if (cookie_preferences) {
180              cookie_preferences = JSON.parse(cookie_preferences);
181              if (cookie_preferences.date) {
182                  var expires_on = new Date(cookie_preferences.date);
183                  expires_on.setDate(expires_on.getDate() + 365);
184                //   console.log('cookie preferences expire on', expires_on.toISOString());
185                  var valid = expires_on > new Date();
186                  if (valid && cookie_preferences.hasOwnProperty(category) && cookie_preferences[category]) {
187                      result = true;
188                  }
189              }
190          }
191      }
192      catch(e) {
193          console.warn('get_cookie_preference() failed');
194          return result;
195      }
196      console.log('cookie preference', category, result);
197      return result;
198  },
199
200  manage_cookies_popup: {
201
202      init: function(){
203
204          $('#cookie_notification_preferences').off()
205              .click(function () {
206                  window.galleries.cookie_notification.manage_cookies_popup.open();
207              });
208
209          $('#manage_cookie_preferences_close_popup_link a, #manage_cookie_preferences_popup_overlay')
210              .off()
211              .click(function () {
212                  window.galleries.cookie_notification.manage_cookies_popup.close(true);
213                  return false;
214              })
215              ;
216
217
218          $('#cookie_preferences_form').submit(function(e){
219              e.preventDefault();
220              var cookie_consent = {};
221              $('input', this).not(':input[type=button], :input[type=submit], :input[type=reset]').each(function(){
222                  cookie_consent[$(this).attr('name')] = $(this).prop('checked') ? true : false;
223              });
224              window.galleries.cookie_notification.set_cookie_preferences(cookie_consent);
225              window.galleries.cookie_notification.manage_cookies_popup.close(false);
226          }); 
227
228      },
229
230      open: function(){
231          $('body').addClass('manage_cookie_preferences_popup_active');
232          $('#cookie_notification').removeClass('active');
233          setTimeout(function () {
234              $('body').addClass('manage_cookie_preferences_popup_visible');
235              h.accessibility.on_popup_opening($('#manage_cookie_preferences_popup_box'), false, '#manage_cookie_preferences_close_popup_link a');
236              window.galleries.cookie_notification.manage_cookies_popup.after_popup();
237          }, 50);
238      },
239
240      close: function(reopen_notification){
241          $('body').removeClass('manage_cookie_preferences_popup_visible');
242          setTimeout(function () {
243              $('body').removeClass('manage_cookie_preferences_popup_active');
244              if(reopen_notification){
245                  $('#cookie_notification').addClass('active');
246              }
247              else {
248                  window.galleries.cookie_notification.hide_cookie_notification_banner();
249              }
250          }, 400);
251
252          h.accessibility.on_popup_closing();
253      },
254
255      after_popup: function(){
256
257      }
258
259  }
260  
261}
262
263window.galleries = window.galleries || {};
264window.galleries.cookie_notification = cookie_notification;
265export default cookie_notification;

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.