PageSourceSearch

https://withaspin.com/wp-content/plugins/simple-social-icons/svgxuse.js?ver=1.1.21

js withaspin.com collected 2026-09-24 22:32:42 UTC 9,238 bytes, 209 lines download raw bytes

vendor: 7,838 bytes, lines 1-178
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.21
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 domain 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 domain requests.
53            function getHostname(href) {
54                var a = document.createElement('a');
55                a.href = href;
56                return a.hostname;
57            }
58            var Request;
59            var hname = location.hostname;
60            var hname2;
61            if (window.XMLHttpRequest) {
62                Request = new XMLHttpRequest();
63                hname2 = getHostname(url);
64                if (Request.withCredentials === undefined && hname2 !== '' && hname2 !== hname) {
65                    Request = XDomainRequest || undefined;
66                } else {
67                    Request = XMLHttpRequest;
68                }
69            }
70            return Request;
71        };
72        var xlinkNS = 'http://www.w3.org/1999/xlink';
73        checkUseElems = function () {
74            var base;
75            var bcr;
76            var fallback = ''; // optional fallback URL in case no base path to SVG file was given and no symbol definition was found.
77            var hash;
78            var href;
79            var i;
80            var inProgressCount = 0;
81            var isHidden;
82            var Request;
83            var url;
84            var uses;
85            var xhr;
86            function observeIfDone() {
87                // If done with making changes, start watching for chagnes in DOM again
88                inProgressCount -= 1;
89                if (inProgressCount === 0) { // if all xhrs were resolved
90                    unobserveChanges(); // make sure to remove old handlers
91                    observeChanges(); // watch for changes to DOM
92                }
93            }
94            function attrUpdateFunc(spec) {
95                return function () {
96                    if (cache[spec.base] !== true) {
97                        spec.useEl.setAttributeNS(xlinkNS, 'xlink:href', '#' + spec.hash);
98                    }
99                };
100            }
101            function onloadFunc(xhr) {
102                return function () {
103                    var body = document.body;
104                    var x = document.createElement('x');
105                    var svg;
106                    xhr.onload = null;
107                    x.innerHTML = xhr.responseText;
108                    svg = x.getElementsByTagName('svg')[0];
109                    if (svg) {
110                        svg.setAttribute('aria-hidden', 'true');
111                        svg.style.position = 'absolute';
112                        svg.style.width = 0;
113                        svg.style.height = 0;
114                        svg.style.overflow = 'hidden';
115                        body.insertBefore(svg, body.firstChild);
116                    }
117                    observeIfDone();
118                };
119            }
120            function onErrorTimeout(xhr) {
121                return function () {
122                    xhr.onerror = null;
123                    xhr.ontimeout = null;
124                    observeIfDone();
125                };
126            }
127            unobserveChanges(); // stop watching for changes to DOM
128            // find all use elements
129            uses = document.getElementsByTagName('use');
130            for (i = 0; i < uses.length; i += 1) {
131                try {
132                    bcr = uses[i].getBoundingClientRect();
133                } catch (ignore) {
134                    // failed to get bounding rectangle of the use element
135                    bcr = false;
136                }
137                href = uses[i].getAttributeNS(xlinkNS, 'href');
138                if (href && href.split) {
139                    url = href.split('#');
140                } else {
141                    url = ["", ""];
142                }
143                base = url[0];
144                hash = url[1];
145                isHidden = bcr && bcr.left === 0 && bcr.right === 0 && bcr.top === 0 && bcr.bottom === 0;
146                if (bcr && bcr.width === 0 && bcr.height === 0 && !isHidden) {
147                    // the use element is empty
148                    // if there is a reference to an external SVG, try to fetch it
149                    // use the optional fallback URL if there is no reference to an external SVG
150                    if (fallback && !base.length && hash && !document.getElementById(hash)) {
151                        base = fallback;
152                    }
153                    if (base.length) {
154                        // schedule updating xlink:href
155                        xhr = cache[base];
156                        if (xhr !== true) {
157                            // true signifies that prepending the SVG was not required
158                            setTimeout(attrUpdateFunc({
159                                useEl: uses[i],
160                                base: base,
161                                hash: hash
162                            }), 0);
163                        }
164                        if (xhr === undefined) {
165                            Request = createRequest(base);
166                            if (Request !== undefined) {
167                                xhr = new Request();
168                                cache[base] = xhr;
169                                xhr.onload = onloadFunc(xhr);
170                                xhr.onerror = onErrorTimeout(xhr);
171                                xhr.ontimeout = onErrorTimeout(xhr);
172                                xhr.open('GET', base);
173                                xhr.send();
174                                inProgressCount += 1;
175                            }
176                        }
177                    }
178                } else {
179                    if (!isHidden) {
180                        if (cache[base] === undefined) {
181                            // remember this URL if the use element was not empty and no request was sent
182                            cache[base] = true;
183                        } else if (cache[base].onload) {
184                            // if it turns out that prepending the SVG is not necessary,
185                            // abort the in-progress xhr.
186                            cache[base].abort();
187                            delete cache[base].onload;
188                            cache[base] = true;
189                        }
190                    } else if (base.length && cache[base]) {
191                        attrUpdateFunc({
192                            useEl: uses[i],
193                            base: base,
194                            hash: hash
195                        })();
196                    }
197                }
198            }
199            uses = '';
200            inProgressCount += 1;
201            observeIfDone();
202        };
203        // The load event fires when all resources have finished loading, which allows detecting whether SVG use elements are empty.
204        window.addEventListener('load', function winLoad() {
205            window.removeEventListener('load', winLoad, false); // to prevent memory leaks
206            tid = setTimeout(checkUseElems, 0);
207        }, false);
208    }
209}());

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.