PageSourceSearch

https://www.neste.ee/sites/all/modules/contrib/cache_control/cache_control.js?tlthv2

js neste.ee collected 2026-09-26 13:57:38 UTC 5,395 bytes, 139 lines download raw bytes

1(function ($) {
2  Drupal.cacheControl = {};
3  Drupal.cacheControl.initialized = false;
4
5  Drupal.cacheControl.componentHandlers = [];
6  Drupal.cacheControl.componentsFinishedHandlers = [];
7
8  Drupal.behaviors.cacheControl = {
9    attach: function(context, settings) {
10      if (Drupal.cacheControl.initialized) {
11        //There's no need to ever execute this more than once per pageload
12        return;
13      }
14      Drupal.cacheControl.initialized = true;
15
16      if (settings.cacheControl) {
17        var cacheNodeId = settings.cacheControl.cacheNodeId;
18
19        var force = settings.cacheControl.force || false;
20        var authenticated = parseInt($.cookie('cacheControlAuthenticated'), 10);
21
22        if (authenticated || force) {
23          var path = settings.basePath + "_cache_control/get_components?_q=" + settings.cacheControl.q
24          if (settings.cacheControl.query) {
25            path += "&" + settings.cacheControl.query;
26          }
27
28          $.getJSON(path, function(data) {
29            //Inject components into DOM
30
31            if (data.settings) {
32              //If some components delivered settings, take them into use.
33              jQuery.extend(Drupal.settings, data.settings);
34            }
35
36            for (var i in data.components) if (data.components.hasOwnProperty(i)) {
37              var elem = $(data.components[i]);
38              elem.addClass('cacheControlProcessed');
39
40              if (settings.cacheControl.devMode) {
41            	 elem.addClass('cacheControlDev');
42              }
43
44              var id = elem.attr("id");
45
46              //Remove the anonymous content to avoid conflicts
47              var anonymousElement = $("#" + id + "-anonymous");
48              var placeholderElement = $("#" + id);
49              Drupal.detachBehaviors(anonymousElement);
50
51              if (placeholderElement.length > 0) {
52                anonymousElement.remove();
53                Drupal.detachBehaviors(placeholderElement);
54                placeholderElement.replaceWith(elem);
55              }
56              else {
57                anonymousElement.replaceWith(elem);
58              }
59            }
60
61            //Some JS components may need initializing
62            for (var b in Drupal.behaviors) if (Drupal.behaviors.hasOwnProperty(b)) {
63              if (b !== 'cacheControl' && typeof Drupal.behaviors[b].attach === 'function') {
64                Drupal.behaviors[b].attach($('.cacheControlProcessed'), Drupal.settings);
65              }
66            }
67
68            //Give modules/themes (usually themes) a chance to react to the fact that the page is now completely ready.
69            var finishHandlers = Drupal.cacheControl.componentsFinishedHandlers;
70            for (var i = 0; i < finishHandlers.length; i++) {
71              var handler = finishHandlers[i];
72              if (typeof handler == 'function') {
73                handler();
74              }
75            }
76          });
77
78        }
79
80        if (!authenticated) {
81          //Bring up anonymous content
82          $(".cacheControlAnonymous").each(function() {
83            var id = $(this).attr('id').replace(/-anonymous$/, '');
84
85            if ($("#" + id).length > 0) {
86              $("#" + id).replaceWith($(this));
87            }
88            $(this).attr('id', id);
89            $(this).removeClass('cacheControlAnonymous');
90
91            if (settings.cacheControl.devMode) {
92              $(this).addClass('cacheControlDev');
93            }
94          });
95
96          //If needed, process forms with captcha
97          if (settings.cacheControl.processAnonymousCaptchaForms) {
98            $("input[name=captcha_response]").each(function() {
99              var form = $(this).parents('form');
100              if (!form.hasClass('cacheControlProcessedForm')) {
101                form.addClass('cacheControlProcessedForm');
102                var formBuildId = form.find('input[name=form_build_id]').val();
103
104                //Add a focus event handler that silently and hopefully unobtrusively rebuilds the form in the background
105                form.find('*').focus(function() {
106                  //store focused element id so that we can restore focus when the form has been re-rendered
107                  var focusedId = $(this).attr("id");
108
109                  $.get(Drupal.settings.basePath + "_cache_control/rebuild_form/" + formBuildId, function(data) {
110                    var currentContent = $("#" + focusedId).val();
111                    var newForm = $(data);
112                    form.replaceWith(newForm);
113
114                    //Some JS components may need initializing
115                    for (var b in Drupal.behaviors) if (Drupal.behaviors.hasOwnProperty(b)) {
116                      if (b !== 'cacheControl' && typeof Drupal.behaviors[b].attach === 'function') {
117                        Drupal.behaviors[b].attach(newForm, Drupal.settings);
118                      }
119                    }
120
121                    //For improved user experience
122                    $("#" + focusedId)
123                      .val(currentContent)
124                      .focus();
125                  });
126                });
127              }
128            });
129          }
130
131          //Further, track statistics for an anonymous user if so requested
132          if (cacheNodeId) {
133            $.get(Drupal.settings.basePath + "cache_control_statistics_tracker.php?nid=" + cacheNodeId);
134          }
135        }
136      }
137    }
138  };
139})(jQuery);

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.