PageSourceSearch

https://www.ate.gov.hk/common/js/global.js

js ate.gov.hk collected 2026-10-01 23:43:19 UTC 25,654 bytes, 713 lines download raw bytes

1var currentPage = 1;
2var maxPage = 0;
3var mobileDevice = false;
4
5var MobileMenu = {
6    init: function () {
7        $(document).ready(function () {
8            MobileMenu.resize();
9
10            $(window).on('resize', MobileMenu.resize);
11        });
12    },
13
14    resize: function () {
15        var win = $(window);
16        if (win.innerWidth() <= 991) {
17            $('header .navbar-collapse').css('top', 0);
18        }
19        else {
20            $('header .navbar-collapse').css('top', 'unset');
21        }
22    }
23}
24
25
26function generatePager(lang, totalPage, page) {
27    var content = '';
28
29    var backLabel = 'Previous Page';
30    var nextLabel = 'Next Page';
31    var pageLabel = 'Page ';
32
33    if (lang == 'TC') {
34        backLabel = '上一頁';
35        nextLabel = '下一頁';
36        pageLabel = '頁';
37    }
38    else if (lang == 'SC') {
39        backLabel = '上一页';
40        nextLabel = '下一页';
41        pageLabel = '页';
42    }
43
44    if (totalPage > 1) {
45        content += '<ul>' + "\n";
46
47        content += '<li><a href="javascript:void(0);" class="previousPage" title="' + backLabel + '"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>' + "\n";
48
49        var startIndex = 1;
50        var endIndex = totalPage;
51
52        if (totalPage > 6) {
53
54            if (totalPage >= 5 && page >= 5) {
55                content += '<li><a href="javascript:void(0);" data-page="1" title="' + pageLabel + '1" class="goPage">1</a>' + "\n";
56                content += '<li class="ellipsis">...</li>' + "\n";
57                startIndex = page - 1;
58            }
59
60            if (totalPage - page <= 3) {
61                startIndex = totalPage - 4;
62            }
63
64            if (totalPage > 5) {
65                if (page <= 4) {
66                    endIndex = 5;
67                }
68                else if (totalPage - page > 3) {
69                    endIndex = page + 1;
70                }
71                else {
72                    endIndex = totalPage;
73                }
74            }
75
76            for (var i = startIndex; i <= endIndex; i++) {
77                content += '<li><a href="javascript:void(0);" data-page="' + i +'" title="' + pageLabel + i + '" class="goPage' + (i == page ? ' active' : '') + '">' + i + '</a>' + "\n";
78            }
79
80            if (totalPage - page > 3) {
81                content += '<li class="ellipsis">...</li>' + "\n";
82                content += '<li><a href="javascript:void(0);" data-page="' + totalPage + '" title="' + pageLabel + '' + totalPage + '" class="goPage">' + totalPage + '</a>' + "\n";
83            }
84
85        }
86        else {
87            for (var i = startIndex; i <= endIndex; i++) {
88                content += '<li><a href="javascript:void(0);" data-page="' + i +'" title="' + pageLabel + i + '" class="goPage' + (i == page ? ' active' : '') + '">' + i + '</a>' + "\n";
89            }
90        }
91
92        content += '<li><a href="javascript:void(0);" class="nextPage" title="' + nextLabel + '"><i class="fa fa-chevron-right" aria-hidden="true"></i></a>' + "\n";
93
94        content += '</ul>' + "\n";
95    }
96
97    $('.page .content .pager').html(content);
98
99
100    $('.previousPage').on('click', function() {
101        if (currentPage - 1 > 0) {
102            var lang = curLanguage;
103            currentPage -= 1;
104
105            showResults(lang, currentPage);
106            generatePager(lang, maxPage, currentPage);
107            setHash(currentPage);
108        }
109        return false;
110    });
111
112    $('.nextPage').on('click', function() {
113        if (currentPage + 1 <= maxPage) {
114            var lang = curLanguage;
115            currentPage += 1;
116
117            showResults(lang, currentPage);
118            generatePager(lang, maxPage, currentPage);
119            setHash(currentPage);
120        }
121        return false;
122    });
123
124    $('.goPage').on('click', function() {
125        var newPage = $(this).data('page');
126
127        if (newPage > 0 && newPage <= maxPage) {
128            var lang = curLanguage;
129            currentPage = newPage;
130
131            showResults(lang, currentPage);
132            generatePager(lang, maxPage, currentPage);
133            setHash(currentPage);
134        }
135        return false;
136    });
137
138}
139
140
141function generatePager(lang, totalPage, page, query) {
142    var content = '';
143
144    if (typeof query == "undefined") {
145        query = '';
146    }
147
148    var backLabel = 'Previous Page';
149    var nextLabel = 'Next Page';
150    var pageLabel = 'Page ';
151
152    if (lang == 'tc') {
153        backLabel = '上一頁';
154        nextLabel = '下一頁';
155        pageLabel = '頁';
156    }
157    else if (lang == 'sc') {
158        backLabel = '上一页';
159        nextLabel = '下一页';
160        pageLabel = '页';
161    }
162
163    if (totalPage > 1) {
164        content += '<ul>' + "\n";
165
166        content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=' + (parseInt(page) - 1 > 0 ? parseInt(page) - 1 : 1) + '" class="previousPage" title="' + backLabel + '"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>' + "\n";
167
168        var startIndex = 1;
169        var endIndex = totalPage;
170
171        if (totalPage > 6) {
172
173            if (totalPage >= 5 && page >= 5) {
174                content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=1" data-page="1" title="' + pageLabel + '1" class="goPage">1</a>' + "\n";
175                content += '<li class="ellipsis">...</li>' + "\n";
176                startIndex = parseInt(page) - 1;
177            }
178
179            if (totalPage - page <= 3) {
180                startIndex = totalPage - 4;
181            }
182
183            if (totalPage > 5) {
184                if (page <= 4) {
185                    endIndex = 5;
186                }
187                else if (totalPage - page > 3) {
188                    endIndex = parseInt(page) + 1;
189                }
190                else {
191                    endIndex = totalPage;
192                }
193            }
194
195            for (var i = startIndex; i <= endIndex; i++) {
196                content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=' + i + '" data-page="' + i +'" title="' + pageLabel + i + '" class="goPage' + (i == page ? ' active' : '') + '">' + i + '</a>' + "\n";
197            }
198
199            if (totalPage - page > 3) {
200                content += '<li class="ellipsis">...</li>' + "\n";
201                content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=' + totalPage + '" data-page="' + totalPage + '" title="' + pageLabel + '' + totalPage + '" class="goPage">' + totalPage + '</a>' + "\n";
202            }
203
204        }
205        else {
206            for (var i = startIndex; i <= endIndex; i++) {
207                content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=' + i + '" data-page="' + i +'" title="' + pageLabel + i + '" class="goPage' + (i == page ? ' active' : '') + '">' + i + '</a>' + "\n";
208            }
209        }
210
211        content += '<li><a href="' + query + (query == '' ? '?' : '&') + 'p=' + (parseInt(page) + 1 <= totalPage ? parseInt(page) + 1 : totalPage) + '" class="nextPage" title="' + nextLabel + '"><i class="fa fa-chevron-right" aria-hidden="true"></i></a>' + "\n";
212
213        content += '</ul>' + "\n";
214    }
215
216    $('.page .content .pager').html(content);
217
218}
219
220function setHash(hash) {
221    if (history.pushState) {
222        // IE10, Firefox, Chrome, etc.
223        window.history.pushState(null, null, '#' + hash);
224    } else {
225        // IE9, IE8, etc
226        window.location.hash = '#!' + hash;
227    }
228}
229
230function getParameterByName(name, url) {
231    if (!url) url = window.location.href;
232    name = name.replace(/[\[\]]/g, "\\$&");
233    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
234        results = regex.exec(url);
235    if (!results) return '';
236    if (!results[2]) return '';
237    return decodeURIComponent(results[2].replace(/\+/g, " "));
238}
239
240function goTop() {
241    var aTag = $("#top");
242    $('html,body').animate({scrollTop: aTag.offset().top},'slow');
243    aTag.focus();
244    // $('html,body').animate({scrollTop: 0}, 1000, function () {
245    // });
246}
247
248function checkEnvironment() {
249    var isChrome = false;
250    var isFirefox = false;
251    var isSafari = false;
252    var isEdge = false;
253    var isIE = false;
254    var isIOSDevice = false;
255    var isMSTouchDevice = false;
256
257    if ($('body').hasClass('chrome') && !$('body').hasClass('edge')) {
258        isChrome = true;
259    } else if ($('body').hasClass('firefox')) {
260        isFirefox = true;
261    } else if ($('body').hasClass('safari')) {
262        isSafari = true;
263    } else if ($('body').hasClass('edge')) {
264        isEdge = true;
265    } else if ($('body').hasClass('trident')) {
266        isIE = true;
267    }
268    isIOSDevice = $('body').hasClass('ios') && $('body').hasClass('mobile');
269    if ((('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) && (!isSafari)) {
270        $('body').addClass('isMSTouchDevice');
271        isMSTouchDevice = true;
272    }
273    mobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
274}
275
276function initShareBtns() {
277    var $holder = $('.share-btns');
278    var $btn = $holder.find('.share-btns__btn');
279    var $windowCount = 0;
280    var url = window.location.href;
281    //init QR
282    new QRCode(document.getElementById("wc-qrcode"), url);
283    $('#wc-qrcode').find('canvas').remove();
284    $btn.click(function (event) {
285        event.preventDefault();
286        var $thisBtn = $(this);
287        var pageShareTitle = encodeURIComponent(document.getElementsByTagName("title")[0].innerHTML);
288        var pageShareContent = window.location.href;
289        var href = "";
290        var type = 'default';
291        var pageUrl = encodeURIComponent(window.location.href);
292        if ($thisBtn.hasClass('share-btns__btn--fb')) {
293            href = "https://www.facebook.com/sharer/sharer.php?u=" + pageUrl;
294        } else if ($thisBtn.hasClass('share-btns__btn--email')) {
295            href = "mailto:?subject=" + pageShareTitle + "&body=" +pageShareTitle+'%0A'+ pageUrl;
296        } else if ($thisBtn.hasClass('share-btns__btn--wa')) {
297            if(mobileDevice){
298                href = "whatsapp://send?text=" + pageShareTitle + ": " + pageUrl;
299            }else{
300                href = "https://web.whatsapp.com/send?text=" + pageShareTitle + ": " + pageUrl;
301            }
302        } else if ($thisBtn.hasClass('share-btns__btn--tw')) {
303            href = "http://x.com/share?text=" + pageShareTitle + ": " + "&url=" + pageUrl;
304        } else if ($thisBtn.hasClass('share-btns__btn--wb')) {
305            href = "http://service.weibo.com/share/share.php?url=" + pageUrl + "&title=" + pageShareTitle;
306        } else if ($thisBtn.hasClass('share-btns__btn--wc')) {
307            href = window.location.href;
308            type = 'wechat';
309        } else if ($thisBtn.hasClass('share-btns__btn--ln')) {
310            href = "https://social-plugins.line.me/lineit/share?url=" + pageUrl;
311        }
312
313        PopupCenter(href, "shareWindow_" + $windowCount, 600, 500, type);
314        $windowCount++;
315    });
316}
317
318function getTxtByLang(arrayTxt) {
319    var currentLang = 0;
320    switch (curLanguage ) {
321        case 'tc':
322            currentLang = 1;
323            break;
324        case 'sc':
325            currentLang = 2;
326            break;
327        default:
328            currentLang = 0;
329    }
330    return (arrayTxt[currentLang]);
331}
332
333function PopupCenter(url, title, w, h, type) {
334    if (type == 'wechat') {
335        var html = $('.wc-qrcode').html();
336        var wechatTitle = getTxtByLang(['WeChat Share', '微信分享', '微信分享']);
337        var newWindow = window.open(url, '_blank', 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); //��
338        newWindow.document.write('<!DOCTYPE html><html><head><title>' + wechatTitle + '</title></head><body></body></html>');
339        newWindow.document.write(html);
340    } else {
341        // Fixes dual-screen position                         Most browsers      Firefox
342        var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
343        var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
344
345        var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
346        var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
347
348        var left = ((width / 2) - (w / 2)) + dualScreenLeft;
349        var top = ((height / 2) - (h / 2)) + dualScreenTop;
350        var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
351
352        // Puts focus on the newWindow
353        if (window.focus) {
354            newWindow.focus();
355        }
356    }
357}
358
359function handleFocus() {
360
361    $('header a.control-icon.control-icon--contactus').focus(function(e) {
362        e.preventDefault();
363        if (whatInput.ask() === 'keyboard') {
364            $('.tools-sub-holder').removeClass('show');
365            $('.tools-sub-holder').data('bs-popper', '');
366            $(this).removeClass('show');
367            $(this).attr('aria-expanded', 'false');
368        }
369    });
370
371    $('.share > button').focus(function(e) {
372        e.preventDefault();
373        if (whatInput.ask() === 'keyboard') {
374            if ($('.tools-sub-holder').hasClass('show')) {
375                $('.tools-sub-holder').removeClass('show');
376                $('.tools-sub-holder').data('bs-popper', '');
377                $(this).removeClass('show');
378                $(this).attr('aria-expanded', 'false');
379            }
380            else {
381                $('.tools-sub-holder').addClass('show');
382                $('.tools-sub-holder').attr('data-bs-popper', 'static');
383                $(this).addClass('show');
384                $(this).attr('aria-expanded', 'true');
385
386            }
387        }
388    });
389
390    $('header a.control-icon.control-icon--print').focus(function(e) {
391        e.preventDefault();
392        if (whatInput.ask() === 'keyboard') {
393            $('.tools-sub-holder').removeClass('show');
394            $('.tools-sub-holder').data('bs-popper', '');
395            $(this).removeClass('show');
396            $(this).attr('aria-expanded', 'false');
397        }
398    });
399
400    $('.tools-sub-holder button').focus(function(e) {
401        e.preventDefault();
402        if (whatInput.ask() === 'keyboard') {
403            $('.tools-sub-holder').addClass('active');
404        }
405    });
406
407    $('header a.control-icon').focus(function(e) {
408        e.preventDefault();
409        if (whatInput.ask() === 'keyboard') {
410            $('header button.control-icon--language').parent().addClass('collapsed');
411            $('.tools-sub-holder').removeClass('active');
412        }
413    });
414
415    $('.rounded-circle').focus(function(e) {
416        e.preventDefault();
417        if (whatInput.ask() === 'keyboard') {
418            // $('.tools-sub-holder').removeClass('active');
419        }
420    });
421
422    $('header button.control-icon--language').focus(function(e) {
423        e.preventDefault();
424        if (whatInput.ask() === 'keyboard') {
425            if ($(this).parent().hasClass('collapsed')) {
426                $(this).parent().removeClass('collapsed');
427            }
428            else {
429                $(this).parent().addClass('collapsed');
430            }
431        }
432    });
433
434    $("header .container ul.nav > li.nav-item > div > a").focus(function(e) {
435        e.preventDefault();
436        if (whatInput.ask() === 'keyboard') {
437            $(this).parent().parent().parent().find("li").removeClass('focus');
438            if ($(this).parent().parent().children("div")) {
439                $(this).parent().parent().addClass('focus');
440                $(this).parent().find("a.cursor").removeClass('collapsed');
441                $(this).parent().find("a.cursor").attr('aria-expanded', 'true');
442                $(this).parent().find("div").addClass('show');
443            }
444        }
445    });
446
447    // $('header button.hamburger').focus(function(e) {
448    //     e.preventDefault();
449    //     if (whatInput.ask() === 'keyboard') {
450    //         $(this).trigger('click');
451    //     }
452    // });
453
454
455    $('.btnPrint').focus(function(e) {
456        e.preventDefault();
457        if (whatInput.ask() === 'keyboard') {
458            $('.tools-sub-holder').removeClass('active');
459            // $('header .container ul.nav').find("div").hide();
460        }
461    });
462
463    $('a.navbar-brand').focus(function(e) {
464        e.preventDefault();
465        if (whatInput.ask() === 'keyboard') {
466            $('header button.control-icon--language').parent().addClass('collapsed');
467            $('header .container ul.nav').find("li").removeClass('focus');
468            $('header .container ul.nav').find("a.cursor").addClass('collapsed');
469            $('header .container ul.nav').find("a.cursor").attr('aria-expanded', 'false');
470            $('header .container ul.nav').find("div").removeClass('show');
471            if ($('#navbarCollapse').hasClass('show')) {
472                $('#navbarCollapse').removeClass('show');
473                $('.js-hamburger').removeClass('is-active').removeClass('collapsed');
474            }
475        }
476    });
477
478    $('form.form-inline button').focus(function(e) {
479        e.preventDefault();
480        if (whatInput.ask() === 'keyboard') {
481            $('header .container ul.nav').find("li").removeClass('focus');
482            $('header .container ul.nav').find("a.cursor").addClass('collapsed');
483            $('header .container ul.nav').find("a.cursor").attr('aria-expanded', 'false');
484            $('header .container ul.nav').find("div").removeClass('show');
485        }
486    });
487
488    $('li.breadcrumb-item a').focus(function(e) {
489        e.preventDefault();
490        if (whatInput.ask() === 'keyboard') {
491            $('header .container ul.nav').find("li").removeClass('focus');
492            $('header .container ul.nav').find("a.cursor").addClass('collapsed');
493            $('header .container ul.nav').find("a.cursor").attr('aria-expanded', 'false');
494            $('header .container ul.nav').find("div").removeClass('show');
495            if ($('#navbarCollapse').hasClass('show')) {
496                $('#navbarCollapse').removeClass('show');
497                $('.js-hamburger').removeClass('is-active').removeClass('collapsed');
498            }
499        }
500    });
501
502    /** Faq **/
503    $('.faq .headeritem > a').focus(function(e) {
504        e.preventDefault();
505        if (whatInput.ask() === 'keyboard') {
506            if ($(this).hasClass('collapsed')) {
507                $(this).trigger('click');
508            }
509        }
510    });
511
512    /** Home **/
513    $('.home-section3 .controls .bd-highlight a').focus(function(e) {
514        e.preventDefault();
515        if (whatInput.ask() === 'keyboard') {
516            if (!$(this).hasClass('active')) {
517                $(this).trigger('click');
518            }
519        }
520    });
521    /** End of Home **/
522
523}
524
525function checkFocus() {
526    console.log('checkFocus');
527    if (!$('header .form-inline .control-icon').is(":focus")) {
528        $('header .form-inline').removeClass('active-form');
529    }
530    else {
531        setTimeout(checkFocus, 500);
532    }
533}
534
535const makeRequest = async (params = {}, url) => {
536    let data = params.query || {};
537    let post = {
538        url: url,
539        data: data,
540        method: params.method || 'GET',
541        cache: false
542    };
543
544    console.log(params);
545
546    if (params.extra) {
547        console.log(params.extra);
548        if (params.extra.hasOwnProperty('headers')) post.headers = params.extra.headers;
549        if (params.extra.hasOwnProperty('processData')) post.processData = params.extra.processData;
550        if (params.extra.hasOwnProperty('contentType')) post.contentType = params.extra.contentType;
551        if (params.extra.hasOwnProperty('processData')) post.processData = params.extra.processData;
552        if (params.extra.hasOwnProperty('dataType')) post.dataType = params.extra.dataType;
553        if (params.extra.hasOwnProperty('url')) post.url = post.url + params.extra.url;
554    }
555
556    console.log(post);
557
558    let result;
559    try {
560        result = await $.ajax(post);
561    } catch (error) {
562        console.error(error);
563    }
564
565    return result;
566}
567
568$(document).ready(function() {
569    AOS.init();
570    checkEnvironment();
571    initShareBtns();
572    handleFocus();
573
574    // $('.control-icon--language').click(function(e) {
575    //     if ($(this).parent().hasClass('collapsed')) {
576    //         $(this).parent().removeClass('collapsed');
577    //     }
578    //     else {
579    //         $(this).parent().addClass('collapsed');
580    //     }
581    // });
582
583    MobileMenu.init();
584
585    $(window).scroll(function () {
586        var htmlTop = $(document).scrollTop();
587        if (htmlTop > 500) {
588            $(".backtotop").fadeIn();
589        } else {
590            $(".backtotop").fadeOut();
591        }
592    });
593
594    // $('.change-language').click(function() {
595    //     var url = $(this).attr('href');
596    //     var hash = window.location.hash;
597    //     if (hash != '') {
598    //         url += hash;
599    //         $(this).attr('href', url);
600    //     }
601    //     return true;
602    // });
603
604    $('header button.hamburger').click(function(e) {
605        $('header button.control-icon--language').parent().addClass('collapsed');
606        return true;
607    });
608
609    $('header nav ul.nav li > a.cursor').click(function() {
610        if ($(this).parent().hasClass('focus')) {
611            $(this).parent().removeClass('focus');
612        }
613        else {
614            $(this).parent().addClass('focus');
615        }
616        return true;
617    })
618
619    // $('header .form-inline .form-control').focus(function() {
620    //     $(this).parent().addClass('active-form');
621    // });
622    //
623    // $('header .form-inline .form-control').focusout(function() {
624    //     setTimeout(checkFocus, 500);
625    // });
626
627
628    $('#mobaccordion > li.nav-item > div > a.cursor').on('click', function() {
629        console.log('click');
630        $(this).parent().parent().toggleClass('show');
631
632        if ($(this).parent().parent().hasClass('show')) {
633            $('#mobaccordion > li.nav-item').addClass('d-none');
634            $('#mobaccordion > li.nav-item.show').removeClass('d-none');
635        }
636    });
637
638    $('#mobaccordion > li.nav-item > ul.children').on('hidden.bs.collapse', function() {
639        if (!$(this).hasClass('show')) {
640            console.log('hidden.bs.collapse');
641            $('#mobaccordion > li.nav-item').removeClass('d-none');
642        }
643    });
644
645    $('#mobaccordion > li.nav-item > ul.children > li > div > a.cursor').on('click', function() {
646        console.log('click');
647        $(this).parent().parent().toggleClass('show');
648
649        if ($(this).parent().parent().hasClass('show')) {
650            $('#mobaccordion > li.nav-item').addClass('d-none');
651            $('#mobaccordion > li.nav-item.show > div').addClass('d-none');
652            $('#mobaccordion > li.nav-item.show').removeClass('d-none');
653            $('#mobaccordion > li.nav-item > ul.children > li').addClass('d-none');
654            $('#mobaccordion > li.nav-item.show > ul.children > li.show').removeClass('d-none');
655        }
656    });
657
658    $('#mobaccordion > li.nav-item > ul.children > li > ul.subchildren').on('hidden.bs.collapse', function() {
659        if (!$(this).hasClass('show')) {
660            console.log('hidden.bs.collapse');
661            $('#mobaccordion > li.nav-item.show > ul.children > li').removeClass('d-none');
662            $('#mobaccordion > li.nav-item.show').removeClass('d-none');
663            $('#mobaccordion > li.nav-item.show > div').removeClass('d-none');
664        }
665    });
666
667    $.each($('main span.new'), function (i, item) {
668        let valid = true;
669        const expire = $(item).data('expire');
670        if (expire !== '') {
671            const expireDate = new Date(expire);
672            const now = new Date();
673
674            if (expireDate < now) {
675                valid = false;
676            }
677        }
678        if (valid) {
679            $(item).removeClass('d-none');
680        }
681    });
682
683    $.each($('.page .container table'), function(i, table) {
684        $(table).wrap('<div class="table-responsive"></div>');
685    });
686
687    $('.control-icon--print').on('click', function(e) {
688        e.preventDefault();
689        window.print();
690    });
691
692    if (typeof Fancybox != "undefined") {
693        const fancyboxLanguages = {'en': Fancybox.l10n.en, 'tc': Fancybox.l10n.zh_TW, 'sc': Fancybox.l10n.zh_CN};
694
695        Fancybox.bind("[data-fancybox]", {
696            // Your custom options
697            l10n: fancyboxLanguages[curLanguage],
698        });
699    }
700
701    localStorage.setItem("curLanguage", curLanguage);
702
703    // document.querySelector('#navbarSideCollapse').addEventListener('click', () => {
704    //     document.querySelector('.offcanvas-collapse').classList.toggle('open')
705    // })
706
707    $.each($('.page .content a'), function (i, item) {
708        if ($(item).attr('href') != undefined && $(item).attr('target') != undefined && $(item).attr('target') == '_blank') {
709            $(item).attr('rel', 'noopener noreferrer');
710        }
711    });
712
713});

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.