PageSourceSearch

https://www.northtexasregionalairport.com/common/scripts/ezutilities.js

js northtexasregionalairport.com collected 2026-10-02 22:21:05 UTC 17,000 bytes, 352 lines download raw bytes

1//Author: ezTask.com Inc.
2//Filename: ezUtilities.js
3//Purpose: Contains common/useful javascript functions used throughout ezTask projects
4//No Dependencies allowed, jQuery or any other library should not be used in this file
5(function() {
6    window.ezUtilities = {
7        isMobile: (function() {
8            var ismobile = false;
9            var isTouchScreen = 'ontouchstart' in document.documentElement;
10            (function(a) {
11                ismobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))
12            })(navigator.userAgent || navigator.vendor || window.opera);
13            return ismobile && isTouchScreen;
14        })(),
15        CustomEventPolyfill: (function() {
16            /*Polyfill for Custom Event API in Internet Explorer 9+*/
17            if (typeof window.CustomEvent === "function") return false;
18
19            function CustomEvent(event, params) {
20                params = params || {
21                    bubbles: false,
22                    cancelable: false,
23                    detail: undefined
24                };
25                var evt = document.createEvent('CustomEvent');
26                evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
27                return evt;
28            }
29
30            CustomEvent.prototype = window.Event.prototype;
31
32            window.CustomEvent = CustomEvent;
33        })(),
34        Cookie: (function() {
35            //Singleton
36            // Private Methods and Values
37            var instance,
38                daysInMS = 86400000,
39                API = {};
40            var createInstance = function() {
41                return Object.freeze(API);
42            }
43
44            var getInstance = function() {
45                if (!instance) {
46                    instance = createInstance();
47                }
48                return instance;
49            }
50
51            //Public Methods and Values
52            API.createCookie = function(name, value, expires, path, domain) {
53                //Creates a new cookie
54                var cookie = name + "=" + escape(value) + ";";
55                if (navigator.cookieEnabled) {
56                    if (expires) {
57                        expires = new Date(new Date().getTime() + (daysInMS * expires));
58                        cookie += "expires=" + expires.toGMTString() + ";";
59                    }
60                    if (path)
61                        cookie += "path=" + path + ";";
62                    if (domain)
63                        cookie += "domain=" + domain + ";";
64                    document.cookie = cookie;
65                    return document.cookie;
66                } else {
67                    this.cookiesNotEnabled();
68                    return false;
69                }
70            }
71            API.getCookie = function(name) {
72                // Return a cookie based on the name given or returns null
73                var regexp = new RegExp("(?:^" + name + "|;\s*" + name + ")=(.*?)(?:;|$)", "g");
74                var result = regexp.exec(document.cookie);
75                return (result === null) ? null : result[1];
76            }
77            API.deleteCookie = function(name) {
78                // Deletes a cookie based on the name given
79                if (this.getCookie(name)) {
80                    this.createCookie(name, "", -1);
81                }
82            }
83            API.checkCookie = function(name, daysToExpire) {
84                //Checks to see if a cookie exists and then creates one
85                if (!this.getCookie(name)) {
86                    if (navigator.cookieEnabled) {
87                        this.createCookie(name, navigator.appVersion, daysToExpire);
88                    }
89                    return false;
90                } else return true;
91            }
92            API.cookiesNotEnabled = function() {
93                //Let's the user know that their cookies are not enabled and will hinder functionality
94                return navigator.cookieEnabled;
95            }
96            return {
97                getInstance: getInstance
98            };
99        })(),
100        LocalStorage: (function() {
101            //Singleton
102            //Similar to Cookies except the information stored is more persistant since it can't be deleted by the user and has no expiration date
103            if (typeof(Storage) === "undefined") {
104                console.warn("Storage API not found in this Browser. Use cookies instead.");
105                return;
106            }
107
108            // Private Methods and Values
109            var instance,
110                API = {};
111            var createInstance = function() {
112                return Object.freeze(API);
113            }
114
115            var getInstance = function() {
116                if (!instance) {
117                    instance = createInstance();
118                }
119                return instance;
120            }
121
122            //Public Methods and Values
123            API.create = function(name, value) {
124                if (typeof value !== "string") {
125                    try {
126                        value = JSON.stringify(value)
127                    } catch (e) {
128                        console.log("Value must be either a string or an object.");
129                    }
130                }
131                localStorage.setItem(name, value);
132            }
133
134            API.get = function(name) {
135                return localStorage.getItem(name);
136            }
137
138            API.remove = function(name) {
139                localStorage.removeItem(name);
140            }
141
142            return {
143                getInstance: getInstance
144            };
145        })(),
146        EventHub: function() {
147            if (!(this instanceof ezUtilities.EventHub)) throw new Error("ezUtilities.EventHub should be created with `new`")
148            var topics = {};
149            var hOP = topics.hasOwnProperty;
150            return {
151                subscribe: function(topic, listener) {
152                    // Create the topic's object if not yet created
153                    if (!hOP.call(topics, topic)) topics[topic] = [];
154
155                    // Add the listener to queue
156                    var index = topics[topic].push(listener) - 1;
157
158                    // Provide handle back for removal of topic
159                    return {
160                        remove: function() {
161                            delete topics[topic][index];
162                        }
163                    };
164                },
165                publish: function(topic, info) {
166                    // If the topic doesn't exist, or there's no listeners in queue, just leave
167                    if (!hOP.call(topics, topic)) return;
168
169                    // Cycle through topics queue, fire!
170                    topics[topic].forEach(function(item) {
171                        item(info != undefined ? info : {});
172                    });
173                }
174            };
175        },
176        returnPageName: function() {
177            var pagename = (window.location.pathname).split("/");
178            return pagename[pagename.length - 1];
179        },
180        returnPageMode: function() { //Preview or Page mode?
181            var pagename = (window.location.pathname).split("/");
182            return pagename[pagename.length - 2];
183        },
184        checkIfRefferer: function(referrer, destination) {
185            //Prevents users from accessing a page if they haven't been referred from another page
186            //Ex: A form page that sends users to a document page after they have filled out the form
187            //referrer: Link the desired referrer page (entire URL)
188            //destination: name of landing page (the page which will be calling this function)
189            var cookie = this.Cookie.getInstance();
190            var cookieExists = cookie.getCookie(destination);
191            var pagename = this.returnPageName();
192            var pagemode = this.returnPageMode();
193            if (pagemode != "preview") {
194                if (!cookieExists) { //The cookie does not exist
195                    if (document.referrer == referrer) { //The referrer was not the specified page so send the user back to the specified page
196                        cookie.createCookie(pagename, navigator.appVersion, 1000);
197                    } else {
198                        window.location = referrer; //The referrer was the specified page so create a cookie that expires in 30 days
199                    }
200                }
201            }
202        },
203        convertXMLtoJSON: function(xml) {
204            try {
205                var items = xml.getElementsByTagName('item');
206            } catch (e) {
207                return null;
208            }
209            var json = [];
210            for (var i = 0; i < items.length; i++) {
211                var item = items[i];
212                var children = item.childNodes;
213                json.push({});
214                for (var j = 0; j < children.length; j++) {
215                    var child = children[j];
216                    if (child.nodeType !== 1 /*Node.ELEMENT_NODE*/ ) continue;
217                    if (child.nodeName) json[i][child.nodeName] = child.textContent;
218                }
219            }
220            return json;
221        },
222        renderTemplate: function(template, data, escape) {
223            var regex = /{{\s*[\w\.]+\s*(\|.*)?}}/g;
224            var matches = template.match(regex); //creates array of tags
225            if (matches) {
226                matches.map(function(x) {
227                    var tag = x.replace(/{{/, "").replace(/}}/, "").trim();
228                    var value = data[tag];
229                    if (escape) value = ezUtilities.escapeHTML(value);
230                    template = template.replace(x, value)
231                });
232            }
233            return template
234        },
235        escapeHTML: function(html) {
236            var tempDiv = document.createElement("div");
237            tempDiv.innerText = html;
238            return tempDiv.innerHTML
239        },
240        parseUrlQuery: function(queryString, removeBase) {
241            var removeBase = removeBase || "";
242            var queryString = queryString.replace(removeBase, "");
243            var queryData = {};
244            var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
245            for (var i = 0; i < pairs.length; i++) {
246                var pair = pairs[i].split('=');
247                if (pair[0] != "") queryData[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
248            }
249            return queryData;
250        },
251        throttle: function(func, limit) {
252            var wait = false;
253            limit = limit || 200;
254            return function() {
255                if (!wait) {
256                    func.call();
257                    wait = true;
258                    setTimeout(function() {
259                        wait = false;
260                    }, limit);
261                }
262            }
263        },
264        debounce: function(func, wait, immediate) {
265            var timeout;
266            var args;
267            return function() {
268                var context = this,
269                    args = arguments;
270                var later = function() {
271                    timeout = null;
272                    if (!immediate) func.apply(context, args);
273                }
274                var callNow = immediate && !timeout;
275                clearTimeout(timeout);
276                timeout = setTimeout(func, wait || 200);
277                if (callNow) func.apply(context, args);
278            }
279        },
280        getURLParameters: function() {
281            var queryString = window.location.search;
282            var queryData = {};
283            var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
284            for (var i = 0; i < pairs.length; i++) {
285                var pair = pairs[i].split('=');
286                if (pair[0] != "") queryData[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
287            }
288            return queryData;
289        },
290        print: (function() {
291            $(function() {
292                var $print = $("#print");
293                var $body = $("#body");
294                window.addEventListener("afterprint", function() {
295                    $body.removeClass("printing");
296                });
297                window.addEventListener("beforeprint", function() {
298                    $body.addClass("printing");
299                });
300                $print.on("click", function() {
301                    window.print();
302                });
303            });
304        })(),
305        sticky: function(element) {
306            if (window.location.pathname == "/design/Editor.aspx" || ezUtilities.isMobile) return;
307            var $body = $("body");
308            var $element = $(element);
309            var top = $element.offset().top;
310            var height = $element.outerHeight();
311            var requestAnimationFrame = window.requestAnimationFrame || function(func) {
312                func();
313            };
314            $(window).on("scroll", function() {
315                requestAnimationFrame(function() {
316                    if ((window.scrollY || window.pageYOffset) > (top)) {
317                        $element.addClass("sticky");
318                        $body.css("padding-top", height + "px");
319                    } else {
320                        $element.removeClass("sticky");
321                        $body.css("padding-top", 0);
322                    }
323                });
324            });
325        },
326        translate: (function() {
327            var translateLink = $("#translateLink").attr("target", "_blank");
328            if (translateLink.length) {
329                var currentURL = encodeURIComponent(window.location.href);
330                var url = "https://www.microsofttranslator.com/bv.aspx?from=en&to=es&refd=www.translatoruser.net&r=true&a=" + currentURL;
331                translateLink.attr("href", url)
332            }
333        })(),
334        slideshowReadmoreButtons: function(id) {
335            var $slideshow = $(id);
336            var $slides = $slideshow.find(".imageWrapper");
337            $slides.each(function() {
338                var $caption = $(this).next(".ezcaptionwrapper");
339                var href = this.href || $(this).attr("data-href");
340                var hasTitle = $caption.find(".ezcaptiontitle").text().length;
341                var hasDescription = $caption.find(".ezcaption").text().length;
342                if ((hasTitle || hasDescription) && href != "javascript:void(0)") {
343                    var $readmore = $("<span class='ezcaptionlink'><a href='" + href + "'>Learn More</a></span>");
344                    $caption.append($readmore);
345                    $(this).on("click", function(e) {
346                        e.preventDefault();
347                    });
348                }
349            });
350        }
351    }
352})();

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.