PageSourceSearch

https://www.xjtl.gov.cn/content/_common/base/js/power.ui.js?v=dzxdCRk-tCmkPLzVW16gMY5Go0SsnQaYwZ7SGgTfgEA

js xjtl.gov.cn collected 2026-10-02 17:05:27 UTC 9,559 bytes, 274 lines download raw bytes

1/**
2 * 此文件的头部注释
3 */
4
5/*global jQuery: false */
6
7(function ($) {
8    'use strict';
9
10    pe.ui = {};
11    var $home = window.top.pe.home;
12    var frameHistory = function (frameName) {
13        this.frameName = frameName;
14        this.records = [];
15    };
16
17    frameHistory.prototype = {
18        frameName: '',
19        add: function (url) {
20            this.records.push(url);
21        },
22        back: function () {
23            this.records.pop();
24            var src = this.records.pop();
25            window.top.$('iframe[data-historian=' + this.frameName + ']').prop('src', src);
26        }
27    };
28
29    var history = function () {
30        var ele;
31        if (window.top.pe.ui.history) {
32            ele = window.top.pe.ui.history;
33        } else {
34            window.top.pe.ui.history = ele = {};
35        }
36
37        this.records = ele;
38    };
39
40    history.prototype = {
41        records: null,
42        frame: function (name) {
43            if (name in this.records) {
44                return this.records[name];
45            } else {
46                var fh = new frameHistory(name);
47                this.records[name] = fh;
48
49                return fh;
50            }
51        }
52    };
53
54    pe.ui.historian = function () {
55        return new history();
56    };
57
58    function bindNewTabLink() {
59        $('body')
60            .on('click',
61                'a',
62                function (e) {
63                    var $this = $(this),
64                        url = $this.prop('href');
65                    if (url && ($this.is("[data-tabs-target='_blank']") || e.ctrlKey)) {
66                        $home.tabs.addTab(url);
67                        return false;
68                    }
69
70                    return true;
71                });
72
73    }
74
75    $(function () {
76        $(".btn.disabled")
77            .click(function () {
78                return false;
79            });
80        $('.history-back')
81            .each(function (i, n) {
82                var frame = $home.currentFrame(),
83                    self = $(this);
84                if (pe.ui.historian().frame(frame.attr('data-historian')).records.length < 1) {
85                    self.addClass('disabled');
86                    self.on('click', function (e) { return false; });
87                } else {
88                    self.on('click',
89                        function (e) {
90                            var $home = window.top.pe.home,
91                                frame = $home.currentFrame();
92                            pe.ui.historian().frame(frame.attr('data-historian')).back();
93
94                            return false;
95                        });
96                }
97
98            });
99
100        bindNewTabLink();
101    });
102
103    $('.unselect').on('selectstart', function (e) { return false; }).attr('unselectable', 'on');
104
105    $.each($('a[data-confirm]'),
106        function () {
107            var $this = $(this);
108            var placement = 'bottom';
109            if ($this.data('placement')) {
110                placement = $this.data('placement');
111            }
112            var message = $this.attr('data-confirm');
113            $this.confirmation({
114                placement: placement,
115                title: message,
116                btnOkLabel: '确定',
117                btnCancelLabel: '取消',
118                popout: false,
119                onConfirm: function (event, element) {
120                    var href = $(element).attr('href');
121                    if (href) {
122                        window.location.href = href;
123                    } else {
124                        var confirm = $this.data("onConfirm");
125                        if (confirm) {
126                            confirm();
127                        }
128                    }
129
130                }
131            });
132        });
133
134
135
136    var videoElements = [];
137    /*
138    videoSrc:视频地址
139    succeedFunc:获取视频帧成功后回调
140    errorFunc:获取视频帧失败后回调
141    imgWidth:生成图片宽度
142    imgHeight:生成图片高度
143    */
144    pe.ui.VideoCover = function (videoSrc, succeedFunc, errorFunc, imgWidth, imgHeight) {
145        if (videoSrc) {
146            var videoElement = document.createElement("VIDEO");
147            videoElement.src = videoSrc;
148            videoElement.muted = true;
149            videoElement.autoplay = true;   // 视频一定要设置自动播放,否则抓出来的封面不是白的就是透明的
150            videoElement.setAttribute("crossOrigin", 'anonymous');
151            videoElement.setAttribute('playsinline', '');
152            videoElement.setAttribute('webkit-playsinline', ''); //这个属性是内联播放,避免在ios中,ios会劫持播放器,自动弹出播放界面
153            videoElement.addEventListener("loadeddata", function() {
154                try {
155                    var videoWidth = videoElement.videoWidth, videoHeight = videoElement.videoHeight;  // 获取video的宽高
156                    // var maxLength = videoWidth > videoHeight ? videoWidth : videoHeight;
157                    // 固定视频缩略图生成比例
158                    var imgWidth = 800;
159                    var imgHeight = 450;
160                    var x = 0, y = 0, width = 0, height = 0;
161                    // 计算缩小后图片的宽高以及canvas绘制的位置信息
162                    if (videoWidth / videoHeight >= 1.5) {
163                        width = imgWidth;
164                        height = videoHeight * (imgWidth / videoWidth);
165                        x = 0;
166                        y = (imgHeight - height) / 2;
167                    } else {
168                        height = imgHeight;
169                        width = videoWidth * (imgHeight / videoHeight);
170                        y = 0;
171                        x = (imgWidth - width) / 2;
172                    }
173                    var canvas = document.createElement("canvas");
174                    canvas.width = imgWidth;
175                    canvas.height = imgHeight;
176                    var ctx = canvas.getContext("2d");
177                    ctx.fillStyle = "#000";
178                    ctx.fillRect(0, 0, imgWidth, imgHeight);
179                    ctx.drawImage(videoElement, x, y, width, height);
180                    var src = canvas.toDataURL("image/jpeg"); // 完成base64图片的创建
181                    if (succeedFunc) { succeedFunc(src) }
182                    // 清空video对象
183                    videoElements.splice($.inArray(videoElement, videoElements), 1);
184                    videoElement = null;
185                } catch (e) {
186                    if (errorFunc) { errorFunc() }
187                }
188            })
189            videoElement.addEventListener("error", function () {
190                if (errorFunc) { errorFunc() }
191            });
192            videoElements.push(videoElement);   // 存储video对象防止回收
193        }
194    }
195
196    // 针对前台视频列表页视频封面的帧初始化
197    $(function () {
198        $(".video-showcover img").each(function () {
199            var $imgDiv = $(this),
200                videoSrc = $imgDiv.data('videourlforcoverimage');
201            pe.ui.VideoCover(videoSrc,
202                function (src) { $imgDiv.attr('src', src); },
203                function () { $imgDiv.attr('src', '/content/_common/base/img/nopic.gif'); }
204            )
205        });
206
207        $("video").each(function () {
208            var $videoDiv = $(this),
209                videoSrc = this.src;
210            $videoDiv.attr('webkit-playsinline', '');
211            $videoDiv.attr('playsinline', '');
212            $videoDiv.attr('preload', 'auto');
213            if ($videoDiv.attr('poster')) {
214                return;
215            }
216            pe.ui.VideoCover(videoSrc,
217                function (src) { $videoDiv.attr('poster', src); },
218                function () { $videoDiv.attr('poster', '/content/_common/base/img/nopic.gif'); }
219            )
220        })
221    });
222
223    /**
224     * HTML标签XSS过滤
225     *
226     * @param {String} html
227     * @return {String}
228     */
229    pe.ui.filterXSS = function (html) {
230        return filterXSS(html, {
231            onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
232                if (name === 'class' ||
233                    name === 'hidefocus' ||
234                    name.substr(0, 5) === 'data-' ||
235                    name.substr(0, 7) === 'action-'
236                ) {
237                    return name + '="' + filterXSS.escapeAttrValue(value) + '"';
237 // 通过内置的escapeAttrValue函数来对属性值进行转义
238                }
239            }
240        });
241    }
242
243    /**
244     * String字符串XSS过滤
245     *
246     * @param {String} string
247     * @return {String}
248     */
249    pe.ui.filterStringXSS = function (string) {
250        return filterXSS(string, {
251            whiteList: {},        // 白名单为空,表示过滤所有标签
252            stripIgnoreTag: true,      // 过滤所有非白名单标签的HTML
253            stripIgnoreTagBody: ['script'] // script标签较特殊,需要过滤标签中间的内容
254        }).replace(/'/g, "").replace(/"/g, "");
255    }
256
257    $(function () {
258        // 查看原图
259        $(".swp-tool a[class='swpt-full-tip']").on("click", function () {
260            var url = "";
261            $("ul.swp-hd-list>li").each(function () {
262                var that = $(this);
263                if ($(that).hasClass("current")) {
264                    url = $(that).find(".swp-img>img").attr("src");
265                    return false;
266                }
267            });
268
269            if (url) {
270                window.open(url, "_blank");
271            }
272        });
273    });
274}(jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.