PageSourceSearch

https://www.solidagro.be/ui/uibase/script/pblib/pblib.js?rev=cbwwOSnJEpE

js solidagro.be collected 2026-09-30 14:19:44 UTC 33,113 bytes, 991 lines download raw bytes

1// To flush the cache of this file, increase the version number: 4
2
3window.PbLib = window.PbLib || (function (window, document, undefined) {
4    'use strict';
5
6    var PbLib = {};
7
8    PbLib.isDebug = function () {
9        var isDebug = false;
10        var scriptElements = document.getElementsByTagName('script');
11        var i = scriptElements.length;
12        while (i-- && !isDebug) {
13            isDebug = (/ui\/uibase\/script\/pblib\/pblib\.js\?.*isdebug=1/i).test(scriptElements[i].src);
14        }
15
16        PbLib.isDebug = function () {
17            return isDebug;
18        };
19
20        return PbLib.isDebug();
21    };
22
23    PbLib.self = {
24        pathName: 'ui/uibase/script/pblib',
25        fileName: 'pblib.js'
26    };
27
28    PbLib.getMetaUriParts = function () {
29        var scripts = document.getElementsByTagName('script');
30        var match;
31        var revMatch;
32
33        var pathBase = '/';
34        var uriBase = '/';
35        var langInfix = '';
36        var revision = '';
37
38        var re = new RegExp('^(.*)' + PbLib.self.pathName + '/' + PbLib.self.fileName + '(\\?.*)?$');
39        for (var i = 0; i < scripts.length; i++) {
40            match = scripts[i].src.match(re);
41            if (match) {
42                uriBase = match[1] === '' ? '/' : match[1];
43                pathBase = uriBase.replace(/^(https?:\/\/)?([^\/]*)/i, '');
44
45                revMatch = match[2].match(/(\?|&)rev=(.*?)($|&)/);
46                if (revMatch) {
47                    revision = revMatch[2];
48                }
49
50                /*
51                    Search for elements:
52                    * can have l/k/c
53                    * can have language infix
54                    * can have workspace infix
55                */
56                var url = window.location.href;
57                // ([a-z]/)?(([a-z]{2})/)?([0-9]*)?(/.*)?$');
58                re = new RegExp('^(https?:\/\/[^/]*)?' + uriBase + '([a-z]/)?(.*)$');
59                match = url.match(re);
60                if (!match) {
61                    break;
62                }
63                url = match[3];
64
65                var urlParts = url.split('/');
66                if (typeof urlParts[0] !== 'undefined' && urlParts[0].match(/^[a-z]{2}$/)) {
67                    langInfix = urlParts.shift() + '/';
68                }
69                break;
70            }
71        }
72
73        if (revision === '') {
74            revision = '' +
75                PbLib.curDate.getFullYear() +
76                (PbLib.curDate.getMonth() + 1) +
77                PbLib.curDate.getDate() +
78                PbLib.curDate.getHours();
79        }
80
81        // Redefine this method with cached values
82        PbLib.getMetaUriParts = function () {
83            return {
84                uriBase: uriBase,
85                pathBase: pathBase,
86                langInfix: langInfix,
87                revision: revision
88            };
89        };
90
91        return PbLib.getMetaUriParts();
92    };
93
94    PbLib.getCacheString = function () {
95        return PbLib.getMetaUriParts().revision;
96    };
97
98    function ProBaseUrl (path) {
99        this.path = path;
100        this.queryParams = {};
101        this.addReturnUrl = false;
102    }
103
104    ProBaseUrl.prototype.setQueryParam = function (name, value) {
105        this.queryParams[name] = value;
106        return this;
107    };
108
109    ProBaseUrl.prototype.setAddReturnUrl = function (returnUrl) {
110        this.addReturnUrl = returnUrl;
111        return this;
112    };
113
114    ProBaseUrl.prototype.toString = function () {
115        var metaUriParts = PbLib.getMetaUriParts();
116
117        var path = this.path;
118        if (path) {
119            if (path.charAt(0) === '/') {
120                path = path.substring(1);
121            }
122        } else {
123            path = '';
124        }
125
126        var url = metaUriParts.uriBase;
127        if (!path.match(/^(files|ui)\//)) {
128            var match = path.match(/^([a-z]\/)/);
129            if (match) {
130                url += match[1];
131                path = path.substring(2);
132            }
133            match = path.match(/^([a-z]{2}\/)/);
134            if (!match) {
135                // Only add language infix if path doesn't have it already
136                url += metaUriParts.langInfix;
137            }
138        }
139        url += path;
140
141        var queryStarted = false;
142        var params = this.queryParams;
143
144        if (params.return_uri) {
145            delete params.return_uri;
146        }
147
148        if (this.addReturnUrl === true) {
149            var uri = '';
150            if (document.location.pathname) {
151                uri += document.location.pathname;
152            }
153            if (document.location.search) {
154                uri += document.location.search;
155            }
156
157            params.return_uri = uri ? uri : '/';
158        } else if (this.addReturnUrl) {
159            params.return_uri = this.addReturnUrl;
160        }
161
162        for (var key in params) {
163            if (!params.hasOwnProperty(key)) {
164                continue;
165            }
166
167            url += queryStarted ? '&' : '?';
168            queryStarted = true;
169
170            url += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
171        }
172
173        return url;
174    };
175
176    PbLib.buildUrl = function (path) {
177        return new ProBaseUrl(path);
178    };
179
180    PbLib.getNewURI = function (path) {
181        return PbLib.buildUrl(path).toString();
182    };
183
184    // single page notice bar
185    // noticeType: 'failure', 'success', 'info', 'warning', 'question'
186    PbLib.notice = function (noticeClass, noticeText, showAsHtml) {
187        if (window.parent !== window && window.parent.PbLib) {
188            return window.parent.PbLib.notice(noticeClass, noticeText, showAsHtml);
189        }
190
191        var topDocument = window.top.document;
192        var contentElement = topDocument.getElementById('content');
193        if (!contentElement || !contentElement.parentNode) {
194            return false;
195        }
196
197        var notices = topDocument.getElementById('spiNotices');
198        var existingNotices = document.querySelectorAll('ul.notice');
199        var numberOfExistingNotices = existingNotices.length;
200
201        // Process existing notices
202        for (var i = 0; i < numberOfExistingNotices; i++) {
203            var existingNotice = existingNotices[i];
204
205            if (!document.body.contains(existingNotice)) {
206                continue;
207            }
208
209            // Remove normal (non SPI) notices
210            if (notices && !notices.contains(existingNotice)) {
211                PbLib.fadeOut(existingNotice, 0.05, 50, true);
212                continue;
213            }
214
215            // Prevent hammering the user with equal notices
216            var existingNoticeText = existingNotice.children[0].childNodes[0].nodeValue;
217            if (existingNoticeText === noticeText) {
218                return;
219            }
220        }
221
222        if (!notices) {
223            // spiNotices.parentNode.removeChild(spiNotices);
224            notices = topDocument.createElement('div');
225            notices.setAttribute('id', 'spiNotices');
226            notices.setAttribute('class', 'singlepage');
227            contentElement.parentNode.insertBefore(notices, contentElement.parentNode.firstChild);
228        }
229
230        var notice = topDocument.createElement('ul');
231        notice.style.transition = 'opacity .2s ease';
232        notice.style.opacity = '0';
233        var item = topDocument.createElement('li');
234        var text;
235        if (showAsHtml) {
236            text = topDocument.createElement('span');
237            text.innerHTML = noticeText;
238        } else {
239            text = topDocument.createTextNode(noticeText);
240        }
241        var closeButton = topDocument.createElement('span');
242        var closeButtonText = '@{Close this notice}';
243
244        closeButton.update(closeButtonText);
245
246        closeButton.onclick = function () {
247            notice.parentNode.removeChild(notice);
248        };
249
250        if (noticeClass === 'failure') {
251            noticeClass = 'fail';
252        }
253
254        notice.className = 'notice ' + noticeClass;
255        closeButton.className = 'closebutton';
256
257        item.appendChild(text);
258        item.appendChild(closeButton);
259        notice.appendChild(item);
260        notices.appendChild(notice);
261
262        var raf = (function () {
263            return window.requestAnimationFrame ||
264                window.webkitRequestAnimationFrame ||
265                window.mozRequestAnimationFrame ||
266                window.oRequestAnimationFrame ||
267                window.msRequestAnimationFrame ||
268                function (callback) {
269                    window.setTimeout(callback, 1000 / 60);
270                };
271        })();
272
273        raf(function () {
274            notice.style.opacity = '1';
275        });
276
277        setTimeout(function () {
278            if (!notices.contains(notice)) {
279                return;
280            }
281
282            notice.style.opacity = '0';
283
284            setTimeout(function () {
285                notice.parentNode.removeChild(notice);
286            }, 250);
287        }, 10000);
288    };
289
290    PbLib.objectClone = function (obj) {
291        if (obj === null || typeof (obj) !== 'object') {
292            return obj;
293        }
294
295        var tObj = {};
296        for (var k in obj) {
297            if (!obj.hasOwnProperty(k)) {
298                continue;
299            }
300            tObj[k] = PbLib.objectClone(obj[k]);
301        }
302        return tObj;
303    };
304
305    PbLib.getUniqId = function () {
306        var idBase = 'pblibguid';
307        var idBaseNum = 0;
308        var guid = 0;
309        while (document.getElementById(idBase + (idBaseNum === 0 ? '' : idBaseNum) + '_1')) {
310            idBaseNum += 1;
311        }
312        idBase = idBase + (idBaseNum === 0 ? '' : idBaseNum) + '_';
313
314        PbLib.getUniqId = function () {
315            return idBase + (++guid);
316        };
317
318        return PbLib.getUniqId();
319    };
320
321    PbLib.escapeFrame = function () {
322        if (window !== window.top) {
323            window.top.location.replace(window.location.href);
324        }
325    };
326
327    PbLib.loadScript = function (scripts, callback) {
328        scripts = scripts instanceof Array ? scripts : [scripts];
329        var total = scripts.length;
330        var loaded = 0;
331        var args = Array.prototype.slice.call(arguments, 2);
332        var i;
333
334        for (i = 0; i < total; ++i) {
335            // make sure the translated script is loaded
336            scripts[i] = scripts[i].replace(
337                /^((([a-z]+:)?\/\/[^\/]+\/)ui|(\/?)ui)\//,
338                '$2$4a/' + PbLib.getMetaUriParts().langInfix + 'userinterface/'
339            );
340
341            var scriptElementsRelative = document.querySelectorAll('script[src="' + scripts[i] + '"]');
342            var scriptElementsWithProtocol = document.querySelectorAll(
343                'script[src="' + window.location.protocol + '//' + window.location.host + scripts[i] + '"]'
344            );
345            var isLoaded = (
346                scriptElementsRelative.length > 0 ||
347                (!scripts[i].match(/^https?:\/\//) && scriptElementsWithProtocol.length > 0)
348            );
349
350            if (isLoaded) {
351                ++loaded;
352            } else {
353                (function () {
354                    var domscript = document.head.appendChild(document.createElement('script'));
355                    var onloadFired;
356                    domscript.src = scripts[i];
357                    if (callback) {
358                        var delay = 0;
359
360                        // Test for onreadystatechange to trigger callback in IE
361                        domscript.onreadystatechange = function () {
362                            window.setTimeout(function () {
363                                // Only check on 'loaded'.
364                                // Checking on readyState 'complete' can result in Callback = NULL
365                                if (!onloadFired && (domscript.readyState === 'loaded')) {
366                                    onloadFired = true;
367                                    if (++loaded === total) {
368                                        callback.apply(window, args);
369                                    }
370                                }
371                            }, delay);
372                        };
373
374                        domscript.onload = function () {
375                            window.setTimeout(function () {
376                                if (!onloadFired) {
377                                    onloadFired = true;
378                                    if (++loaded === total) {
379                                        callback.apply(window, args);
380                                    }
381                                }
382                            }, delay);
383                        };
384                    }
385                })();
386            }
387        }
388
389        callback && loaded === total && callback.apply(window, args);
390    };
391
392    PbLib.loadCss = function (sheets, callback) {
393        sheets = sheets instanceof Array ? sheets : [sheets];
394        var args = Array.prototype.slice.call(arguments, 2);
395        var total = sheets.length;
396        var loaded = 0;
397        var cssTimer;
398        var i;
399
400        for (i = 0; i < total; ++i) {
401            if (document.querySelectorAll('links[href="' + sheets[i] + '"]').length > 0) {
402                ++loaded;
403            } else {
404
405                var sheetIndex = document.styleSheets.length;
406                var domcss = document.head.appendChild(document.createElement('link'));
407                var styleRules = '';
408
409                domcss.rel = 'stylesheet';
410                domcss.type = 'text/css';
411                domcss.media = 'screen';
412                domcss.href = sheets[i];
413
414                // Check if href is external
415                var match = sheets[i].match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
416                var isExternal = false;
417
418                if (typeof match[1] === 'string' &&
419                    match[1].length > 0 &&
420                    match[1].toLowerCase() !== location.protocol
421                ) {
422                    isExternal = true;
423                }
424
425                if (typeof match[2] === 'string' &&
426                    match[2].length > 0 &&
427                    match[2].replace(new RegExp(':(' + {
428                        'http:': 80,
429                        'https:': 443
430                    }[location.protocol] + ')?$'), '') !== location.host
431                ) {
432                    isExternal = true;
433                }
434
435                (function loader () {
436                    try {
437                        var sheet = document.styleSheets[sheetIndex];
438
439                        // cssRules or rules are only present if stylesheet is loaded
440                        if (isExternal === false && sheet.cssRules) {
441                            styleRules = sheet.cssRules;
442                        } else if (isExternal === false && sheet.rules) {
443                            styleRules = sheet.rules;
444                        }
445
446                        if ((styleRules !== '' || isExternal === true) && callback) {
447                            callback.apply(window, args);
448                            clearTimeout(cssTimer);
449                            ++loaded;
450                        }
451                    } catch (e) {
452                        if ('NS_ERROR_DOM_SECURITY_ERR' !== e.name) {
453                            cssTimer = setTimeout(loader, 100);
454                        }
455                    }
456
457                })();
458            }
459        }
460
461        if (callback && loaded === total) {
462            callback.apply(window, args);
463        }
464    };
465
466    PbLib.module = {};
467    PbLib.modules = {};
468    PbLib.curDate = new Date();
469    PbLib.module.load = function (modName) {
470        if (Array.isArray(modName)) {
471            var returnval = true;
472            for (var i = 0; i < modName.length; i++) {
473                returnval = returnval && PbLib.module.load(modName[i]);
474            }
475            return returnval;
476        } else if (typeof modName !== 'string') {
477            return false;
478        }
479
480        modName = modName.toLowerCase();
481        if (typeof PbLib.modules[modName] === 'undefined') {
482            PbLib.modules[modName] = {
483                loaded: false,
484                loading: true,
485                dependencies: [],
486                dependencyOf: []
487            };
488        } else if (PbLib.modules[modName].loaded) {
489            // Module is loaded
490            return true;
491        } else if (PbLib.modules[modName].loading) {
492            // Module is being loaded
493            return true;
494        }
495
496        // Load module content
497
498        // make sure the translated module is loaded
499        var path = PbLib.self.pathName.replace('ui/', 'a/userinterface/');
500        var request = new XMLHttpRequest();
501        request.onreadystatechange = function (event) {
502            var element = event.target;
503            if (element.status === 200 && element.responseText) {
504                eval(element.responseText);
505            }
506        };
507        request.open('GET', PbLib.getNewURI(path + '/' + modName + '.js?rev=' + PbLib.getCacheString()), false);
508        request.send();
509
510        return PbLib.modules[modName].loaded;
511    };
512
513    PbLib.module.loadDependencies = function (modName, dependencyString) {
514
515        modName = modName.toLowerCase();
516        if (typeof PbLib.modules[modName] === 'undefined' ||
517            typeof PbLib.modules[modName].loaded === 'undefined' ||
518            (!PbLib.modules[modName].loading && !PbLib.modules[modName].loaded)
519        ) {
520            return false;
521        }
522
523        var dependencies = dependencyString.toLowerCase().split(',');
524
525        for (var i = 0; i < dependencies.length; i++) {
526            PbLib.modules[modName].dependencies.push(dependencies[i]);
527            if (PbLib.module.load(dependencies[i])) {
528                PbLib.modules[dependencies[i]].dependencyOf.push(modName);
529            } else {
530                return false;
531            }
532        }
533
534        return true;
535    };
536
537    PbLib.module.setLoaded = function (modName) {
538
539        modName = modName.toLowerCase();
540        if (typeof PbLib.modules[modName] === 'undefined') {
541            PbLib.modules[modName] = {
542                loaded: true,
543                loading: false,
544                dependencies: [],
545                dependencyOf: []
546            };
547        } else {
548            PbLib.modules[modName].loading = false;
549            PbLib.modules[modName].loaded = true;
550        }
551    };
552
553    /**
554     * Dialog functions
555     */
556
557    PbLib.dialog = {};
558
559    PbLib.createDialog = function (url, reqWidth, reqHeight, options) {
560        options = options || {};
561
562        PbLib.module.load('dialog');
563        options.openerElem = document.activeElement;
564
565        document.documentElement.classList.add('dialog--isOpen');
566
567        if (options.isConfirmDialog) {
568            document.documentElement.classList.add('dialog--isConfirmDialog');
569        }
570
571        return PbLib.createDialogImpl(url, reqWidth, reqHeight, options);
572    };
573
574    PbLib.createConfirmDialog = function (reqWidth, reqHeight, options) {
575        PbLib.module.load('dialog');
576        options.openerElem = document.activeElement;
577        return PbLib.createConfirmDialogImpl(reqWidth, reqHeight, options);
578    };
579
580    PbLib.dialog.getOpener = function () {
581        PbLib.module.load('dialog');
582        return PbLib.getOpenerImpl();
583    };
584
585    PbLib.dialog.isOpen = function () {
586        return document.documentElement.classList.contains('dialog--isOpen');
587    };
588
589    PbLib.destroyDialog = function (force, callback) {
590        PbLib.module.load('dialog');
591        document.documentElement.classList.remove('dialog--isOpen');
592        document.documentElement.classList.remove('dialog--isConfirmDialog');
593        return PbLib.destroyDialogImpl(force, callback);
594    };
595
596    PbLib.dialog.reScaleToContent = function () {
597        var opener = PbLib.dialog.getOpener();
598        if (typeof opener.PbLib === 'undefined' || typeof opener.PbLib.dialog === 'undefined') {
599            return;
600        }
601        if (opener.PbLib.dialog.loaderElem === null) {
602            opener.PbLib.dialog.reScaleToContent();
603        }
604    };
605
606    /**
607     * Fade an element in or out
608     * @param {HTMLElement} elem - The html element to fade
609     * @param {number} from - The opacity percentage to start with (0-1)
610     * @param {number} to - The opacity  percentage to end with (0-1)
611     * @param {number} fadeTime - The total time of the fade
612     * @param {number} onFinished - The function call to execute when fading is done
613     * @param {number} frameRate - The amount of steps per second to take
614     * @return {null|boolean}
615     */
616    PbLib.fade = function (elem, from, to, fadeTime, onFinished, frameRate) {
617
618        if (!elem) {
619            return false;
620        } else if (!elem.parentNode) {
621            return false;
622        }
623
624        var userAgent = window.navigator.userAgent;
625        if (userAgent.indexOf('MSIE ') > 0) {
626            //IE element needs to have layout for alpha filter to work
627            elem.style.zoom = '1';
628        }
629
630        if (!frameRate) {
631            frameRate = 12;
632        }
633
634        fadeTime = Math.max(1, parseInt(fadeTime));
635        from = Math.min(1, parseInt(from));
636        to = Math.max(0, parseInt(to));
637
638        var period = (1 / frameRate);
639        var step = period * (to - from);
640        var stop = false;
641
642        if (typeof elem.curOpacity === 'undefined') {
643            elem.curOpacity = from;
644        } else {
645            elem.curOpacity += step;
646            if (to > from) {
647                if (elem.curOpacity >= to) {
648                    elem.curOpacity = to;
649                    stop = true;
650                }
651            } else if (elem.curOpacity <= to) {
652                elem.curOpacity = to;
653                stop = true;
654            }
655        }
656
657        if (elem.curOpacity > 0) {
658            if (elem.style.display === 'none') {
659                elem.style.display = '';
660            }
661            if (elem.style.visibility === 'hidden') {
662                elem.style.visibility = 'visible';
663            }
664        }
665
666        elem.style.opacity = elem.curOpacity;
667
668        if (stop) {
669            if (onFinished) {
670                onFinished(elem);
671            }
672            return null;
673        }
674
675        setTimeout(function () {
676            PbLib.fade(elem, from, to, fadeTime, onFinished, frameRate);
677        }, (1000 * period));
678    };
679
680    /**
681     * Fade an element in
682     * @param {HTMLElement} elem - HTML element to fade in
683     * @param {number} step - Opacity to increase per step (0-1)
684     * @param {number} time - Time in milliseconds per step
685     */
686    PbLib.fadeIn = function (elem, step, time) {
687        PbLib.fade(elem, 0, 1, step * time, false, 1000 / time);
688    };
689
690    /**
691     * Fade an element out
692     * @param {HTMLElement} elem - HTML element to fade out
693     * @param {number} step - Opacity to decrease per step (0-1)
694     * @param {number} time - Time in milliseconds per step
695     * @param {boolean} removeAfter - Remove element when faded out
696     */
697    PbLib.fadeOut = function (elem, step, time, removeAfter) {
698        var onFinished = false;
699        if (removeAfter) {
700            onFinished = function () {
701                if (elem.parentNode) {
702                    elem.parentNode.removeChild(elem);
703                }
704            };
705        }
706        PbLib.fade(elem, 1, 0, step * time, onFinished, 1000 / time);
707    };
708
709    PbLib.setPos = function (elem, posLeft, posTop) {
710        if (!posTop && typeof posLeft === 'object') {
711            // Result of getPos given
712            posTop = posLeft.top;
713            posLeft = posLeft.left;
714        }
715
716        if (typeof elem.posDiff === 'undefined') {
717            var startPos = {left: elem.offsetLeft, top: elem.offsetTop};
718
719            positionAbsoluteOnSameSpot(elem);
720
721            var curPos = {left: elem.offsetLeft, top: elem.offsetTop};
722            elem.posDiff = {left: curPos.left - startPos.left, top: curPos.top - startPos.top};
723        }
724
725        elem.style.left = parseInt(posLeft) + elem.posDiff.left + 'px';
726        elem.style.top = parseInt(posTop) + elem.posDiff.top + 'px';
727
728        function positionAbsoluteOnSameSpot (el) {
729            if (window.getComputedStyle(el).getPropertyValue('position') === 'absolute') {
730                return;
731            }
732
733            var offsetParent = el.offsetParent;
734            var eOffset = el.getBoundingClientRect();
735            var pOffset = offsetParent.getBoundingClientRect();
736            var offsetTop = eOffset.top - pOffset.top;
737            var offsetLeft = eOffset.left - pOffset.left;
738
739            el.setStyle({
740                position: 'absolute',
741                top: offsetTop + 'px',
742                left: offsetLeft + 'px',
743                width: eOffset.width + 'px',
744                height: eOffset.height + 'px'
745            });
746        }
747    };
748
749    /**
750     * Window/Popup functions
751     */
752
753    PbLib.getWindowSize = function (win) {
754
755        win = win || window;
756
757        if (typeof win.chromeSize === 'undefined') {
758            PbLib.setChromeSize(win);
759        }
760
761        var size = {x: win.chromeSize.x, y: win.chromeSize.y};
762        if (typeof win.innerWidth !== 'undefined') {
763            size.x += win.innerWidth;
764            size.y += win.innerHeight;
765        } else if (typeof win.document.clientWidth !== 'undefined') {
766            size.x += win.document.clientWidth;
767            size.y += win.document.clientHeight;
768        } else if (typeof win.documentElement !== 'undefined') {
769            if (typeof win.documentElement.clientWidth !== 'undefined') {
770                size.x += win.documentElement.clientWidth;
771                size.y += win.documentElement.clientHeight;
772            }
773        } else if (typeof win.document.documentElement.clientWidth !== 'undefined') {
774            size.x += win.document.documentElement.clientWidth;
775            size.y += win.document.documentElement.clientHeight;
776        }
777
778        return size;
779    };
780
781    PbLib.setWindowSize = function (width, height, win) {
782        win = win || window;
783
784        win.resizeTo(parseInt(width), parseInt(height));
785    };
786
787    PbLib.setChromeSize = function (win) {
788        win = win || window;
789        win.chromeSize = {x: 0, y: 0};
790
791        var startSize = PbLib.getWindowSize(win);
792        PbLib.setWindowSize(startSize.x, startSize.y, win);
793        var curSize = PbLib.getWindowSize(win);
794
795        win.chromeSize = {x: startSize.x - curSize.x, y: startSize.y - curSize.y};
796
797        PbLib.setWindowSize(startSize.x + win.chromeSize.x, startSize.y + win.chromeSize.y, win);
798    };
799
800    PbLib.availScreenWidth = window.screen.availWidth || 1024;
801    PbLib.availScreenHeight = window.screen.availHeight || 768;
802    PbLib.centerWindow = function (win) {
803        win = win || window;
804
805        var winS = PbLib.getWindowSize(win);
806        win.moveTo((PbLib.availScreenWidth - winS.x) / 2, (PbLib.availScreenHeight - winS.y) / 2);
807    };
808
809    PbLib.scaleWindowToContent = function (scaleWidth, scaleHeight, win) {
810        win = win || window;
811        if (typeof scaleHeight === 'undefined') {
812            scaleHeight = true;
813        }
814        if (typeof scaleWidth === 'undefined') {
815            scaleWidth = false;
816        }
817
818        var doc = win.document;
819        if (!doc.body) {
820            return false;
821        }
822
823        if (!scaleWidth && !scaleHeight) {
824            return true;
825        }
826
827        var curSize = PbLib.getWindowSize(win);
828        var targetWidth = curSize.x;
829        var targetHeight = curSize.y;
830        var curScroll = 0;
831
832        if (scaleWidth) {
833            if (doc.all) {
834                do {
835                    curScroll += 200;
836                    win.scrollTo(curScroll, 0);
837                } while (Math.max(doc.body.scrollLeft, doc.body.parentNode.scrollLeft) >= curScroll);
838                targetWidth += Math.max(doc.body.scrollLeft, doc.body.parentNode.scrollLeft);
839            } else {
840                do {
841                    curScroll += 200;
842                    win.scrollTo(curScroll, 0);
843                } while (win.scrollX >= curScroll);
844                targetWidth += win.scrollX;
845            }
846            win.scrollTo(0, 0);
847            targetWidth = Math.min(PbLib.availScreenWidth, targetWidth + 1);
848            win.moveTo((PbLib.availScreenWidth - targetWidth) / 2, (PbLib.availScreenHeight - targetHeight) / 2);
849            win.resizeTo(targetWidth, targetHeight);
850        }
851        if (scaleHeight) {
852            if (doc.all) {
853                do {
854                    curScroll += 200;
855                    win.scrollTo(0, curScroll);
856                } while (Math.max(doc.body.scrollTop, doc.body.parentNode.scrollTop) >= curScroll);
857                targetHeight += Math.max(doc.body.scrollTop, doc.body.parentNode.scrollTop);
858            } else {
859                do {
860                    curScroll += 200;
861                    win.scrollTo(0, curScroll);
862                } while (win.scrollY >= curScroll);
863                targetHeight += win.scrollY;
864            }
865            win.scrollTo(0, 0);
866            targetHeight = Math.min(PbLib.availScreenHeight, targetHeight + 1);
867        }
868
869        win.moveTo((PbLib.availScreenWidth - targetWidth) / 2, (PbLib.availScreenHeight - targetHeight) / 2);
870        win.resizeTo(targetWidth, targetHeight);
871    };
872
873    /**
874     * Add function to Elements
875     */
876
877    Element.prototype.isInDialog = function (onlyDirect) {
878        if (getParentWithClassName(this, 'div.pbdialogcontainer')) {
879            return true;
880        }
881
882        var found = false;
883        var dialogFrames = isTopAccessible()
884            ? window.top.document.querySelectorAll('div.pbdialogcontainer iframe')
885            : [];
886
887        dialogFrames.forEach(function (frame) {
888            if (frame.contentWindow === window || (!onlyDirect && window.parent === frame.contentWindow)) {
889                found = true;
890            }
891        });
892
893        function getParentWithClassName (child, className) {
894            var node = child.parentElement;
895            while (node !== null) {
896                if (node.classList.contains(className)) {
897                    return node;
898                }
899                node = node.parentElement;
900            }
901        }
902
903        function isTopAccessible() {
904            try {
905                window.top.document;
906                return true;
907            }
908            catch (err) {
909                return false;
910            }
911        }
912
913        return found;
914    };
915
916    /**
917     * JS version of Icon::getIconPath
918     */
919
920    PbLib.getIconPath = function (iconString, size) {
921        size = size || 16;
922        var parts = iconString.split(':');
923        var iconPart = '/icons/';
924
925        if (parts.length === 2) {
926            return PbLib.getNewURI('files/' + parts[0] + iconPart + parts[1] + size + '.png');
927        }
928        return PbLib.getNewURI('ui/uibase' + iconPart + size + '/' + iconString + '.png');
929    };
930
931    return PbLib;
932
933})(window, document);
934
935document.documentElement.classList.add('has-js');
936document.documentElement.classList.remove('no-js');
937document.documentElement.classList.add((('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)) ? 'has-touch' : 'no-touch');
938
939// ESC closes the topmost dialog; in order to do that each window and dialog iframe should have a handler
940document.addEventListener('keydown', function (event) {
941    'use strict';
942    if (event.key === 'Escape') {
943        // check if a dialog is open
944        var stack = window.top.PbLib.dialog.windowStack;
945        if (typeof stack !== 'undefined' && stack.length > 0) {
946            var topWindow = stack[stack.length - 1];
947            if (topWindow.PbLib.dialog.isEnabledEscapeClose) {
948                event.preventDefault();
949                PbLib.destroyDialog();
950            }
951        }
952    }
953});
954
955/**
956 * Polyfill for the CustomEvent() constructor functionality in Internet Explorer 9 and higher. This is not optimal
957 * to have here but it's the only functionality that would prevent us from getting rid of PrototypeJS, so far.
958 * Copied from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill
959 */
960(function () {
961    'use strict';
962
963    if (typeof window.CustomEvent === 'function') {
964        return false;
965    }
966
967    function CustomEvent (event, params) {
968        params = params || { bubbles: false, cancelable: false, detail: null };
969        var evt = document.createEvent('CustomEvent');
970        evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
971        return evt;
972    }
973
974    window.CustomEvent = CustomEvent;
975})();
976
977/**
978 * Ajax.Request.abort
979 * extend the prototype.js Ajax.Request object so that it supports an abort method
980 * Copied from: http://blog.pothoven.net/2007/12/aborting-ajax-requests-for-prototypejs.html
981 */
982if (typeof Ajax !== 'undefined') {
983    Ajax.Request.prototype.abort = function () {
984        // prevent and state change callbacks from being issued
985        this.transport.onreadystatechange = Prototype.emptyFunction;
986        // abort the XHR
987        this.transport.abort();
988        // update the request counter
989        Ajax.activeRequestCount = Math.max(Ajax.activeRequestCount - 1, 0);
990    };
991}

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.