PageSourceSearch

https://www.comodo.it/blog/wp-content/themes/comodo/assets/js/svgxuse.js?ver=d4a899b51dd9b5f4d9811369ecab96db

js comodo.it collected 2026-10-02 13:22:17 UTC 9,440 bytes, 215 lines download raw bytes

vendor: 5,917 bytes, lines 1-141
1/*!
2 * @copyright Copyright (c) 2016 IcoMoon.io
3 * @license   Licensed under MIT license
4 *            See https://github.com/Keyamoon/svgxuse
5 * @version   1.1.23
6 */
7/*jslint browser: true */
8/*global XDomainRequest, MutationObserver, window */
9(function () {
10    'use strict';
11    if (window && window.addEventListener) {
12        var cache = Object.create(null); // holds xhr objects to prevent multiple requests
13        var checkUseElems;
14        var tid; // timeout id
15        var debouncedCheck = function () {
16            clearTimeout(tid);
17            tid = setTimeout(checkUseElems, 100);
18        };
19        var unobserveChanges = function () {
20            return;
21        };
22        var observeChanges = function () {
23            var observer;
24            window.addEventListener('resize', debouncedCheck, false);
25            window.addEventListener('orientationchange', debouncedCheck, false);
26            if (window.MutationObserver) {
27                observer = new MutationObserver(debouncedCheck);
28                observer.observe(document.documentElement, {
29                    childList: true,
30                    subtree: true,
31                    attributes: true
32                });
33                unobserveChanges = function () {
34                    try {
35                        observer.disconnect();
36                        window.removeEventListener('resize', debouncedCheck, false);
37                        window.removeEventListener('orientationchange', debouncedCheck, false);
38                    } catch (ignore) {}
39                };
40            } else {
41                document.documentElement.addEventListener('DOMSubtreeModified', debouncedCheck, false);
42                unobserveChanges = function () {
43                    document.documentElement.removeEventListener('DOMSubtreeModified', debouncedCheck, false);
44                    window.removeEventListener('resize', debouncedCheck, false);
45                    window.removeEventListener('orientationchange', debouncedCheck, false);
46                };
47            }
48        };
49        var createRequest = function (url) {
50            // In IE 9, cross origin requests can only be sent using XDomainRequest.
51            // XDomainRequest would fail if CORS headers are not set.
52            // Therefore, XDomainRequest should only be used with cross origin requests.
53            function getOrigin(loc) {
54                var a;
55                if (loc.protocol !== undefined) {
56                    a = loc;
57                } else {
58                    a = document.createElement('a');
59                    a.href = loc;
60                }
61                return a.protocol.replace(/:/g, '') + a.host;
62            }
63            var Request;
64            var origin;
65            var origin2;
66            if (window.XMLHttpRequest) {
67                Request = new XMLHttpRequest();
68                origin = getOrigin(location);
69                origin2 = getOrigin(url);
70                if (Request.withCredentials === undefined && origin2 !== '' && origin2 !== origin) {
71                    Request = XDomainRequest || undefined;
72                } else {
73                    Request = XMLHttpRequest;
74                }
75            }
76            return Request;
77        };
78        var xlinkNS = 'http://www.w3.org/1999/xlink';
79        checkUseElems = function () {
80            var base;
81            var bcr;
82            var fallback = ''; // optional fallback URL in case no base path to SVG file was given and no symbol definition was found.
83            var hash;
84            var href;
85            var i;
86            var inProgressCount = 0;
87            var isHidden;
88            var Request;
89            var url;
90            var uses;
91            var xhr;
92            function observeIfDone() {
93                // If done with making changes, start watching for chagnes in DOM again
94                inProgressCount -= 1;
95                if (inProgressCount === 0) { // if all xhrs were resolved
96                    unobserveChanges(); // make sure to remove old handlers
97                    observeChanges(); // watch for changes to DOM
98                }
99            }
100            function attrUpdateFunc(spec) {
101                return function () {
102                    if (cache[spec.base] !== true) {
103                        spec.useEl.setAttributeNS(xlinkNS, 'xlink:href', '#' + spec.hash);
104                    }
105                };
106            }
107            function onloadFunc(xhr) {
108                return function () {
109                    var body = document.body;
110                    var x = document.createElement('x');
111                    var svg;
112                    xhr.onload = null;
113                    x.innerHTML = xhr.responseText;
114                    svg = x.getElementsByTagName('svg')[0];
115                    if (svg) {
116                        svg.setAttribute('aria-hidden', 'true');
117                        svg.style.position = 'absolute';
118                        svg.style.width = 0;
119                        svg.style.height = 0;
120                        svg.style.overflow = 'hidden';
121                        body.insertBefore(svg, body.firstChild);
122                    }
123                    observeIfDone();
124                };
125            }
126            function onErrorTimeout(xhr) {
127                return function () {
128                    xhr.onerror = null;
129                    xhr.ontimeout = null;
130                    observeIfDone();
131                };
132            }
133            unobserveChanges(); // stop watching for changes to DOM
134            // find all use elements
135            uses = document.getElementsByTagName('use');
136            for (i = 0; i < uses.length; i += 1) {
137                try {
138                    bcr = uses[i].getBoundingClientRect();
139                } catch (ignore) {
140                    // failed to get bounding rectangle of the use element
141                    bcr = false;
142                }
143                href = uses[i].getAttributeNS(xlinkNS, 'href');
144                if (href && href.split) {
145                    url = href.split('#');
146                } else {
147                    url = ["", ""];
148                }
149                base = url[0];
150                hash = url[1];
151                isHidden = bcr && bcr.left === 0 && bcr.right === 0 && bcr.top === 0 && bcr.bottom === 0;
152                if (bcr && bcr.width === 0 && bcr.height === 0 && !isHidden) {
153                    // the use element is empty
154                    // if there is a reference to an external SVG, try to fetch it
155                    // use the optional fallback URL if there is no reference to an external SVG
156                    if (fallback && !base.length && hash && !document.getElementById(hash)) {
157                        base = fallback;
158                    }
159                    if (base.length) {
160                        // schedule updating xlink:href
161                        xhr = cache[base];
162                        if (xhr !== true) {
163                            // true signifies that prepending the SVG was not required
164                            setTimeout(attrUpdateFunc({
165                                useEl: uses[i],
166                                base: base,
167                                hash: hash
168                            }), 0);
169                        }
170                        if (xhr === undefined) {
171                            Request = createRequest(base);
172                            if (Request !== undefined) {
173                                xhr = new Request();
174                                cache[base] = xhr;
175                                xhr.onload = onloadFunc(xhr);
176                                xhr.onerror = onErrorTimeout(xhr);
177                                xhr.ontimeout = onErrorTimeout(xhr);
178                                xhr.open('GET', base);
179                                xhr.send();
180                                inProgressCount += 1;
181                            }
182                        }
183                    }
184                } else {
185                    if (!isHidden) {
186                        if (cache[base] === undefined) {
187                            // remember this URL if the use element was not empty and no request was sent
188                            cache[base] = true;
189                        } else if (cache[base].onload) {
190                            // if it turns out that prepending the SVG is not necessary,
191                            // abort the in-progress xhr.
192                            cache[base].abort();
193                            delete cache[base].onload;
194                            cache[base] = true;
195                        }
196                    } else if (base.length && cache[base]) {
197                        attrUpdateFunc({
198                            useEl: uses[i],
199                            base: base,
200                            hash: hash
201                        })();
202                    }
203                }
204            }
205            uses = '';
206            inProgressCount += 1;
207            observeIfDone();
208        };
209        // The load event fires when all resources have finished loading, which allows detecting whether SVG use elements are empty.
210        window.addEventListener('load', function winLoad() {
211            window.removeEventListener('load', winLoad, false); // to prevent memory leaks
212            tid = setTimeout(checkUseElems, 0);
213        }, false);
214    }
215}());

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.