PageSourceSearch

https://www.svfischbach.de/include/jquery/domReady.js

js svfischbach.de collected 2026-10-08 20:03:07 UTC 7,513 bytes, 171 lines download raw bytes

1// add event cross browser
2function addEvent(elem, event, fn) {
3    if (elem.addEventListener) {
4        elem.addEventListener(event, fn, false);
5    } else {
6        elem.attachEvent("on" + event, function() {
7            // set the this pointer same as addEventListener when fn is called
8            return(fn.call(elem, window.event));
9        });
10    }
11}
12
13    function confirmLink(message, url) {
14//console.log(message);
15        if (confirm(message)){ location.href = url;} else {return false;}
16    }
17
18    include_file = (function(FileName, nodeName) {
19        "use strict";
20        if (typeof FileName !== "string") {return false;}
21        let FileExt = FileName.replace(/^.*\./, '');
22        if (FileExt === "css" || FileExt === "js") {
23            var headJs,nodeJs,headCss,nodeCss;
24            switch (FileExt) {
25                case 'js':
26                    headJs = document.getElementsByTagName("SCRIPT")[0].parentNode;
27                    nodeJs = document.createElement("SCRIPT");
28                    nodeJs.setAttribute("async","async");
29                    nodeJs.setAttribute("src",FileName);
30                    headJs.appendChild(nodeJs);
31                    break;
32                case 'css':
33                    headCss = document.head.getElementsByTagName('LINK')[0].parentNode;
34                    nodeCss = document.createElement("LINK");
35                    nodeCss.setAttribute("rel","stylesheet");
36                    nodeCss.setAttribute("href",FileName);
37                    headCss.appendChild(nodeCss);
38                    break;
39                default:
40            }
41        };
42    });
43
44var logs = [];
45var eventSet = false;
46var loaded = false;
47function log(str) {
48    if (loaded) {
49            output(str);
50    } else {
51        if (loaded) {
52            output(str);
53        } else {
54            logs.push(str);
55        }
56        function output(str) {
57            var o = document.getElementById("log");
58            if (o){
59                var div = document.createElement("div");
60                div.appendChild(document.createTextNode(str));
61//console.log(o);
62                o.appendChild(div);
63            }
64        }
65        if (!eventSet) {
66            eventSet = true;
67            addEvent(window, "load", function() {
68                loaded = true;
69                for (var i = 0; i < logs.length; i++) {
70                    output(logs[i]);
71                }
72                logs = [];
73            });
74        }
75    }
76}
77
78    // call this when the document is ready
79    // this function protects itself against being called more than once
80    function ready() {
81        if (!readyFired) {
82            // this must be set to true before we start calling callbacks
83            readyFired = true;
84            for (var i = 0; i < readyList.length; i++) {
85                // if a callback here happens to add new ready handlers,
86                // the domReady() function will see that it already fired
87                // and will schedule the callback to run right after
88                // this event loop finishes so all handlers will still execute
89                // in order and no new ones will be added to the readyList
90                // while we are processing the list
91                readyList[i].fn.call(window, readyList[i].ctx);
92            }
93            // allow any closures held by these functions to free
94            readyList = [];
95        }
96    }(function(funcName, baseObj) {
97            // The public function name defaults to window.domReady
98            // but you can pass in your own object and own function name and those will be used
99            // if you want to put them in a different namespace
100            funcName = funcName || "domReady";
101            baseObj = baseObj || window;
102            var readyList = [];
103            var readyFired = false;
104            var readyEventHandlersInstalled = false;
105            // call this when the document is ready
106            // this function protects itself against being called more than once
107            function ready() {
108                    if (!readyFired) {
109                            // this must be set to true before we start calling callbacks
110                            readyFired = true;
111                            for (var i = 0; i < readyList.length; i++) {
112                                    // if a callback here happens to add new ready handlers,
113                                    // the domReady() function will see that it already fired
114                                    // and will schedule the callback to run right after
115                                    // this event loop finishes so all handlers will still execute
116                                    // in order and no new ones will be added to the readyList
117                                    // while we are processing the list
118                                    readyList[i].fn.call(window, readyList[i].ctx);
119                            }
120                            // allow any closures held by these functions to free
121                            readyList = [];
122                    }
123            }
124            function readyStateChange() {
125                    if (document.readyState === "complete") {
126                            ready();
127                    }
128            }
129            // This is the one public interface
130            // domReady(fn, context);
131            // the context argument is optional - if present, it will be passed
132            // as an argument to the callback
133            baseObj[funcName] = function(callback, context) {
134                    // if ready has already fired, then just schedule the callback
135                    // to fire asynchronously, but right away
136                    if (readyFired) {
137                            setTimeout(function() {
138                                    callback(context);
139                            }, 1);
140                            return;
141                    } else {
142                            // add the function and context to the list
143                            readyList.push({
144                                    fn: callback,
145                                    ctx: context
146                            });
147                    }
148                    // if document already ready to go, schedule the ready function to run
149                    if (document.readyState === "complete") {
150                            setTimeout(ready, 1);
151                    } else if (!readyEventHandlersInstalled) {
152                            // otherwise if we don't have event handlers installed, install them
153                            if (document.addEventListener) {
154                                    // first choice is DOMContentLoaded event
155                                    document.addEventListener("DOMContentLoaded", ready, false);
156                                    // backup is window load event
157                                    window.addEventListener("load", ready, false);
158                            } else {
159                                    // must be IE
160                                    document.attachEvent("onreadystatechange", readyStateChange);
161                                    window.attachEvent("onload", ready);
162                            }
163                            readyEventHandlersInstalled = true;
164                    }
165            }
166    })("domReady", window);
167
168window.addEventListener('DOMContentLoaded', include_file, false);
169
170//window.addEventListener('DOMContentLoaded', confirmLink, false);
171

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.