PageSourceSearch

https://www.openstack.org/themes/openstack/javascript/filetracking.jquery.js?m=1790782113

js openstack.org collected 2026-10-01 08:04:30 UTC 2,432 bytes, 59 lines download raw bytes

1/**
2 * Copyright 2014 Openstack Foundation
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 **/
13(function( $ ){
14
15    var filetypes = /[\./](zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
16
17    var methods = {
18        init : function(options) {
19            var baseHref = '';
20            if ($('base').attr('href') != undefined)
21                baseHref = $('base').attr('href');
22                $('a').each(function() {
23                    var href = $(this).attr('href');
24                    if (href && href.match(filetypes)) {
25                            $(this).on("click",function() {
26                            var extension = (/[\./]/.exec(href)) ? /[^\./]+$/.exec(href) : undefined;
27                            var filePath = href;
28
29                            ga('send', 'event', {
30                                    eventCategory: 'Download',
31                                    eventAction:  'Click - ' + extension,
32                                    eventLabel:filePath
33                            });
34
35                            if ($(this).attr('target') != undefined && $(this).attr('target').toLowerCase() != '_blank') {
36                                setTimeout(function() { location.href = baseHref + href; }, 200);
37                                return false;
38                            }
39                        });
40                    }
41             });
42        }
43    };
44
45    $.fn.filetracking = function(methodOrOptions) {
46        if ( methods[methodOrOptions] ) {
47            return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
48        } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
49            // Default to "init"
50            return methods.init.apply( this, arguments );
51        } else {
52            $.error( 'Method ' +  method + ' does not exist on jQuery.filetracking' );
53        }
54    };
55
56    //helper functions
57
58// End of closure.
59}( 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.