PageSourceSearch

https://www.ynlib.cn/content/_common/base/js/power.js?v=4KwewJi3dU-c0a8yLuEn265irsifeR5QjTfB4r5sUco

js ynlib.cn collected 2026-10-02 16:33:35 UTC 46,119 bytes, 1,207 lines download raw bytes

1(function () {
2    $(function () {
3        var videoAll = $("body").find('.edui-upload-video,.edui-video-video');
4        var videoDiv = $('[data-ui="video"]');
5        var embedAll = $("body").find('embed[class="edui-faked-video"]');
6        var videoEdui = $("body").find('.edui-faked-video');
7        if (videoAll.length > 0 || videoDiv.length > 0 || embedAll.length > 0 || videoEdui.length > 0) {
8            // 加载ckplayer.js文件
9            var ckTag = '<script></script>';
10            var domCk = $.parseHTML(ckTag);
11            $(domCk).attr('src', '/content/_common/assets/ckplayer/ckplayer.js');
12            $(domCk).on('load',
13                function () {
14                }).appendTo($('body'));
15
16            if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.") {
17                // IE8下加载swfobject.js文件
18                var swfObjectTag = '<script></script>';
19                var domSwfObject = $.parseHTML(swfObjectTag);
20                $(domSwfObject).attr('src', '/content/_common/assets/scripts/swfobject.js');
21                $(domSwfObject).on('load',
22                    function () {
23                    }).appendTo($('body'));
24            }
25
26            // 加载视频播放.js文件
27            var scriptTag = '<script></script>';
28            var dom = $.parseHTML(scriptTag);
29            $(dom).attr('src', '/content/_common/base/js/power.videoreversion.js');
30            $(dom).on('load', function () { }).appendTo($('body'));
31        }
32    });
33
34    //广告。
35    $(function () {
36        /**
37         * 广告漂浮版位。
38         */
39        function advertisementFloat(floatPositions) {
40            //var floatPositions = $("div[data-power-ui='advertisement_float']");
41            $.each(floatPositions,
42                function () {
43                    var floatposition = $(this);
44                    var width = floatposition.data().width; //版位宽度
45                    var height = floatposition.data().height; //版位高度
46
47                    //计算关闭按钮的位置
48                    var close = floatposition.children('.close');
49                    switch (floatposition.data().closeButtonPosition) {
50                        case 'UpperRight':
51                            close.css('left', width - 20);
52                            break;
53                        case 'LowerRight':
54                            close.css('left', width - 20).css('top', height - 20);
55                            break;
56                        case 'NoShow':
57                            close.hide();
58                            break;
59                    }
60
61                    //定时关闭版位
62                    var time = floatposition.data().stopTime;
63                    if (time > 0) {
64                        setTimeout(function () {
65                            floatposition.hide();
66                        },
67                            (time * 1000) >= 2147483647 ? 2147483647 : (time * 1000));
68                    }
69                });
70
71            return floatPositions;
72        }
73
74        initFloatPosition();
75
76        /*初始化漂浮广告*/
77        function initFloatPosition() {
78            var floatPositionsInfo = $("div[data-power-ui='advertisement_float']");
79            var floatPositions = advertisementFloat(floatPositionsInfo);
80            floatPositions.each(function () {
81                var floatPosition = $(this);
82                //计算版位的坐标
83                var ypos = positionCoordinate($(this));
84                floatPosition.css('top', $(this).scrollTop() + ypos);
85                //广告随滚动条滚动
86                if (floatPosition.data().enableScroll.toLowerCase() === 'true') {
87                    $(window)
88                        .scroll(function () {
89                            var nextYpos = $(this).scrollTop() + ypos;
90                            var scrollTop = $(this).scrollTop();
91                            var windowHeight = $(this).height();
92                            if ((scrollTop + windowHeight) >= document.body.scrollHeight) {
93                            } else {
94                                floatPosition.css('top', nextYpos);
95                            }
96
97                        });
98                }
99            });
100        }
101
102        //浏览器窗口大小改变时
103        window.onresize = function () {
104            var floatPositionsInfo = $("div[data-power-ui='advertisement_float']");
105            var floatPositions = advertisementFloat(floatPositionsInfo);
106            floatPositions.each(function () {
107                var floatPosition = $(this);
108                //计算版位的坐标
109                var ypos = positionCoordinate($(this));
110                //广告随滚动条滚动
111                if (floatPosition.data().enableScroll.toLowerCase() === 'true') {
112                    $(window)
113                        .scroll(function () {
114                            floatPosition.css('top', $(this).scrollTop() + ypos);
115                        });
116                }
117            });
118        };
119
120        //计算版位的坐标
121        function positionCoordinate(floatPosition) {
122            var xpos = 0;
123            var ypos = 0;
124            var width = floatPosition.data().width; //版位宽度
125            var height = floatPosition.data().height;
125 //版位高度
126            var availWidth = document.documentElement.clientWidth; //浏览器窗口可见宽度
127            var availHeight = document.documentElement.clientHeight; //浏览器窗口可见高度
128            var verticalMargin = floatPosition.data().verticalMargin / 100;
129            var horizontalMargin = floatPosition.data().horizontalMargin / 100;
130            switch (floatPosition.data().datumMark) {
131                case 'UpperLeft':
132                    xpos = availWidth * verticalMargin;
133                    xpos = xpos === availWidth ? xpos - width : xpos;
134                    ypos = availHeight * horizontalMargin;
135                    ypos = ypos === availHeight ? ypos - height : ypos;
136                    break;
137                case 'LowerRight':
138                    xpos = (availWidth - width) - (availWidth * verticalMargin);
139                    xpos = xpos < 0 ? 0 : xpos;
140                    ypos = (availHeight - height) - (availHeight * horizontalMargin);
141                    ypos = ypos < 0 ? 0 : ypos;
142                    break;
143                case 'Middle':
144                    var halfWidth = availWidth / 2;
145                    var halfheight = availHeight / 2;
146                    xpos = halfWidth + (halfWidth * verticalMargin);
147                    xpos = xpos === availWidth ? xpos - width : xpos;
148                    ypos = halfheight + (halfheight * horizontalMargin);
149                    ypos = ypos === height ? ypos - height : ypos;
150                    break;
151            }
152            floatPosition.css('z-index', 99).css('left', xpos);
153            return ypos;
154        }
155
156        initRollfloatPosition();
157
158        /*初始化随机漂浮广告*/
159        function initRollfloatPosition() {
160            initFloatRollPosition($("div[data-power-ui='advertisement_rollfloat']"));
161            initFloatSteadyPosition($("div[data-power-ui='advertisement_steadyfloat']"));
162        }
163
164        /**
165        * 广告随机漂浮。
166        */
167        function initFloatRollPosition(element) {
168            var rollfloatPositionsInfo = $(element);
169            var rollfloatPositions = advertisementFloat(rollfloatPositionsInfo);
170            rollfloatPositions.each(function () {
171                var floatPosition = $(this);
172                var ypos = positionCoordinate($(this));
173                floatPosition.css('top', ypos);
174
175                var pageX = window.pageXOffset;
176                var position = 0;
177                var width = floatPosition.data().width;
178                var height = floatPosition.data().height;
179                var vmax = 5;
180                var vmin = 2;
181                var vr = 2;
182                var offset = 1;
183                var vx = vmin + vmax * Math.random();
184                var vy = vmin + vmax * Math.random();
185                var lefts = 0;
186                var tops = 0;
187                var interval = 42;
188
189                function moves() {
190                    pageH = window.document.documentElement.offsetHeight - 4;
191
192                    tops = floatPosition.offset().top;
193                    lefts = floatPosition.offset().left;
194
195                    lefts = lefts + vx;
196                    tops = tops + vy;
197                    vx += vr * (Math.random() - 0.5);
198                    vy += vr * (Math.random() - 0.5);
199                    if (vx > (vmax + vmin)) {
200                        vx = (vmax + vmin) * offset - vx;
201                    }
202
203                    if (vx < (-vmax - vmin)) {
204                        vx = (-vmax - vmin) * offset - vx;
205                    }
206
207                    if (vy > (vmax + vmin)) {
208                        vy = (vmax + vmin) * offset - vy;
209                    }
210
211                    if (vy < (-vmax - vmin)) {
212                        vy = (-vmax - vmin) * offset - vy;
213                    }
214
215                    if (lefts <= pageX) {
216                        lefts = pageX;
217                        vx = vmin + vmax * Math.random();
218                    }
219
220                    if (lefts >= pageX + document.documentElement.clientWidth - width) {
221                        lefts = pageX + document.documentElement.clientWidth - width;
222                        vx = -vmin - vmax * Math.random();
223                    }
224
225                    if (tops <= position) {
226                        tops = position;
227                        vy = vmin + vmax * Math.random();
228                    }
229
230                    // 触底。
231                    if (tops >= (document.documentElement.clientHeight + position) - height) {
232                        tops = tops - 2;
233                        vy = -vmin - vmax * Math.random();
234                        if (tops > position + document.documentElement.clientHeight) {
235                            tops = position + document.documentElement.clientHeight - height;
236                        }
237                    }
238
239                    floatPosition.css('top', tops);
240                    floatPosition.css('left', lefts);
241                }
242
243                var move = setInterval(moves, interval);
244
245                $(document).scroll(function () {
246                    position = $(this).scrollTop();
247                });
248
249                //悬停停止
250                floatPosition.mouseover(function () {
251                    clearInterval(move);
252                });
253
254                floatPosition.mouseout(function () {
255                    move = setInterval(moves, interval);
256                });
257            });
258        }
259
260        /**
261         * 广告平稳漂浮板块。
262        */
263        function initFloatSteadyPosition(element) {
264            var steadyfloatPositionsInfo = $(element);
265            var steadyfloatPositions = advertisementFloat(steadyfloatPositionsInfo);
266            steadyfloatPositions.each(function () {
267                var floatPosition = $(this);
268                //计算版位的坐标
269                var ypos = positionCoordinate($(this));
270                floatPosition.css('top', ypos);
271
272                // 滚动。
273                var x = 1;
274                var y = 1;
275                var position = 0;
276                var width = floatPosition.data().width + 1;
277                var height = floatPosition.data().height + 1;
278
279                function moves() {
280                    var tops = floatPosition.offset().top;
281                    var lefts = floatPosition.offset().left;
282
283                    if (lefts >= document.documentElement.clientWidth - width || (lefts) <= 0) {
284                        x = -x;
285                        if (lefts > (document.documentElement.clientWidth - width)) {
286                            lefts = document.documentElement.clientWidth - width;
287                        } else if (lefts <= 0) {
288                            lefts = 0;
289                        }
290                    }
291
292                    if (tops >= (document.documentElement.clientHeight + position) - height || (tops) <= position + 0) {
293                        y = -y;
294                        if (tops > position + document.documentElement.clientHeight - height) {
295                            tops = position + document.documentElement.clientHeight - height;
296                        } else if (tops < position + document.documentElement.clientHeight - height) {
297                            tops = position;
298                        }
299                    }
300
301                    tops += y;
302                    lefts += x;
303
304                    floatPosition.css('top', tops);
305                    floatPosition.css('left', lefts);
306                }
307
308                var a1a = setInterval(moves, 30);
309
310                $(document).scroll(function () {
311                    position = document.documentElement.scrollTop;
312                });
313                //悬停停止
314                floatPosition.mouseover(function () {
315                    clearInterval(a1a);
316                });
317
318                floatPosition.mouseout(function () {
319                    a1a = setInterval(moves, 30);
320                });
321            });
322        }
323
324        /**
325         * 广告固定板块。
326         */
327        function advertisementSiblings(element, fixed) {
328            var $element = $(element),
329                index = Number($element.text()) - 1;
330            fixed.find('.fixedCount a').removeClass('seld');
331            $element.addClass('seld');
332            fixed.find('.fixedCount a')[index].className = 'seld';
333            fixed.find('.fixedPosition > a')
334                .eq(index)
335                .fadeIn(300)
336                .siblings()
337                .fadeOut(300);
338        }
339
340        function showAuto(fixedLength, fixedNumLinkList, fixed) {
341            var fixedCount = fixed.find('.fixedCount').data().count;
342            fixedCount = fixedCount >= (fixedLength - 1) ? 0 : ++fixedCount;
343            fixed.find('.fixedCount').data().count = fixedCount;
344            advertisementSiblings(fixedNumLinkList.eq(fixedCount), fixed);
345        }
346
347        var $fixedList = $("div[data-power-ui='advertisement_fixed']");
348        $.each($fixedList,
349            function () {
350                var fixed = $(this);
351                var $fixedNumLinkList = fixed.find('.fixedCount a');
352                var fixedLength = $fixedNumLinkList.length;
353                $(this).on('click',
354                    '.fixedCount a',
355                    function () {
356                        advertisementSiblings($(this), fixed);
357                    });
358
359                var fixedtime = setInterval(function () { showAuto(fixedLength, $fixedNumLinkList, fixed); }, 2000);
360                fixed.hover(function () { clearInterval(fixedtime) },
361                    function () {
362                        fixedtime = setInterval(function () {
363                            showAuto(fixedLength, $fixedNumLinkList, fixed);
364                        },
365                            2000);
366                    });
367            });
368
369        /*外部重新刷新广告定位*/
370        pe.advertising = {};
371        pe.advertising.InitAdvertising = {
372            InitFloatPosition: initFloatPosition,
373            InitRollfloatPosition: initRollfloatPosition,
374            InitFloatRollPosition: initFloatRollPosition,
375            InitFloatSteadyPosition: initFloatSteadyPosition
376        };
377    });
378
379    // Ajax调用分部视图。
380    $(function () {
381        function getFunction(code, argNames) {
382            var fn = window,
383                parts = (code || "").split(".");
384
385            while (fn && parts.length) {
386                fn = fn[parts.shift()];
387            }
388
389            if (typeof (fn) === "function") {
390                return fn;
391            }
392
393            argNames.push(code);
394            return Function.constructor.apply(null, argNames);
395        }
396
397        function loadData($data, pageid) {
398            var url = $data.ajaxUrl;
399            if (pageid) {
400                url = url + '?pageid=' + pageid;
401            }
402            $.ajax({
403                url: url,
404                type: 'post',
405                cache: !!$data.ajaxCache,
406                data: {
407                    partialViewName: $data.ajaxPartialViewName,
408                    parameters: JSON.stringify($data.ajaxParameter),
409                    cacheMinutes: $data.ajaxCacheminutes,
410                    moduleName: $data.ajaxAreaname
411                },
412                beforeSend: function (xhr) {
413                    getFunction($data.ajaxBegin, ["xhr"]).apply(null, arguments);
414                },
415                complete: function () {
416                    getFunction($data.ajaxComplete, ["xhr", "status"]).apply(null, arguments);
417                },
418                success: function (response, status, xhr) {
419                    var fn = window,
420                        parts = ($data.ajaxSuccess || "").split(".");
421                    while (fn && parts.length) {
422                        fn = fn[parts.shift()];
423                    }
424                    if (typeof (fn) === "function") {
425                        getFunction($data.ajaxSuccess, ["response", "status", "xhr"]).apply(null, arguments);
426                    } else {
427                        if (response.page) {
428                            $data.ajaxDataCount = response.page.DataCount;
429                            $data.ajaxPageIndex = response.page.PageIndex;
430                            $data.ajaxPageSize = response.page.PageSize;
431                            $data.ajaxPagingUrl = response.page.PagingUrl;
432                        }
433
434                        $('[data-ajax-data="' + $data.ajaxId + '"]')
435                            .each(function () {
436                                $(this).trigger('ajaxControlHandler', [response, $data]);
437                            });
438
439                        var mode = ($data.ajaxMode || "").toUpperCase();
440                        $($data.ajaxUpdate)
441                            .each(function (i, update) {
442                                var top;
443                                switch (mode) {
444                                    case "BEFORE":
445                                        top = update.firstChild;
446                                        $("<div />")
447                                            .html(response.html)
448                                            .contents()
449                                            .each(function () {
450                                                update.insertBefore(this, top);
451                                            });
452                                        break;
453                                    case "AFTER":
454                                        $("<div />")
455                                            .html(response.html)
456                                            .contents()
457                                            .each(function () {
458                                                update.appendChild(this);
459                                            });
460                                        break;
461                                    case "REPLACE-WITH":
462                                        $(update).replaceWith(response.html);
463                                        break;
464                                    default:
465                                        $(update).html(response.html);
466                                        break;
467                                }
468                            });
469                    }
470
471                    // ajax加载的页面,有开启无障碍功能时需要重新初始化无障碍语音播放
472                    if (window.free_Web && free_Web.Function && free_Web.Function.initFreeWeb) {
473                        window.free_Web.Function.initFreeWeb();
474                    }
475                },
476                error: function (xhr, textStatus, errorThrown) {
477                    getFunction($data.ajaxFailure, ["xhr", "status", "error"]).apply(null, arguments);
478                }
479            });
480        }
481
482        // ajaxpartial 初始化
483        $('[data-ui-type="ajaxpartial"]')
484            .each(function () {
485                var $data = $(this).data();
486                $data.ajaxLoadData = loadData;
487                loadData($data);
488            });
489
490        // ajaxbutton 初始化
491        function ajaxButtonControlHandler(response, $data) {
492            $('[data-ajax-data="' + $data.ajaxId + '"]')
493                .each(function () {
494                    if (response.page.PageIndex >= response.page.PageCount) {
495                        $(this).hide();
496                    }
497                });
498        }
499
500        $('[data-ui-type="ajaxbutton"]')
501            .each(function () {
502                var $this = $(this);
503
504                function getData(element) {
505                    var id = $(element).data().ajaxData;
506                    var input = $('#' + id);
507                    var $data = input.data();
508                    var pageid = 1;
509                    if ($data.ajaxPageIndex) {
510                        pageid = $data.ajaxPageIndex + 1;
511                    }
512                    $data.ajaxLoadData($data, pageid);
513                }
514
515                $this.on('ajaxControlHandler',
516                    function (event, response, $data) {
517                        ajaxButtonControlHandler(response, $data);
518                    });
519
520                $this.on('click',
521                    function () {
522                        getData(this);
523                    });
524            });
525    });
526
527    //编辑器内的表格在前台展示时滚动条的显示
528    $(function () {
529        var $content = $('[data-power-area="content"]');
530        var contentwidth = $content.width();
531        var tables = $content.find('table');
532        if (contentwidth != null && $content.data().powerScrolltable !== false) {
533
534
535            tables.wrap(function () {
536                if (parseInt($(this).innerWidth()) > parseInt($(this).parent().width())) {
537                    return '<div class="ueditortable"></div>';
538                }
539            });
540            // tables.wrap('<div class="ueditortable"></div>');
541
542            $(".ueditortable").css("width",
543                function () {
544                    if ($(this).parent().width()) {
545                        return $(this).parent().width() - 2;
546                    }
547
548                    return "auto";
549                });
550            var ueditortables = $(".ueditortable");
551            $.each(ueditortables,
552                function () {
553                    var table = $(this).find("table")[0];
554                    var utableWidth = $(this).width();
555                    var utableHeight = $(window).height() - 180;
556                    if (table.clientWidth > utableWidth && table.clientHeight > utableHeight) {
557                        $(this).css("height", utableHeight);
558                    }
559                });
560
561            $(".ueditortable").hover(function () {
562                var tablewidth = $(this).find("table")[0].offsetWidth;
563                var utableWidth = $(this).width();
564                if (parseInt(tablewidth) > utableWidth && !$(this).hasClass("tablemask")) {
565                    $(this).prepend(
566                        '<p class="expandtable"><a id="fullScreen" title="全屏" href="javascript:;"><i class="fa fa-expand"></i></a></p>');
567                }
568            },
569                function () {
570                    $(this).find(".expandtable").remove();
571                });
572
573            var $this = $(".ueditortable");
574            $(".ueditortable").on("click",
575                ".expandtable",
576                function () {
577                    $this = $(this).parent();
578                    fullscreenState();
579                });
580
581            $("body").on("click",
582                ".compresstable",
583                function () {
584                    $this = $(this).parent();
585                    fullscreenState();
586                });
587
588            $("body").on("click",
589                ".newwindowtable",
590                function () {
591                    var b = window.open('');
592                    var html = $(".newueditortable").find("table").css("text-align", " center")[0].outerHTML;
593                    $(b.document.body).html(html + "<style>td { border: solid;}</style>");
594                });
595
596            document.onkeydown = function (ev) {
597                var oEvent = ev || event;
598                if (oEvent.keyCode == 27) {
599                    if ($(".newueditortable").length > 0) {
600                        fullscreenState();
601                    }
602                }
603            };
604        }
605
606        function fullscreenState() {
607            if ($("div").hasClass("tablemask")) {
608                $(".tablemask").remove();
609                $(".newueditortable").remove();
610            } else {
611                $("body").prepend('<div class="tablemask"></div>');
612                $this.find(".expandtable").remove();
613                $("body").append(
614                    '<div class="newueditortable">' +
615                    $this.html() +
616                    '</div>');
617
618                tablemargins();
619                $(".newueditortable").hover(function () {
620                    $(this)
621                        .prepend(
622                            '<div class="newclass"><p class="newwindowtable"><a href="javascript:;">打开新窗口表单</a></p><p class="compresstable"><a title="退出全屏" href="javascript:;"><i class="fa fa-compress"></i>&nbsp;退出全屏</a></p></div>');
623                    //$(".newclass").css("left", $(window).width() / 2.4);
624                },
625                    function () {
626                        $(this).find(".newclass").remove();
627                    });
628
629                $(window).resize(function () {
630                    tablemargins();
631                });
632            }
633        }
634
635        function tablemargins() {
636            if ($this.find("table").width() > ($(window).width() / 1.1)) {
637                $(".newueditortable").css("width", $(window).width() / 1.1);
638            } else {
639                $(".newueditortable").css("width", "");
640            }
641
642            $(".newueditortable").css("left", ($(window).width() - $(".newueditortable").outerWidth()) / 2);
643            $(".newclass").css("left", $(window).width() / 2.4);
644            if ($this.find("table").height() > $(window).height() / 1.2) {
645                $(".newueditortable").css("height", $(window).height() / 1.2);
646            } else {
647                $(".newueditortable").css("height", "");
648            }
649        }
650    });
651
652    function getReplaceSharedUrl(value) {
653        if (!value) {
654            return value;
655        }
656        var key = 'SessionVerify=';
657        var index = value.toLocaleLowerCase().indexOf(key.toLocaleLowerCase());
658        if (index < 0) {
659            return value;
660        }
661
662        return value.substr(0, index - 1);
663    };
664
665    /**
666     * 渲染二维码
667     * @param {JQuery} $element 要渲染为二维码的jQuery实体。
668     */
669    function renderQrcode($element) {
670        var content = $element.data('content'),
671            size = $element.data('size');
672        if (!content) {
673            content = getReplaceSharedUrl(window.location.href);
674        }
675        content = encodeURI(content);
676        new QRCode($element.get(0),
677            {
678                text: content,
679                width: size,
680                height: size
681            });
682
683        //qrcode.makeCode();
684    }
685
686    $('[data-powertype="qrcode"]').each(function (i, n) {
687        renderQrcode($(n));
688    });
689
690    updateContentHits();
691    updateNodeHits();
692    updateSubjectCategoryHits();
693    updateSiteTraffic();
694
695    /**
696     * [通过参数名获取url中的参数值]
697     * @param  {[string]} queryName [参数名]
698     */
699    function GetQueryValue(queryName) {
700        var query = decodeURI(window.location.search.substring(1));
701        var vars = query.split("&");
702        for (var i = 0; i < vars.length; i++) {
703            var pair = vars[i].split("=");
704            if (pair[0] == queryName) {
705                return pair[1];
706            }
707        }
708        return null;
709    }
710
711    /**
712     * 更新内容的点击数。
713     * @returns {}
714     */
715    function updateContentHits() {
716        // 如果请求url中存在VisualizationToken参数,说明当前是可视化编辑,不应该添加点击数。
717        if (window.location.href.indexOf('VisualizationToken=') >= 0) {
718            $('[data-power-hits-action]').each(function () {
719                var $element = $(this);
720                var isShowHit = $element.data().powerHitsOpen;
721                if (isShowHit) {
722                    var count = $element.data().powerHitsCount;
723                    $element.text(count);
724                }
725            });
726            return false;
727        }
728
729        $('[data-power-hits-action]').each(function () {
730            var $element = $(this);
731            var mold = $element.data().powerHitsMold,
732                id = $element.data().powerHitsId,
733                nodeId = $element.data().powerHitsNodeid,
734                isShowHit = $element.data().powerHitsOpen,
735                ispreview = GetQueryValue('ispreview');
736
737            var referrerCode = getQueryParam("referrercode");
738            if (referrerCode && referrerCode.length >= 8) {
739                referrerCode = referrerCode.substring(0, 8);
740            }
741
742            $.ajax({
743                url: $element.data().powerHitsAction,
744                type: 'get',
745                data: { "mold": mold, "id": id, "isShowHit": isShowHit, "nodeId": nodeId, "ispreview": ispreview, "referrercode": referrerCode },
746                success: function (data) {
747                    $element.text(data.hits);
748                }
749            });
750        });
751    }
752
753    /**
754     * 获取查询参数。
755     * @param {any} name
756     * @returns 返回值。
757     */
758    function getQueryParam(name) {
759        if (window.URLSearchParams) {
760            var searchParams = new URLSearchParams(window.location.search);
761            return searchParams.get(name);
762        }
763
764        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
765        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
766        var results = regex.exec(location.search);
767        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
768    }
769
770    function updateSiteTraffic() {
771        if ($("#currentsiteinfo").length > 0) {
772            var siteurl = $("#currentsiteinfo").data("siteajaxrequestprefix");
773            $.ajax({
774                url: siteurl + "site/AjaxAddSiteTraffic",
775                type: 'get'
776            });
777        }
778    }
779
780    /**
781     * 更新信息公开目录点击数。暂时不调用此方法还没写完。
782     * */
783    function updateSubjectCategoryHits() {
784        // 如果请求url中存在VisualizationToken参数,说明当前是可视化编辑,不应该添加点击数。
785        if (window.location.href.indexOf('VisualizationToken=') >= 0) {
786            return false;
787        }
788
789        $('[data-power-subjecthits-action]').each(function () {
790            var $element = $(this);
791            var subjectId = $element.data().powerSubjecthitsSubjectcategoryid;
792            $.postPreventCSRF($element.data().powerSubjecthitsAction, { "subjectId": subjectId }, function () { });
793        });
794    }
795
796    /**
797     * 更新节点的点击数。
798     * @param {any} url
799     */
800    function updateNodeHits() {
801        // 如果请求url中存在VisualizationToken参数,说明当前是可视化编辑,不应该添加点击数。
802        if (window.location.href.indexOf('VisualizationToken=') >= 0) {
803            return false;
804        }
805
806        $('[data-power-nodehits-action]').each(function () {
807            var $element = $(this);
808            var nodeId = $element.data().powerNodehitsNodeid;
809            $.postPreventCSRF($element.data().powerNodehitsAction, { "nodeId": nodeId }, function () { });
810        });
811    }
812
813    //点击外链询问离开
814    /**
815     * 获取Host
816     * @param {string} url 地址。
817     */
818    function getHost(url) {
819        var host = "null";
820
821        if (typeof url == "undefined" || null == url) {
822            url = window.location.href;
823        }
824
825        //HTMLHyperlinkElementUtils.host 使用API来获取。
826        var anchor = document.createElement("a");
827        anchor.href = url;
828        if (anchor.hostname) {
829            return anchor.hostname;
830        }
831
832        var regex = /.*\:\/\/([^\/]*).*/;
833        var match = url.match(regex);
834        if (typeof match != "undefined" && null != match) {
835            host = match[1];
836        }
837        return host;
838    }
839
840    /**
841     * 点击外链询问离开
842     * @param {this对象} _this this对象。
843     * @param {string} type 类型"aLink"为a链接,"select"为select下拉。
844     */
845    function isExcelLink(_this, type, event) {
846        var o = $(_this);
847        var linkEcrypted = false;
848        var href = "";
849        var target = "";
850        var siteName = $("meta[name ='application-name']").attr("content");
851        if (type == "aLink") {
852            href = o.attr('href');
853            var oldHref = href;
854            href = getDecryptLink(o, href);
855            linkEcrypted = oldHref != href;
856            target = o.attr('target');
857        } else if (type == "select" && !!$('option:selected', o).attr('value')) {
858            href = o.val();
859        } else {
860            return false;
861        }
862        var linkHost = getHost(href);
863
864        //设置白名单,excelLinkWhiteList是全局变量,如有需要请写到基础布局页里面。例excelLinkWhiteList = ["www.***.com"]
865        if (typeof (excelLinkWhiteList) == "undefined") {
866            excelLinkWhiteList = [];
867        }
868
869        // 从配置中获取白名单。
870        if (window && window.POWER_LEAVESITEPROMPTS_CONFIG && window.POWER_LEAVESITEPROMPTS_CONFIG.DomainWhitelist) {
871            excelLinkWhiteList.push.apply(excelLinkWhiteList, window.POWER_LEAVESITEPROMPTS_CONFIG.DomainWhitelist);
872        }
873
874        if (typeof (href) != 'undefined' &&
875            linkHost != 'null' &&
876            !checkHostInWhiteList(linkHost, excelLinkWhiteList) &&
877            location.hostname.replace("www.", "") != linkHost.replace("www.", "").split(":")[0]) {
878
879            //离开站点提示,对应3个值(枚举:开启OnShow;仅政府网站不提示OnlyGovNoShow;关闭NoShow)。
880            var siteId = $("meta[name=SiteId]").attr("content");
881            var LeaveSitePrompts = window.POWER_LEAVESITEPROMPTS_CONFIG.LeaveSitePrompts[siteId];
882            if (typeof (LeaveSitePrompts) == "undefined" || LeaveSitePrompts == "PlatformConfig") {
883                LeaveSitePrompts = window.POWER_LEAVESITEPROMPTS_CONFIG.LeaveSitePrompts[0];
884            }
885
886            //属于开启和提示情况
887            if (chekHrefGoInternalUrl(href)) {
888                event && event.preventDefault();
889                showLinkTip('此链接是内网地址,如果您现在不在内网使用,将无法访问此地址。', type, o, href, target, linkEcrypted);
890                if (typeof (free_Web) != "undefined" && free_Web.Function.show.status) {
891                    free_Web.Function.audioplay.audio('此链接是内网地址,如果您现在不在内网使用,将无法访问此地址。');
892                }
893            } else if (LeaveSitePrompts == 'OnShow' || (LeaveSitePrompts == 'OnlyGovNoShow' && !IsOnlyGovNoShow(href))) {
894                event && event.preventDefault();
895                var title = '您访问的链接即将离开“' + siteName + '”门户网站,</br>是否继续?';
896                showLinkTip(title, type, o, href, target, linkEcrypted);
897                if (typeof (free_Web) != "undefined" && free_Web.Function.show.status) {
898                    free_Web.Function.audioplay.audio(title);
899                }
900            }
901            else {
902                if (type == "select") {
903                    window.open(href, target);
904                } else if (type == "aLink" && linkEcrypted) {
905                    event && event.preventDefault();
906                    window.open(href, target, 'noreferrer');
907                    return false;
908                }
909            }
910        } else if (type == "select") {
911            window.open(href, target);
912        } else if (type == "aLink" && linkEcrypted) {
913            event && event.preventDefault();
914            window.open(href, target, 'noreferrer');
915        }
916    }
917
918    function showLinkTip(title, type, o, href, target, linkEcrypted) {
919        //当是a元素时去除元素默认链接
920        if (type == "aLink" && !linkEcrypted) {
921            o.removeAttr('href');
922        }
923        var w = '480px',
924            h = 'auto';
925        if (window.screen.width < 768) {
926            w = '90%';
927            h = 'auto';
928        }
929        //判断是否加载 layer.js 库,没有的话加载!
930        if (typeof layer === 'undefined') {
931            $('body').prepend('<script src="/content/_common/base/js/layer/layer.js"></script>');
932        }
933
934        var cf = layer.confirm(
935            '<div style="margin-top:20px; font-size:16px;">' + title + '</div>',
936            {
937                btn: ['继续访问', '放弃'],
938                title: false,
939                shade: 0.7,
940                area: [w, h],
941                shadeClose: true,
942                end: function () {
943                    if (type == "aLink" && !linkEcrypted) {
944                        o.attr('href', href);
945                    }
946                }
947            },
948            function () {
949                if (type == "aLink" && !linkEcrypted) {
950                    o.attr('href', href);
951                }
952                layer.close(cf);
953                window.open(href, target, 'noreferrer');
954            },
955            function () {
956                if (type == "aLink" && !linkEcrypted) {
957                    o.attr('href', href);
958                }
959                layer.close(cf);
960            });
961    }
962
963    window.ipHelperUtil = window.ipHelperUtil || {
964        needCheckIP: false,
965        ipHelperUtil: false,
966        hosts: [],
967        getLinkHost: function (link) {
968            var host = '';
969            try {
970                var anchor = document.createElement("a");
971                anchor.href = link;
972                if (anchor.hostname) {
973                    return anchor.hostname;
974                }
975            } catch (e) {
976            }
977
978            return host;
979        },
980        clientIpIsInternalIp: function (clientIP) {
981            if (!clientIP) {
982                return false;
983            }
984
985            if (clientIP == "::1") {
986                return true;
987            }
988
989            // 局域网IP永远在白名单中。
990            if (clientIP.indexOf('10.') > -1 || clientIP.indexOf('192.168.') > -1) {
991                return true;
992            }
993
994            // 对172开头的局域网IP的处理稍微复杂一些
995            if (clientIP.indexOf('172.') > -1) {
996                var ip1 = parseInt(clientIP.split('.')[1]);
997                if (ip1 > 15 && ip1 < 32) {
998                    return true;
999                }
1000            }
1001
1002            return false;
1003        },
1004        initPageAccesscrossIP: function () {
1005            var currentHosts = [];
1006            $('a:not("[data-power-noExcelLinks] a,[data-power-noExcelLink]")').each(function (item) {
1007                var $this = $(this);
1008                var currentHref = $this.attr('href');
1009                currentHref = getDecryptLink($this, currentHref);
1010
1011                if (currentHref && (currentHref.indexOf('http:') > -1 || currentHref.indexOf('https:') > -1)) {
1012                    var currentHost = ipHelperUtil.getLinkHost(currentHref);
1013                    if (currentHost && ipHelperUtil.clientIpIsInternalIp(currentHost) && currentHosts.indexOf(currentHost) < 0) {
1014                        currentHosts.push(currentHost);
1015                    }
1016                }
1017            });
1018
1019            if (currentHosts.length > 0) {
1020                var postData = { ipList: currentHosts.join(',') };
1021                $.postPreventCSRF('/ajax/ajaxgetaccesscrossip', postData, function (data) {
1022                    if (!data) {
1023                        return;
1024                    }
1025
1026                    ipHelperUtil.needCheckIP = data.needCheck;
1027                    ipHelperUtil.accessCrossIP = data.accessCross;
1028                    ipHelperUtil.hosts = data.ipList;
1029                });
1030            }
1031        }
1032    }
1033
1034    //判断链接是不是包含gov.cn
1035    function IsOnlyGovNoShow(url) {
1036        if (url.indexOf('gov.cn') > -1) {
1037            return true;
1038        } else {
1039            return false;
1040        }
1041    }
1042
1043    function checkHostInWhiteList(linkHost, excelLinkWhiteList) {
1044        if ($.inArray(linkHost, excelLinkWhiteList) > -1) {
1045            return true;
1046        }
1047
1048        for (var i = 0; i < excelLinkWhiteList.length; i++) {
1049            var pattern = excelLinkWhiteList[i];
1050            pattern = pattern.replace('*', '');
1051            if (linkHost.indexOf(pattern) > -1) {
1052                return true;
1053            }
1054
1055            if (pattern.charAt(0) === '.') {
1056                pattern = pattern.replace('.', '');
1057                if (linkHost.indexOf(pattern) > -1) {
1058                    return true;
1059                }
1060            }
1061        }
1062
1063        return false;
1064    }
1065
1066    function chekHrefGoInternalUrl(href) {
1067        if (!href || !ipHelperUtil.needCheckIP || !ipHelperUtil.accessCrossIP || !ipHelperUtil.hosts || !ipHelperUtil.hosts.length) {
1068            return false;
1069        }
1070
1071        var currentHost = ipHelperUtil.getLinkHost(href);
1072        return currentHost && ipHelperUtil.hosts.indexOf(currentHost) > -1;
1073    }
1074
1075    // 解密外链。
1076    function getDecryptLink($element, value) {
1077        if ($element && $element.length > 0) {
1078            var newHref = $element.attr('data-power-externallink');
1079            if (newHref) {
1080                try {
1081                    return pe.tools.DecryptBase64ForJs(newHref);
1082                } catch (e) {
1083                    console.error(e);
1084                }
1085            }
1086        }
1087
1088        return value;
1089    }
1090
1091    $(document).on('click',
1092        'a:not("[data-power-noExcelLinks] a,[data-power-noExcelLink]")',
1093        function (event) {
1094            isExcelLink(this, "aLink", event);
1095        });
1096    $(document).on('change',
1097        '[data-power-select-ExcelLink]',
1098        function (event) {
1099            isExcelLink(this, "select", event);
1100        });
1101
1102    window.openexternallink = function (encryptHref) {
1103        // 处理页面中的【更多】链接无法跳转至加密外链的情况。
1104        $(this).attr('data-power-externallink', encryptHref);
1105        isExcelLink(this, "aLink");
1106    }
1107
1108    /**
1109     * pdf 预览
1110     */
1111    var haspdf = $("[data-uitype ='pdf']").length > 0;
1112    if (haspdf) {
1113        // 加载js并插入到文档末尾
1114        var script = document.createElement('script');
1115        script.src = '/content/_common/base/js/power.pdfpreview.js';
1116        window.document.body.insertAdjacentElement('afterend', script);
1117    }
1118
1119    /**
1120    * 添加表单action添加字段submit。
1121    */
1122    $(function () {
1123        $("form").each(function () {
1124            var url = $(this).attr("action");
1125            if (url && getUrlParam(url, "submit") == null) {
1126                $(this).attr("action", changeUrlParam(url, 'submit', 'true'));
1127            }
1128        });
1129
1130        function changeUrlParam(url, arg, value) {
1131            var pattern = arg + '=([^&]*)';
1132            var replaceText = arg + '=' + value;
1133            if (url.match(pattern)) {
1134                var tmp = '/(' + arg + '=)([^&]*)/gi';
1135                tmp = url.replace(eval(tmp), replaceText);
1136                return tmp;
1137            } else {
1138                if (url.match('[\?]')) {
1139                    return url + '&' + replaceText;
1140                } else {
1141                    return url + '?' + replaceText;
1142                }
1143            }
1144        }
1145
1146        function getUrlParam(url, name) {
1147            var reg = new RegExp('(^|&)' + name + "=([^&]*)(&|$)");
1148            var results = url.match(reg);
1149            if (!results) {
1150                return null;
1151            }
1152            if (!results[1]) {
1153                return '';
1154            }
1155            return decodeURIComponent(results[2].replace(/\+/g, " "));
1156        }
1157    });
1158
1159    /**
1160    * a链接中target="_blank"的安全处理。
1161    */
1162    $(function () {
1163        $('a[target=_blank]').each(function () {
1164            $(this).attr('rel', 'noopener noreferrer');
1165        });
1166    });
1167
1168    $(function () {
1169        $('.disabledforceuseragent').parent().parent("dl").hide();
1170        $('.disabledforceuseragent').parent().parent("dl").next(".split").hide();
1171
1172        ipHelperUtil.initPageAccesscrossIP();
1173    });
1174
1175    // 修复低版本浏览器不支持:has()样式的问题
1176    $(".input-group:has(.form-control + .input-group-addon)").addClass("input-group_hasAddon");
1177
1178    // 显示被遮蔽信息。
1179    $(".idcard-mask-open").on("click", function () {
1180        $(this).addClass("hidden");
1181        $(this).next().removeClass("hidden");
1182    });
1183
1184    // 遮蔽信息。
1185    $(".idcard-mask-close").on("click", function () {
1186        $(this).addClass("hidden");
1187        $(this).prev().removeClass("hidden");
1188    });
1189
1190    /**
1191     * 替换URL的参数值。
1192     * @param {any} url URL 链接。
1193     * @param {any} paramName 参数名称。
1194     * @param {any} paramValue 参数值。
1195     * @returns
1196     */
1197    function replaceURLParameter(url, paramName, paramValue) {
1198        url = url || '';
1199        var pattern = new RegExp('\\b(' + paramName + '=).*?(&|$)');
1200        if (url.search(pattern) >= 0) {
1201            return url.replace(pattern, '$1' + paramValue + '$2');
1202        }
1203        return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue;
1204    }
1205
1206    $.fn.replaceURLParameter = replaceURLParameter;
1207}());

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.