PageSourceSearch

https://www.positivekristen.com/wp-content/plugins/influex-video-popup/assets/js/script.js?ver=1.3.3

js positivekristen.com collected 2026-10-04 05:08:40 UTC 5,036 bytes, 173 lines download raw bytes

1function getYouTubeID(url) {
2	const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
3	const match = url.match(regExp);
4
5	return (match && match[2].length === 11) ?
6		match[2] :
7		null;
8}
9
10function parseVideo(url) {
11    // - Supported YouTube URL formats:
12    //   - http://www.youtube.com/watch?v=My2FRPA3Gf8
13    //   - http://youtu.be/My2FRPA3Gf8
14    //   - https://youtube.googleapis.com/v/My2FRPA3Gf8
15    // - Supported Vimeo URL formats:
16    //   - http://vimeo.com/25451551
17    //   - http://player.vimeo.com/video/25451551
18    // - Also supports relative URLs:
19    //   - //player.vimeo.com/video/25451551
20
21    url.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
22
23    if (RegExp.$3.indexOf('youtu') > -1) {
24        var type = 'youtube';
25    } else if (RegExp.$3.indexOf('vimeo') > -1) {
26        var type = 'vimeo';
27    }
28
29    return {
30        type: type,
31        id: RegExp.$6
32    };
33}
34
35// 2. This code loads the IFrame Player API code asynchronously.
36if ( typeof loadScript === 'function' ) {
37	loadScript( 'https://www.youtube.com/iframe_api', () => {} );
38	loadScript( 'https://player.vimeo.com/api/player.js', () => {} );
39} else {
40	// YouTube
41	var yt = document.createElement('script');
42	yt.src = "https://www.youtube.com/iframe_api";
43	var ytScriptTag = document.getElementsByTagName('script')[0];
44	ytScriptTag.parentNode.insertBefore(yt, ytScriptTag);
45
46	// Vimeo
47	var vm = document.createElement('script');
48	vm.src = "https://player.vimeo.com/api/player.js";
49	var vmScriptTag = document.getElementsByTagName('script')[0];
50	vmScriptTag.parentNode.insertBefore(vm, vmScriptTag);
51}
52
53// 3. This function creates an <iframe> (and YouTube player)
54//    after the API code downloads.
55var player;
56var api_ready = false;
57function onYouTubeIframeAPIReady() {
58	api_ready = true;
59}
60
61// 4. The API will call this function when the video player is ready.
62function onPlayerReady(event) {
63	event.target.playVideo();
64}
65
66// 5. The API calls this function when the player's state changes.
67//    The function indicates that when playing a video (state=1),
68//    the player should play for six seconds and then stop.
69var done = false;
70function onPlayerStateChange(event) {
71
72}
73
74function stopVideo() {
75	player.stopVideo();
76}
77
78jQuery(document).ready(function () {
79
80	function showPopup( obj ) {
81
82		var player_id = obj.find('> .video-player > div').attr('id');
83
84		jQuery.magnificPopup.open({
85			mainClass: 'mfp-fade',
86			items: {
87				src: obj, // can be a HTML string, jQuery object, or CSS selector
88				type: 'inline'
89			},
90			callbacks: {
91				open: function() {
92					preparePlayer( player_id );
93				},
94				beforeClose: function() {
95					// Remove YouTube player
96					var src = jQuery( '#' + player_id ).attr('data-src');
97					jQuery( '#' + player_id ).parent().html( '<div data-src="' + src + '" id="' + player_id + '"></div>' );
98				},
99				close: function() {
100					
101				}
102			}
103		});
104
105	}
106
107	function preparePlayer( player_id ) {
108		
109		if ( ! api_ready ) {
110			return false;
111		}
112
113		var player_box = document.getElementById( player_id );
114		if ( player_box ) {
115
116			var src = player_box.getAttribute('data-src');
117			var video = parseVideo( src );
118			
119			if ( video.type && video.id ) { 
120				if ( video.type == 'vimeo' ) {					
121					jQuery( '#' + player_id ).parent().html( '<iframe id="' + player_id + '" src="https://player.vimeo.com/video/' + video.id + '?muted=1" data-src="' + src + '" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' );
122					setTimeout(() => {
123						var iframe = document.querySelector( '#' + player_id );
124						player = new Vimeo.Player( iframe );
125						player.play();
126					}, 250);
127				} else {
128					player = new YT.Player( player_id, {
129						height: '824',
130						width: '1920',
131						videoId: video.id,
132						playerVars: {
133							'rel' : 0,
134							'showinfo' : 0,
135							'modestbranding' : 1,
136							'origin': window.location.href,
137							'enablejsapi': 1,
138						},
139						events: {
140							'onReady': onPlayerReady,
141							'onStateChange': onPlayerStateChange
142						}
143					});
144				}
145			}
146		}
147
148	}
149
150	function prepareVideos() {
151		jQuery('.influex-popup-video').each( function() {
152		
153			box = jQuery(this).find('.video-player-box > .video-player > div');
154	
155			var id = Math.random().toString(36).slice(2);	// Generate random alpha numeric string
156			box.attr('id', 'video_player_' + id );
157	
158		});
159	}
160	prepareVideos();
161
162	// Trigger this event if the videos are in a Slick JS slider or loaded by AJAX
163	jQuery('body').on( 'influex_video_popup_init', function() {
164		prepareVideos();
165	});
166
167	jQuery('body').on( 'click', '.influex-popup-video > a', function(e) {
168		e.preventDefault();
169		e.stopImmediatePropagation();
170		showPopup( jQuery(this).next('.video-player-box') );
171	});
172
173});

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.