PageSourceSearch

https://customer.nationalgrid.co.uk/public/javascripts/angular.page.js

js nationalgrid.co.uk collected 2026-09-24 09:02:04 UTC 26,891 bytes, 769 lines download raw bytes

1angular.module('page', [])
2.factory('$zIndex', function() {
3	return function(selector) {
4        Math.max(0, Math.max.apply(null, $.map(((selector || "*") === "*")? $.makeArray(document.getElementsByTagName("*")) : $(selector),
5            function (v) {
6                return parseFloat($(v).css("z-index")) || null;
7            }
8        )))+1;
9    }
10})
11.factory('$at', ['$http', function($http) {
12    var started,queue = [];
13    var $at = function(fn) {
14        if (CORE.AT) { return fn(CORE.AT) }
15        
16        queue.push(fn);
17        if (CORE.ATF && !started) {
18            var fn;
19            started = true;
20            $http.post(CORE.ATF).then(function(response) { 
21                CORE.AT = response.headers('X-XSRF-TOKEN');
22                $('input[name="authenticityToken"]').val(CORE.AT);
23                while (fn = queue.shift()) { fn(CORE.AT); }
24            }, function() {});
25        }
26    }
27
28    CORE.onTokenLoad = function() { 
29        for (var fn,i=0;(fn=arguments[i]);i++) $at(fn);
30    }
31    
32    return $at;
33}])
34.factory('$coreConfig', [ '$requester', '$q', function($requester, $q) {
35    let $json = $requester({ get: 'PageFront.getCoreConfig_JSON' });
36    
37    return function() {
38        let deferred = $q.defer();
39        let keys = [];
40
41        Object.values(arguments).forEach(key => keys.push(key));
42        
43        $json.get({ keys }, function(response) {
44            deferred.resolve(response);
45        });
46        
47        return deferred.promise;
48    }
49}])
50.factory('$navigation', [ '$requester', '$location', '$debounce', '$rootScope', function($requester, $location, $debounce, $rootScope) {
51    var scopes = { }
52    var byHandle = { }
53    var $json = $requester({ trail: 'PageFront.getTrail_JSON' });
54    var loaded = true;
55    var cache = {}
56    var install = function(handle, trail) {
57        byHandle[handle] && $.each(byHandle[handle], function(i, result) {
58            result.trail = trail.slice();
59            result.selected = trail.length && trail[trail.length - 1];
60        })
61    }
62    var fetch = function() { 
63        var allHandles = []; 
64        var fetchHandles = [];
65        var path = $location.path() || $location.absUrl().replace(/^https?:\/\/[^\/]+\//, '/');
66        
67        if (path) {
68            $.each(scopes, function(k, s) { allHandles = allHandles.concat(s.refHandles) })
69
70            $.each(allHandles, function(i, h) {
71                if ((cache[path] = cache[path] || {})[h]) {
72                    install(h, cache[path][h])
73                } else if (fetchHandles.indexOf(h) < 0) {
74                    fetchHandles.push(h);
75                }
76            })
77
78            loaded && fetchHandles.length && $json.trail({ handles: fetchHandles, currentUrl: path }, function(result){
79                $.each(result, function(handle, res) {
80                    (cache[path] = cache[path] || {})[handle] = res;
81                    install(handle, res);
82                })
83            })
84        }
85    }.$debounce(100);
86    
87    var removeWatcher = $rootScope.$watch(function() { return $location.path(); }, fetch);
88    var watcher = function(key) { return this[key] }
89    var service = function($scope, refHandles) {
90        var result = { }
91        
92        if (typeof(refHandles) == 'string') {
93            refHandles = [refHandles];
94        }
95        scopes[$scope.$id] = scopes[$scope.$id] || { scope: $scope, refHandles: refHandles, result: result }
96        $.each(refHandles, function(i, h) {
97            (byHandle[h] = byHandle[h] || []).push(result);
98        })
99        $scope.$on('$destroy', function() { delete scopes[$scope.$id]; })
100        fetch();
101        
102        result.$watch = function(key, fn) { return $scope.$watch(watcher.bind(result, key), fn); }
103        
104        return result;
105    }
106    var oldBeforeUnload = window.onbeforeunload;
107    
108    window.onbeforeunload = function() { loaded = false; removeWatcher && removeWatcher(); removeWatcher = null; oldBeforeUnload && oldBeforeUnload(); }
109
110    return service;
111}])
112.factory('$i18n', [ '$requester', '$timeout', '$q', function($requester, $timeout, $q) {
113    var queued = [], i18n = {};
114    var $json = $requester({ get: 'PageFront.i18n_JSON'});
115    
116    var service = function(str, p) {
117        var i=1,a,result = i18n[str];
118
119        if (!result) {
120            service.get(str);
121            result = i18n[str] = str;
122        }
123        for (i=1; i<arguments.length; i++) {
124            var undef;
125            if (undef != arguments[i]) {
126                result = result.replace('%s', arguments[i]);
127            }
128        }
129
130        return result;
131    }
132
133    service.promise = function(str) {
134        var q = $q.defer(), originals = {}, original = str;
135        
136        str = str.replace(/ +/g, '-')
137
138        if (i18n && i18n[str]) {
139            q.resolve(i18n[str]); 
140        } else {
141            if (queued.indexOf(str) < 0) {
142                service.get(str).then(function(result) {
143                    var value = result && result[0] && result[0].value || str;
144                    
145                    value = (value!=str)?value:original;
146                    
147                    i18n[str] = value || i18n[str] || str;
148                    
149                    q.resolve(value); 
150                })
151            }
152        } 
153
154        return q.promise;
155    }
156
157    var requestTimeoutId, qMap = {}, keyMap = {}, nextMapKey =0;
158    service.get = function() {
159        var q = $q.defer(), keys = [], mapKey = ++nextMapKey;
160        
161        qMap[mapKey] = q;
162
163        $.each(arguments, function(i, e) {
164            if (typeof(e) == 'string' && queued.indexOf(e) == -1) {
165                e = (e[e.length-1]=='.') ? e + '*' : e;
166
167                queued.push(e);
168                keyMap[e] = mapKey;
169            }
170        })
171        
172        requestTimeoutId && $timeout.cancel(requestTimeoutId);
173        
174        requestTimeoutId = $timeout(function() {
175            var fnIndex, items = queued,fn, key;
176
177            queued = [];
178            var qKeys = Object.keys(qMap);
179
180            if (items.length) $json.get({ i18n: items }, function(response) {
181                var qResults = {}
182                
183                $.each(response.i18n, function(k, v) { 
184                    var qKey = keyMap[k];
185                    
186                    (qResults[qKey] = qResults[qKey] || []).push({ key: k, value: v })
187                    i18n[k] = v; 
188                })
189                
190                while (key = qKeys.pop()) {
191                    if (qMap[key]) {
192                        qMap[key].resolve(qResults[key] || { key: key, value: key });
193
194                        delete qMap[key];
195                    }
196                }
197            }, null, true);
198            
199        }, 50);
200        
201        return q.promise;
202    }
203
204    service.set = function(defs) {
205        i18n = i18n||{}
206        $.each(defs, function(key, value) {
207            i18n[key] = value;
208        })
209    }
210
211    return service;
212}])
213
214
215.factory('$ajax', ['$rootScope', '$loading', '$at', '$timeout', function($rootScope, $loading, $at, $timeout) {
216   return function(url, data, success, error, background, loader) {
217            var on = { 
218                successFN: success,
219                errorFN: error,
220                success: function(fn) { this.successFN = fn; return this; },
221                error: function(fn) { this.errorFN = fn; return this; }
222            }
223            
224            var method = 'POST';
225            var headers = { 'Cache-Control': 'no-cache' }
226            var cache = false;
227            var installMenu = function(html) {
228                $('#admin-menu-holder').replaceWith($(html));
229            }
230            
231            if ($.isPlainObject(url)) {
232                method = url.method || 'POST';
233                if (method == 'GET') {
234                    delete headers['Cache-Control'];
235                    cache = true;
236                }
237
238                url = url.url;
239            }
240            if (CORE && CORE.getters && CORE.getters[url]) url = CORE.getters[url];
241            
242            var ajaxCall = function() {
243                var successFn = function(data, textStatus, jqXHR) {
244                        if (!background) $loading.clear(loader);
245                        if (jqXHR.getResponseHeader('REQUIRES_AUTH')==='1') return doLogin();
246                        else on.successFN&&on.successFN(data);
247                        $rootScope.$digest();
248                    }
249                    
250                if (!background) $loading(loader);
251                if (method != 'GET'||(data&&CORE&&CORE.requesterLegacyMode)) data.authenticityToken =  CORE.AT;
252
253                var sendData = (method == 'GET') ? { body: JSON.stringify(data) } : JSON.stringify(data);
254                
255                $.ajax({ cache: cache, headers:headers, contentType: "application/json", type: method, url: url, data: sendData, dataType: 'JSON',
256                    success: successFn,
257                    error: function(jqXHR, textStatus, errorThrown) { 
258                        if (textStatus == 'parsererror' && jqXHR.responseText[0] == '{') {
259                            try {
260                                var data = JSON.parse(jqXHR.responseText);
261                                successFn(data, "", jqXHR);
262                                return;
263                            } catch(e) { }
264                        }
265                        if (!background) {
266                            $loading.clear();
267                        }
268                        
269                        on.errorFN&&on.errorFN(jqXHR, textStatus, errorThrown);
270                        if (!on.errorFN) {
271                            console.log('XHR Error', textStatus, errorThrown)
272                        }
273                        $rootScope.$digest();
274                    }
275                })
276            }
277            
278            $at(ajaxCall);
279            
280            return on;
281        }
282}])
283
284.factory('$loading', ['$timeout', '$zIndex', function($timeout, $zIndex) {
285    var depth = 0, stage=0, 
286        ele= $('<div class="admin-loading"><img src="/public/images/spinner2.gif" /><div>').appendTo($('body')),
287        cloud = $('<div class="admin-loading-cloud"></div>'),
288        timeout,
289        clearAnimations = function() { ele.stop(true, false); cloud.stop(true, false); timeout = 0; },
290        defaultLoader = {
291            load: function() {
292                clearAnimations();
293                cloud.css({ opacity: 0 });
294                cloud.appendTo($('body'));
295                cloud.css('z-index', $zIndex());
296                ele.css('z-index', $zIndex());
297                ele.show();
298                stage = 0;
299
300                cloud.delay(500).animate({ opacity: .2 }, 500, 'swing');
301                ele.delay(500).animate({ left: -10 }, 500);
302            },
303            clear: function() {
304                clearAnimations();
305                ele.animate( { left: -50 }, 500, 'swing');
306                cloud.animate({ opacity: 0 }, 300, 'swing', function() { cloud.remove();  ele.css('z-index', 0); } )
307            },
308            depth: 0
309        }
310        
311        
312    
313    var result = function(loader) {
314        loader = loader || defaultLoader;
315        loader.depth = loader.depth||0;
316        
317        if (loader.depth++) return;
318        
319        if (loader && loader.load) loader.load();
320    }
321    
322    var clear = function(loader) {
323        loader = loader || defaultLoader;
324        loader.depth = loader.depth||0;
325
326        if (!loader.depth || (loader.depth = Math.max(loader.depth-1, 0))) return;
327        
328        if (loader && loader.clear) loader.clear();
329    }
330    
331    result.setDefaultLoader = function(loader) {
332        defaultLoader = loader || { }
333        
334        defaultLoader.load = defaultLoader.load || function() {}
335        defaultLoader.clear = defaultLoader.clear || function() {}
336        defaultLoader.depth = 0;
337    }
338    
339    result.clear = function(loader) { $timeout(function() { clear(loader); }); }
340
341    return result;
342}])
343
344
345.factory('$requester', ['$http', '$rootScope', '$timeout', '$ajax', '$q', function($http, $rootScope, $timeout, $ajax, $q) {
346    var timeoutId, allRoutes = { },
347        pending = { routes: {}, i18n: [] }, callbacks=[],
348        getRoutes = function(routes, i18n, callback) {
349            var cbKey = callbacks.length;
350            
351            callbacks.push(callback);
352            
353            for (var i,n;(n=(i18n||[])[i]);
353i++) pending.i18n.push(n);
354            
355            routes && $.each(routes, function(key, r) {
356                (pending.routes[r] = pending.routes[r] || []).push({ cbKey: cbKey, key: key });
357            })
358            
359            timeoutId && $timeout.cancel(timeoutId);
360            timeoutId = $timeout(function() {
361                var routes = {}, params = {}, i18n = pending.i18n, i=0, storedCallbacks = callbacks;
362                
363                $.each(pending.routes, function(r, cb) {
364                    routes[i] = r;
365                    params[i] = cb;
366                    i++;
367                })
368                
369                callbacks = [];
370                pending = { routes: {}, i18n: [] };
371                
372                $ajax(CORE.JI, { routes: routes, i18n: i18n }, function(response) {
373                    var index=0,i,p,calls = $.map(storedCallbacks, function(fn) { return { fn: fn, routes: { }, methods: { } } });
374
375                    response.i18n && $.each(response.i18n, function(k,v) { CORE.i18n[k] = v; } );
376
377                    $.each(response.routes, function(key, r) {
378                        allRoutes[routes[index]] = r;
379                        if (CORE.lang && CORE.lang != '') r = '/' + CORE.lang + r;
380                        if (params[key]) {
381                            for (i=0;(p=params[key][i]);i++) {
382                                calls[p.cbKey].routes[p.key] = r;
383                                calls[p.cbKey].methods[p.key] = (response.methods) ? response.methods[key] : 'POST';
384                            }
385                        }
386                    })
387                    
388                    for (i=0;(p=calls[i]);i++) p.fn({ routes: p.routes, methods: p.methods });
389                    
390                }, null, true);
391                
392            })
393        }
394    var counter = 0;
395    var premade = {},
396        create = function(routes, i18n, onReady) {
397            var service = { },
398                ready = false,
399                queue = [],
400                readyQueue = [],
401                routeRequest = {},
402                thisId = ++counter,
403                key,
404                loader,
405                methods = { },
406                inited;
407
408                onReady && readyQueue.push(onReady);
409                
410            var initServices = function(response) {
411                var rq, fn;
412                
413                routes = response.routes||[];
414                methods = response.methods||[]
415                ready = true;
416
417                for (key in response.i18n) {
418                    CORE.i18n[key] = response.i18n[key];
419                }
420
421                while (fn = readyQueue.shift()) {
422                    fn();
423                }
424
425                while (rq = queue.shift()) {
426                    callService.apply(this, rq);
427                }
428                
429                inited = true;
430            }
431
432            var callService = function(key, params, response, background) {
433                if (!ready) {
434                    return queue.push([key, params, response, background]);
435                }
436
437                params = params || {};
438
439                var route = routes[key]&&$ajax({ url: routes[key], method: methods[key]||'POST'}, params, 0, 0, background, response.loader||loader);
440                
441                route && route.success(function() { 
442                    response.success&&response.success.apply(this, arguments);
443                    $rootScope.$digest(); 
444                })
445                
446                if (response.failure) 
447                    route.error(function() { 
448                        response.failure.apply(this, arguments);
449                        $rootScope.$digest(); 
450                    });
451            }
452
453            var createService = function(key) {
454                return function(params, callback, background) { 
455                    var response = { success: callback }
456
457                    $timeout(function() { callService(key, params, response, background); });
458
459                    return { 
460                        onSuccess: function(fn) { response.success = fn; },
461                        onFailure: function(fn) { response.failure = fn; },
462                        setLoader: function(loader) { response.loader = loader; }
463                    }
464                }
465            }
466
467            var getRoute = function(key) {
468                return routes[key];
469            }
470            
471            var setLoader = function(ldr) {
472                loader = ldr;
473                return this;
474            }
475        
476        service.$getRoute = getRoute;
477        service.setLoader = setLoader;
478        
479        service.$onReady = service.onReady = function(fn) { if (ready) $timeout(fn); else readyQueue.push(fn); return service; };
480        
481        for (key in routes) {
482            service[key] = createService(key);
483            if (routes[key].indexOf('_JSON') < 0)
484                routes[key] = routes[key]+'_JSON';
485        } 
486        if (!inited) {
487            getRoutes(routes, i18n, initServices);
488        }
489
490        return service;
491    }
492    
493    var requesterService = function(routes, i18n, onReady, handle) {
494        if (handle && premade[handle]) {
495            return premade[handle];
496        }
497        
498        var service = create(routes, i18n, onReady, handle);
499        
500        if (handle) premade[handle] = service;
501        
502        return service;
503    }
504    
505        /**
506     * Determines a Play! route given the controller.method pair (e.g 'CorePages.list_JSON') as a jet
507     * It returns a promise, which will deliver the key / route pair in the fullness of time.
508     * 
509     * Unlike $json.$getRoute, if the route hasn't already been asked for, this will prompt the router
510     * to go and get it. If the call fails, it will reject the promise, and supply the key in the rejection
511     * @param {type} key
512     * @returns {.$q@call;defer.promise}
513     */
514    requesterService.getRoute = function(key) {
515        var deferred = $q.defer();
516        
517        if (allRoutes[key]) {
518            var result = {}
519            
520            result[key] = allRoutes[key];
521            
522            deferred.resolve(result);
523        } else {
524            var query = {}
525            
526            query[key] = key;
527            getRoutes(query, {}, function(routes) { 
528                if (routes.routes && routes.routes[key]) {        
529                    deferred.resolve(routes.routes);
530                } else {
531                    deferred.reject(key);
532                }
533            });
534        }
535        
536        return deferred.promise;
537    }
538
539    return requesterService;
540    
541}])
542
543
544/**
545 * @param {type} fn
546 * @returns {undefined}
547 * 
548 * Debouncer service leveraging $timeout. Will call the supplied function on a timeout, but if it's used again
549 * before the end of the timeout, cancels the first call and replaces it with the second.
550 * 
551 * Usage:
552 * 
553 * $debounce(myFn, 1000); // Use with a one second delay.
554 * $debounce(myFn, 'my-timeout-id', 500); // Use with a half second delay, and a custom timeout ID.
555 * $debounce(function() { myStuff(); }, 'my-timeout-id', 500);
556 * 
557 * Never do this:
558 * $debounce(function() { myStuff(); }, 500); - as the function is freshly created on each call, $debounce has no way of matching it with previous calls, and will fail to cancel earlier timeouts
559 * 
560 */
561.factory('$debounce', [ '$timeout', function($timeout) {
562    var timeouts = { }, nextId = 0;
563    
564    return function(fn) {
565        var timeoutPeriod = arguments[(arguments.length > 2) ? 2 : 1];
566        var id = (arguments.length == 3) ? arguments[1] : (fn._debounce_id=(fn._debounce_id || ('_db.auto.'+(++nextId))));
567        
568        timeouts[id] && $timeout.cancel(timeouts[id]);
569        timeouts[id] = $timeout(function() { fn(); delete timeouts[id]; }, timeoutPeriod);
570    }
571}])
572
573.factory('$session', function() {
574    var undef,fn = function(key, value) {
575        if (!window.sessionStorage) return null;
576        var result = window.sessionStorage.getItem(key);
577        
578        if (value !== undef) {
579            window.sessionStorage.setItem(key, JSON.stringify({ value: value }));
580        }
581        
582        return result && JSON.parse(result).value;
583    }
584    
585    fn.remove = function(key) {
586        window.sessionStorage && window.sessionStorage.removeItem(key);
587    }
588    return fn;
589})
590
591.factory('$data', function() {
592    var values = {};
593    
594    return {
595        set: function(handle, value) {
596            values[handle] = value;
597        },
598        get: function(handle, defaultValue) {
599            if (typeof(values[handle])=='undefined') return defaultValue;
600            return values[handle];
601        }
602    }
603})
604.filter('html', ['$sce', function ($sce) {
605    return function (val) {
606        return $sce.trustAsHtml(val);
607    };
608}])
609.directive('filterFn', ['$parse', function($parse) {
610    return {
611        restrict: 'A',
612        required: 'ng-model',
613        link: function($scope, ele, attrs) {
614            var modelGetter = $parse(attrs.ngModel),
615                fnGetter = $parse(attrs.filterFn);
616            
617            $scope.$watch(attrs.ngModel, function(val, old) {
618                var undef;
619                
620                if (val != undef && val != old) {
621                    modelGetter.assign($scope, fnGetter($scope)(val, old));
622                }
623            })
624        }
625    }
626
627}])
628
629.directive('ngBindHtmlUnsafe', function() {
630  return function(scope, element, attr) {
631    element.addClass('ng-binding').data('$binding', attr.ngBindHtmlUnsafe);
632    scope.$watch(attr.ngBindHtmlUnsafe, function ngBindHtmlUnsafeWatchAction(value) {
633      element.html(value || '');
634    });
635  };
636})
637
638/*
639This directive allows us to pass a function in on an enter key to do what we want.
640 */
641.directive('ngEnter', function () {
642    return function (scope, element, attrs) {
643        element.bind("keydown keypress", function (event) {
644            if(event.which === 13) {
645                scope.$apply(function (){
646                    scope.$eval(attrs.ngEnter);
647                });
648 
649                event.preventDefault();
650            }
651        });
652    };
653})
654
655.directive('simpleTemplate', [ '$compile', '$parse', '$templateCache', function($compile, $parse, $templateCache) {
656    return {
657        link: function($scope, ele, attrs) {
658            var id = $parse(attrs.rugsMenuTemplate)($scope);
659            var t = $templateCache.get(id);
660
661            $compile(t)($scope, function(clone, scope) { ele.append(clone); });
662        }
663    }
664}])
665
666.directive('ngBindI18n', [ '$i18n', function($i18n) {
667    return {
668        link: function($scope, $ele, $attrs) {
669            $i18n.promise($attrs.ngBindI18n).then(function(str) {
670                $ele.html(str);
671            })
672        }
673    }
674}])
675/**
676 * This is a slightly dirty hack, to get around the fact that a base href of 
677 * /products/ 
678 * will not be happy with a url of
679 * /products
680 * 
681 * The Angular guys have marked this bug as "won't fix" - so we're tapping into Things With Which We Shouldn't Mess With.
682 * To wit: $browser
683 * 
684 * Watch out for this one - it could easily break in a future Angular release.
685 */
686.config(['$provide', function($provide) {
687    $provide.decorator('$browser', [ '$delegate', function($delegate) {
688        var baseHrefFn = $delegate.baseHref;
689        
690        $delegate.baseHref = function() {
691            var result = baseHrefFn.apply($delegate, arguments);
692            var url = $delegate.url().replace(/^(https?:)?\/\/[^/]*(.*)\?.*/, '$2');
693            
694            return (url + '/' == result) ? url : result;
695        }
696
697        return $delegate;
698    }])
699}])
700
701/**
702 * @param {type} fn
703 * @returns {undefined}
704 * 
705 * Debouncer service leveraging $timeout. Will call the supplied function on a timeout, but if it's used again
706 * before the end of the timeout, cancels the first call and replaces it with the second.
707 * 
708 * Usage:
709 * 
710 * $debounce(myFn, 1000); // Use with a one second delay.
711 * $debounce(myFn, 'my-timeout-id', 500); // Use with a half second delay, and a custom timeout ID.
712 * $debounce(function() { myStuff(); }, 'my-timeout-id', 500);
713 * $debounce(true, myFn, 1000) // return a debounced version of myFn. Call the result with whatever args you like, and they will be passed to myFn when it runs. 
714 * 
715 * and for the piece de resistence - if you've included the service in a controller or some such, you have this:
716 * myFunc.$debounce(1000)
717 *    this one applies to *all* functions.
718 * 
719 * Never do this:
720 * $debounce(function() { myStuff(); }, 500); - as the function is freshly created on each call, $debounce has no way of matching it with previous calls, and will fail to cancel earlier timeouts
721 * 
722 */
723.factory('$debounce', [ '$timeout', function($timeout) {
724    var timeouts = { }, nextId = 0;
725    
726    var makeDebounceId = function(fn) {
727        return fn._debounce_id = fn._debounce_id || ('_db.auto.'+(++nextId));
728    }
729
730    var createFunction = function(fn, timeout) {
731        makeDebounceId(fn);
732        
733        return function() {
734            var i,a = [];
735            
736            for (i=0;i<arguments.length;i++) {
737                a.push(arguments[i]);
738            }
739
740            service(function() { fn.apply(this, a); }, fn._debounce_id, timeout)
741        }
742    }
743    var service = function(fn) {
744        if (fn === true) {
745            var i,args = [];
746            
747            for (i=1;i<arguments.length;i++) {
748                args.push(arguments[i])
749            }
750            return createFunction.apply(this, args)
751        }
752        var timeoutPeriod = arguments[(arguments.length > 2) ? 2 : 1];
753        var id = (typeof(arguments[1]) != 'number') ? arguments[1] : makeDebounceId(fn);
754        
755        timeouts[id] && $timeout.cancel(timeouts[id]);
756        timeouts[id] = $timeout(function() { fn(); delete timeouts[id]; }, timeoutPeriod);
757    }
758    
759    service.fn = function(fn, a, b) {
760        return service.bind(service, fn, a, b);
761    }
762    
763    Function.prototype.$debounce = function(a) {
764        return service(true, this, a);
765    }
766    
767    return service;
768}])
769$(document).ready((function(a){a.topZIndex=function(b){return Math.max(0,Math.max.apply(null,a.map((b||"*")==="*"?a.makeArray(document.getElementsByTagName("*")):a(b),function(b){return parseFloat(a(b).css("z-index"))||null})))};a.fn.topZIndex=function(b){if(this.length===0)return this;b=a.extend({increment:1},b);var c=a.topZIndex(b.selector),d=b.increment;return this.each(function(){this.style.zIndex=c+=d})}})(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.