PageSourceSearch

https://vektr.com/scripts/widgets/video-bg.js

js vektr.com collected 2026-10-02 00:19:59 UTC 2,077 bytes, 82 lines download raw bytes

1"use strict"; var $ = jQuery;
2module.exports = function(){
3	var $videoBgs = $(".video-bg");
4	if($videoBgs.length <1){
5		return;
6	}
7	var isPlayVideo = (function(){
8		var isMobile = $('html').hasClass('mobile');
9		var v=document.createElement('video');
10		var canMP4 = v.canPlayType ? v.canPlayType('video/mp4') : false;
11		return canMP4 && !isMobile;
12	})();
13	if( !isPlayVideo ){
14		$videoBgs.each(function(){
15			var $videoBg = $(this);
16			var alt = $videoBg.data('alternative');
17			if(alt){
18				var $img = $('<img alt class="bg" src="'+alt+'"/>');
19				$videoBg.after($img).remove();
20			}
21		});
22		return;
23	}
24	$videoBgs.each(function(){
25		var $divBg = $(this);
26		$divBg.data('loading', function(done){
27			var $videoBg = $('<video class="video-bg"></video>');
28			if($divBg.data('mute')==='yes') $videoBg[0].muted = true;
29			var vol = $divBg.data('volume');
30			if(vol !== undefined) $videoBg[0].volume= vol/100;
31			var doDone = function(){
32				var vw = $videoBg.width();
33				var vh = $videoBg.height();
34				var vr = vw/vh;
35				var $window = $(window);
36				var resize = function(){
37					var ww = $window.width();
38					var wh = $window.height();
39					var wr = ww/wh;
40					var w, h;
41					if(vr > wr){
42						h = Math.ceil(wh);
43						w = Math.ceil(h * vr);
44					}else{
45						w = Math.ceil(ww);
46						h = Math.ceil(w / vr);
47					}
48					$videoBg.css({
49						width:  w+'px',
50						height: h+'px',
51						top: Math.round((wh - h)/2)+'px',
52						left: Math.round((ww - w)/2)+'px'
53					});
54				};
55				$window.resize(resize);
56				resize();
57				$videoBg[0].play();
58				done();
59			};
60			$videoBg.on('ended', function(){
61				this.currentTime = 0;
62				this.play();
63				if(this.ended) {
64					this.load();
65				}
66			});
67			var isNotDone = true;
68			$videoBg.on('canplaythrough', function(){
69				if(isNotDone){
70					isNotDone = false;
71					doDone();
72				}else{
73					this.play();
74				}
75			});
76			$videoBg[0].src = $divBg.data('video');
77			$videoBg[0].preload="auto";
78			$divBg.after($videoBg);
79			$divBg.remove();
80		});
81	});
82};

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.