PageSourceSearch

https://xjtc.gov.cn/content/_common/base/js/power.videoreversion.js

js xjtc.gov.cn collected 2026-10-02 17:03:37 UTC 19,781 bytes, 559 lines download raw bytes

1!function () {
2    $(function () {
3        initAllVideo();
4        $("[data-ui='video']")
5            .each(function () {
6                var $video = $(this).find('video');
7                $video.addClass("VIDEO-Shimen-Pointer-Label");
8                var title = $video.attr("title");
9                if (title == undefined) {
10                    if ($(this).attr("title") !== undefined) {
11                        $video.attr("title", $(this).attr("title"));
12                    }
13                    else if ($(".title").length > 0) {
14                        $video.attr("title", $(".title").text());
15                    }
16                }
17            });
18    });
19
20    /**
21     * 初始化所有视频。
22     * @param {any} $dom
23     */
24    function initAllVideo($dom) {
25        if (!$dom) {
26            $dom = $("body");
27        }
28
29        var videoAll;
30        // 判断是否IE8,是的话用旧版播放器
31        if (isIE8()) {
32            videoAll = $dom.find('.edui-upload-video');
33            videoAll.each(function () {
34                var src = $(this).attr('src') || $(this).data('url');
35                if (src == '#') {
36                    return;
37                }
38                if (isWmv(src)) {
39                    var wmvHtml = createWmvVideo(src, $(this).attr('width'), $(this).attr('height'));
40                    $(this).replaceWith($(wmvHtml));
41                } else {
42                    swfVideoInit(src, $(this).attr('height'), $(this).attr('width'), $(this));
43                }
44            });
45
46            var videoDiv = $dom.find('[data-ui="video"]');
47            videoDiv.each(function () {
48                var src = $(this).attr('src') || $(this).data('url');
49                if (src == '#') {
50                    return;
51                }
52                if (isWmv(src)) {
53                    var wmvHtml = createWmvVideo(src, $(this).data('width'), $(this).data('height'));
54                    $(this).replaceWith($(wmvHtml));
55                } else {
56                    swfVideoInit(src, $(this).data('height'), $(this).data('width'), $(this));
57                }
58            });
59        } else {
60            videoAll = $dom.find('.edui-upload-video,.edui-video-video');
61            $.each(videoAll,
62                function (i, val) {
63                    var center = val.classList.contains('center');
64                    var src = $(this).attr('src') || $(this).data('url');
65                    var wmvHtml;
66                    if (src == '#') {
67                        return;
68                    }
69                    if (isMp3(src) == "mp3") {
70                        $(this).parent().attr('class', 'mp3Player');
71                        $(this).replaceWith($('<audio src="' + src + '" controls="controls"></audio>'));
72                        return;
73                    }
74                    if (isIe() && isWmv(src)) {
75                        wmvHtml = createWmvVideo(src, $(this).attr('width'), $(this).attr('height'));
76                        $(this).replaceWith($(wmvHtml));
77                    } else if (!isIe() && isWmv(src)) {
78                        wmvHtml = createIeTooltip($(this).attr('width'), $(this).attr('height'));
79                        $(this).replaceWith($(wmvHtml));
80                    } else if (!IsInternetExplorer10() && isFlv(src)) {
81                        wmvHtml = createIe10FlvVideo(src, $(this).attr('width'), $(this).attr('height'));
82                        $(this).replaceWith($(wmvHtml));
83                    } else if (isAvi(src)) {
84                        wmvHtml = createAviVideo(src, $(this).attr('width'), $(this).attr('height'));
85                        $(this).replaceWith($(wmvHtml));
86                    } else {
87                        videoInit(src, $(this).attr('height'), $(this).attr('width'), $(this));
88                    }
89                });
90
91            var embedAll = $dom.find('.edui-faked-video');
92            $.each(embedAll,
93                function (i, val) {
94                    var src = $(this).attr('src') || $(this).data('url');
95                    if (src == '#') {
96                        return;
97                    }
98                    if (isMp3(src) == "mp3") {
99                        $(this).parent().attr('class', 'mp3Player');
100                        $(this).replaceWith($('<audio src="' + src + '" controls="controls"></audio>'));
101                        return;
102                    }
103                    if (isIe() && isWmv(src)) {
104                        var wmvHtml = createWmvVideo(src, $(this).attr('width'), $(this).attr('height'));
105                        $(this).replaceWith($(wmvHtml));
106                    } else {
107                        embedInit(src, $(this).attr('height'), $(this).attr('width'), $(this));
108                    }
109                });
110
111            var blendDiv = $dom.find('[data-ui="video"]');
112            // 不自动播放。
113            var autoplay = false;
114            $.each(blendDiv,
115                function (i, val) {
116                    var src = $(this).attr('src') || $(this).data('url');
117                    var wmvHtml;
118                    if (src == '#') {
119                        return;
120                    }
121                    if (isMp3(src) == "mp3") {
122                        $(this).parent().attr('class', 'mp3Player');
123                        $(this).replaceWith($('<audio src="' + src + '" controls="controls"></audio>'));
124                        return;
125                    }
126                    if (isIe() && isWmv(src)) {
127                        wmvHtml = createWmvVideo(src, $(this).data('width'), $(this).data('height'));
128                        $(this).replaceWith($(wmvHtml));
129                    } else if (!isIe() && isWmv(src)) {
130                        wmvHtml = createIeTooltip($(this).data('width'), $(this).data('height'));
131                        $(this).replaceWith($(wmvHtml));
132                    } else if (!IsInternetExplorer10() && isFlv(src)) {
133                        wmvHtml = createIe10FlvVideo(src, $(this).attr('width'), $(this).attr('height'));
134                        $(this).replaceWith($(wmvHtml));
135                    } else if (!IsInternetExplorer10()) {
136                        wmvHtml = createIe10FlvVideo(src, $(this).attr('width'), $(this).attr('height'));
137                        $(this).replaceWith($(wmvHtml));
138                    } else if (isAvi(src)) {
139                        wmvHtml = createAviVideo(src, $(this).attr('width'), $(this).attr('height'));
140                        $(this).replaceWith($(wmvHtml));
141                    } else {
142                        blendInit(src, autoplay, $(this));
143                    }
144                });
145        }
146    };
147
148    /**
149     * 老版播放器
150     * @param {any} src - 路径
151     * @param {any} height - 高度
152     * @param {any} width - 宽度
153     * @param {any} $this - 当前对象
154     */
155    function swfVideoInit(src, height, width, $this) {
156        var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000);
157        var id = 'PowerPlay' + random;
158        $this.attr('id', id);
159        var parameters =
160        {
161            src: src,
162            autoPlay: true,
163            title: '',
164            controlBarAutoHide: "false",
165            scaleMode: "liveOrRecorded"
166        };
167        swfobject.embedSWF("/content/_common/base/swf/powerplayback.swf",
168            id,
169            width,
170            height,
171            "10.1.0",
172            {},
173            parameters,
174            { allowFullScreen: "true", wmode: "opaque" },
175            { name: "powerPlayback" }
176        );
177    };
178
179    /**
180     * video新版
181     * @param {any} src - 路径
182     * @param {any} height - 高度
183     * @param {any} width - 宽度
184     * @param {any} $this - 当前对象
185     */
186    function videoInit(src, height, width, $this) {
187        var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000);
188        var id = 'PowerPlay' + random;
189        var $width = width;
190        var $height = height;
191        var centerClass = $this.hasClass('center') ? ' center' : '';
192        var maxWidth = $('.articleCon').width() || window.innerWidth;
193        if ($width > maxWidth) {
194            $width = maxWidth;
195            var scale = maxWidth / width;
196            $height *= scale;
197            $this.attr('width', maxWidth);
198            $this.attr('height', $height);
199            $this.attr('controls', 'controls');
200            $this.attr('preload', 'metadata');
201        }
202
203        // ios 直接使用浏览器 video 标签播放兼容格式
204        if (navigator.userAgent.match(/(iPhone|iPad|iPod|ios)/i) && /(mp4|3gp|mpeg|mov|webm)$/i.test(src)) {
205            $this.show();
206            return;
207        }
208
209        if (src.indexOf('.mpeg4') > 0) {
210            $this.show();
211            return;
212        }
213
214        var boardDiv =
215            "<div id='" +
216            id +
217            "' class='videoPlayer" + centerClass + "' style='width:" +
218            $width +
219            "px;height:" +
220            $height +
221            "px;display:inline-block;'></div>";
222
223        var videoUrl = src;
224        $this.after(boardDiv);
225        $this.remove();
226        var autoplay = $('#videoAutoPlay').val() == "true" || $this.attr('autoplay'); //判断内容页视频是否有设置自动播放
227        var allowdownload = $('#allowDownloadVideo').val();
228        if (allowdownload && allowdownload == 'true') {
229            allowdownload = true;
230        }
231        else {
232            allowdownload = false;
233        }
234        var videoObject = {
235            container: '#' + id, //容器的ID
236            variable: 'player', //该属性必需设置,值等于下面的new chplayer()的对象
237            autoplay: autoplay, //是否自动播放
238            video: videoUrl,
239            download: allowdownload
240        };
241
242        var embed;
243        if (videoUrl.indexOf('.flv') > 0) {
244            $this.hide();
245            embed = createEmbedVideo(src, $height, $width);
246
247            $('#' + id).replaceWith($(embed));
248        } else if (videoUrl.indexOf('.swf') > 0) {
249            $this.hide();
250            embed = swfHtml(src, $height, $width);
251            $('#' + id).replaceWith($(embed));
252        } else {
253            var player = new ckplayer(videoObject);
254            setTimeout(playHandler, 1000, '#' + id);
255        }
256    };
257
258    function playHandler(id) {
259        // 视频播放暂停按钮居中显示
260        var w = $(id).width(),
261            h = $(id).height();
262
263        $($(id).children().children().get(9)).css({ top: ((h - 80) / 2) + "px", left: ((w - 80) / 2) + "px" });
264    }
265
266    /**
267    * 创建flv视频Html
268    * @param {any} src - 路径
269    * @param {any} width - 宽度
270    * @param {any} height - 高度
271    */
272    function createIe10FlvVideo(src, width, height) {
273        if (width == undefined) {
274            width = 800;
275        }
276        if (height == undefined) {
277            height = 480;
278        }
279        return '<OBJECT name="powerPlayback"  width=' +
280            width +
281            ' height=' +
282            height +
283            '  classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 ><PARAM NAME="FlashVars" VALUE="src=' +
284            src +
285            '"><PARAM NAME="Src" VALUE="/content/_common/base/swf/powerplayback.swf"></OBJECT>';
286    };
287
288    /**
289    * 创建flv视频Html
290    * @param {any} src - 路径
291    * @param {any} width - 宽度
292    * @param {any} height - 高度
293    */
294    function createAviVideo(src, width, height) {
295        if (width == undefined) {
296            width = 800;
297        }
298        if (height == undefined) {
299            height = 480;
300        }
301        return '<object id="MediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="' +
302            width +
303            '" height="' +
304            height +
305            '" standby="Loading Windows Media Player components…" type="application/x-oleobject" codebase=""><param name="FileName" value="' +
306            src +
307            '"><param name="AutoStart" value="true"><param name="ShowControls" value="true"><param name="BufferingTime" value="2"><param name="ShowStatusBar" value="true"><param name="AutoSize" value="true"><param name="InvokeURLs" value="false"><param name="AnimationatStart" value="1"><param name="TransparentatStart" value="1"><param name="Loop" value="1"><embed type="application/x-mplayer2" src="' +
308            src +
309            '" name="MediaPlayer" autostart="1" showstatusbar="1" showdisplay="1" showcontrols="1" loop="0" videoborder3d="0" pluginspage="" width="' +
310            width +
311            '" height="' +
312            height +
313            '"></embed></object>';
314    };
315
316    /**
317     * 判断是否IE10,9
318     */
319    function IsInternetExplorer10() {
320        var browser = navigator.appName;
321        var b_version = navigator.appVersion;
322        var version = b_version.split(";");
323        if (version.length > 1) {
324            var trim_Version = parseInt(version[1].replace(/[ ]/g, "").replace(/MSIE/g, ""));
325            if (trim_Version < 11) {
326                return false;
327            }
328        }
329        return true;
330    }
331
332    /**
333     * embed新版
334     * @param {any} src - 路径
335     * @param {any} height - 高度
336     * @param {any} width - 宽度
337     * @param {any} $this - 当前对象
338     */
339    function embedInit(src, height, width, $this) {
340        var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000);
341        var id = 'PowerPlay' + random;
342        var $width = width;
343        var $height = height;
344        var boardDiv =
345            "<div id='" +
346            id +
347            "' class='videoPlayer' style='width:" +
348            $width +
349            "px;height:" +
350            $height +
351            "px;display:inline-block;'></div>";
352
353        $this.after(boardDiv);
354
355        var videoUrl = src;
356
357        var videoObject = {
358            container: '#' + id, //容器的ID
359            variable: 'player', //该属性必需设置,值等于下面的new chplayer()的对象
360            autoplay: true, //是否自动播放
361            video: videoUrl
362        };
363
364        if (videoUrl.indexOf('.swf') < 0) {
365            $this.hide();
366            var player = new ckplayer(videoObject);
367        } else {
368            $this.hide();
369            var swf = swfHtml(src, $height, $width);
370            $('#' + id).replaceWith($(swf));
371        }
372    };
373
374    /**
375     * 新版混合播放
376     * @param {any} src - 路径
377     * @param {any} autoplay - 是否自动播放
378     * @param {any} $this - 当前对象
379     */
380    function blendInit(src, autoplay, $this) {
381        $this.width($this.data('width'));
382        $this.height($this.data('height'));
383        var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000);
384        var id = 'powerPlay' + random;
385        var poster = $this.data('poster');
386        $this.attr('id', id);
387
388        var allowdownload = $('#allowDownloadVideo').val();
389        if (allowdownload && allowdownload == 'true') {
390            allowdownload = true;
391        }
392        else {
393            allowdownload = false;
394        }
395
396        var videoObject = {
397            container: '#' + id, //容器的ID或className
398            variable: 'player', //播放函数名称
399            autoplay: autoplay, //是否自动播放
400            poster: poster,
401            video: src,
402            download: allowdownload
403        };
404
405        var embed;
406        if (src.indexOf('.flv') > 0) {
407            embed = createEmbedVideo(src, $this.data('height'), $this.data('width'));
408            $('#' + id).replaceWith($(embed));
409        } else if (src.indexOf('.swf') > 0) {
410            embed = swfHtml(src, $this.data('height'), $this.data('width'));
411            $('#' + id).replaceWith($(embed));
412        } else {
413            var player = new ckplayer(videoObject);
414        }
415
416    };
417
418    /**
419     * 创建swf视频Html
420     * @param {any} src - 路径
421     * @param {any} height - 高度
422     * @param {any} width - 宽度
423     */
424    function swfHtml(src, height, width) {
425        return '<div class="videoPlayer"><embed  src="' +
426            src +
427            '" allowFullScreen="true" quality="high" width="' +
428            width +
429            '" height="' +
430            height +
431            '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed></div>';
432    };
433
434    /**
435     * 创建wmv视频Html
436     * @param {any} src - 路径
437     * @param {any} width - 宽度
438     * @param {any} height - 高度
439     */
440    function createWmvVideo(src, width, height) {
441        return '<div class="videoPlayer"><object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer" ' +
442            'width="' +
443            width +
444            '" ' +
445            'height="' +
446            height +
447            '">' +
448            '<param name="URL" value="' +
449            src +
450            '">' +
451            '</object></div>';
452    };
453
454    /**
455     * 创建embed视频Html
456     * @param {any} src - 路径
457     * @param {any} height - 高度
458     * @param {any} width - 宽度
459     */
460    function createEmbedVideo(src, height, width) {
461        return '<div class="videoPlayer"><embed src="/content/_common/assets/ckplayer/ckplayer.swf" flashvars="video=' +
462            src +
463            '"  quality="high" width="' +
464            width +
465            '" height="' +
466            height +
467            '" align="middle" allowScriptAccess="always" allowFullscreen="true" type="application/x-shockwave-flash"></embed></div>';
468    };
469
470    /**
471     * 判断是否是ie8
472     */
473    function isIE8() {
474        //判断是否是IE8浏览器。
475        return navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.";
476    };
477
478    /**
479     * 判断是否ie
480     */
481    function isIe() {
482        //判断是否是IE浏览器。
483        return !!window.ActiveXObject || 'ActiveXObject' in window;
484    };
485
486    /**
487     * 判断是否wmv视频
488     * @param {any} src - 路径
489     */
490    function isWmv(src) {
491        //判断是否是 .wmv
492        return src.toLocaleLowerCase().indexOf('.wmv') > 0;
493    };
494
495    /**
496     * 判断是否flv视频
497     * @param {any} src - 路径
498     */
499    function isFlv(src) {
500        //判断是否是 .flv
501        return src.toLocaleLowerCase().indexOf('.flv') > 0;
502    };
503
504    /**
505     * 判断是否avi视频
506     * @param {any} src - 路径
507     */
508    function isAvi(src) {
509        //判断是否是 .flv
510        return src.toLocaleLowerCase().indexOf('.avi') > 0;
511    };
512
513    /**
514     * 请使用IE浏览器查看该视频
515     * @param {any} width - 宽度
516     * @param {any} height - 高度
517     */
518    function createIeTooltip(width, height) {
519        return '<div style="width:' +
520            width +
521            'px; height:' +
522            height +
523            'px; background-color:#000;margin: 0 auto;">' +
524            '<p style="width: ' +
525            width +
526            'px;height: ' +
527            height +
528            'px;line-height:' +
529            height +
530            'px; color:#fff; text-align:center;">请使用IE浏览器查看该视频</p></div>';
531    };
532
533    var powerVideoReversion = function () { };
534    powerVideoReversion.prototype = {
535        //提供个接口初始化后面新加的视频。
536        initVideo: initAllVideo
537    };
538
539    window.powerVideoReversion = powerVideoReversion;
540
541    /**
542    * 判断是否是MP3
543    * @param {any} url - 路径
544    */
545    function isMp3(url) {
546        if (!url) {
547            return "";
548        }
549        var dotIndex = url.lastIndexOf(".");
550        var filePathLength = url.length;
551        var filePathSuffix = url.substring(dotIndex, filePathLength);
552        var audioArr = ['.MP3',];
553        if (audioArr.indexOf(filePathSuffix.toUpperCase()) > -1) {
554            return "mp3";
555        } else {
556            return "";
557        }
558    };
559}();

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.