PageSourceSearch

https://www.iheartfrugal.com/wp-content/plugins/facebook-conversion-pixel/video.compiled.js

js iheartfrugal.com collected 2026-09-30 11:02:40 UTC 15,076 bytes, 572 lines download raw bytes

1'use strict';
2
3var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
5var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
6
7function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
10
11function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
13if ((typeof fcaPcPost === 'undefined' ? 'undefined' : _typeof(fcaPcPost)) === 'object' && fcaPcPost.video_enabled === "1") {
14	var onYouTubeIframeAPIReady = function onYouTubeIframeAPIReady() {
15
16		fcaPcVideos.forEach(function (video) {
17			if (video.type !== 'YOUTUBE') {
18				return;
19			}
20
21			video.emit('api_youtube_loaded');
22		});
23	};
24
25	// detect all videos on the page
26	var detect_videos = function detect_videos() {
27
28		var videos = [];
29
30		jQuery('iframe').each(function () {
31			videos.push(jQuery(this));
32		});
33
34		jQuery('script').each(function () {
35
36			var src = jQuery(this).attr('src');
37
38			if (typeof src === 'undefined') {
39				return;
40			}
41
42			if (src.indexOf('https://fast.wistia.com/embed/medias/') === -1) {
43				return;
44			}
45
46			videos.push(jQuery(this));
47		});
48
49		if (videos.length === 0) {
50
51			if (fcaPcDebug) {
52				console.log('No videos detected');
53			}
54
55			return;
56		}
57
58		videos.forEach(function (video) {
59			window.fcaPcVideos.push(new FCA_PC_Video(video));
60		});
61	};
62
63	var EventEmitter = function () {
64		function EventEmitter() {
65			_classCallCheck(this, EventEmitter);
66
67			this.events = {};
68		}
69
70		_createClass(EventEmitter, [{
71			key: 'on',
72			value: function on(event, listener) {
73				var _this = this;
74
75				if (_typeof(this.events[event]) !== 'object') {
76					this.events[event] = [];
77				}
78				this.events[event].push(listener);
79				return function () {
80					return _this.removeListener(event, listener);
81				};
82			}
83		}, {
84			key: 'removeListener',
85			value: function removeListener(event, listener) {
86				if (_typeof(this.events[event]) === 'object') {
87					var idx = this.events[event].indexOf(listener);
88					if (idx > -1) {
89						this.events[event].splice(idx, 1);
90					}
91				}
92			}
93		}, {
94			key: 'emit',
95			value: function emit(event) {
96				var _this2 = this;
97
98				for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
99					args[_key - 1] = arguments[_key];
100				}
101
102				if (_typeof(this.events[event]) === 'object') {
103					this.events[event].forEach(function (listener) {
104						return listener.apply(_this2, args);
105					});
106				}
107			}
108		}, {
109			key: 'once',
110			value: function once(event, listener) {
111				var _this3 = this;
112
113				var remove = this.on(event, function () {
114					for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
115						args[_key2] = arguments[_key2];
116					}
117
118					remove();
119					listener.apply(_this3, args);
120				});
121			}
122		}]);
123
124		return EventEmitter;
125	}();
126
127	var FCA_PC_Video = function (_EventEmitter) {
128		_inherits(FCA_PC_Video, _EventEmitter);
129
130		function FCA_PC_Video(selector) {
131			_classCallCheck(this, FCA_PC_Video);
132
133			var _this4 = _possibleConstructorReturn(this, (FCA_PC_Video.__proto__ || Object.getPrototypeOf(FCA_PC_Video)).call(this));
134
135			_this4.video_ready = false;
136
137			if ((typeof selector === 'undefined' ? 'undefined' : _typeof(selector)) === undefined) {
138				return _possibleConstructorReturn(_this4);
139			}
140
141			_this4.element = selector;
142			_this4.init();
143
144			return _this4;
145		}
146
147		_createClass(FCA_PC_Video, [{
148			key: 'init',
149			value: function init() {
150
151				this.setup_events();
152				this.type = this.video_type();
153				this.load_api();
154			}
155		}, {
156			key: 'load_api',
157			value: function load_api() {
158				switch (this.type) {
159					case 'YOUTUBE':
160						this.api_youtube_load();
161						break;
162					case 'WISTIA':
163						this.api_wistia_load();
164						break;
165					case 'VIMEO':
166						this.api_vimeo_load();
167						break;
168				}
169			}
170		}, {
171			key: 'setup_events',
172			value: function setup_events() {
173				this.on('api_youtube_loaded', this.api_youtube_setup);
174				this.on('api_vimeo_loaded', this.api_vimeo_setup);
175				this.on('api_wistia_loaded', this.api_wistia_setup);
176			}
177		}, {
178			key: 'video_type',
179			value: function video_type() {
180				var src = this.element.attr('src');
181
182				if (src === '') {
183					this.revoke('pixel cat video: video link not found.');
184					return false;
185				}
186
187				if (src.indexOf('youtube.com') > -1) return 'YOUTUBE';
188				if (src.indexOf('vimeo.com') > -1) return 'VIMEO';
189				if (src.indexOf('fast.wistia.com') > -1) return 'WISTIA';
190			}
191		}, {
192			key: 'revoke',
193			value: function revoke(message) {
194				if (fcaPcDebug.debug) {
195					console.log(message);
196					console.log('pixel cat video: revoked ');
197				}
198				// Do some code that revoke video JS here.
199			}
200
201			//VIMEO
202
203		}, {
204			key: 'api_vimeo_load',
205			value: function api_vimeo_load() {
206				var _this5 = this;
207
208				jQuery.getScript('https://player.vimeo.com/api/player.js', function () {
209					_this5.emit('api_vimeo_loaded');
210				});
211			}
212		}, {
213			key: 'api_vimeo_setup',
214			value: function api_vimeo_setup() {
215				var _this6 = this;
216
217				var player_dom = this.element[0];
218				try {
219					this.api = new Vimeo.Player(player_dom);
220					this.api.ready().then(function () {
221						_this6.api_vimeo_ready();
222					});
223				} catch (e) {
224					if (fcaPcDebug.debug) console.log(e.message);
225					return;
226				}
227			}
228		}, {
229			key: 'api_vimeo_ready',
230			value: function api_vimeo_ready() {
231				var _this7 = this;
232
233				if (fcaPcDebug.debug) {
234					console.log('Pixel Cat video: Vimeo video ready');
235				}
236
237				this.video_ready = true;
238
239				this.api.getVideoId().then(function (id) {
240					_this7.video_id = id;
241				});
242
243				this.api.getVideoTitle().then(function (title) {
244					_this7.title = title;
245				});
246
247				this.api.getVideoUrl().then(function (url) {
248					_this7.url = url;
249				});
250
251				this.api.getDuration().then(function (duration) {
252					_this7.duration = duration;
253				});
254
255				this.events_triggered = {};
256
257				this.api_vimeo_state_change();
258			}
259		}, {
260			key: 'api_vimeo_state_change',
261			value: function api_vimeo_state_change() {
262				var _this8 = this;
263
264				this.api.on('play', function (event) {
265					_this8.trigger_event('VideoPlay');
266					_this8.timer = setInterval(_this8.track_progress.bind(_this8), 1000);
267				});
268
269				this.api.on('pause', function (event) {
270					_this8.trigger_event('VideoPause', { percentage_watched: _this8.percentage_watched() + '%' });
271					clearInterval(_this8.timer);
272				});
273
274				this.api.on('ended', function (event) {
275					_this8.trigger_event('VideoWatchToEnd');
276					clearInterval(_this8.timer);
277				});
278			}
279
280			//WISTIA
281
282		}, {
283			key: 'api_wistia_load',
284			value: function api_wistia_load() {
285				var _this9 = this;
286
287				jQuery.getScript('//fast.wistia.net/assets/external/E-v1.js', function () {
288					_this9.emit('api_wistia_loaded');
289				});
290			}
291		}, {
292			key: 'api_wistia_setup',
293			value: function api_wistia_setup() {
294
295				var player_dom = this.element;
296
297				var video_src = player_dom.attr('src');
298
299				if (typeof video_src === 'undefined') {
300					return;
301				}
302
303				//GET VIDEO ID FROM URL
304
305				var pattern = /(https:\/\/fast\.wistia\.com\/embed\/medias)\/(.*)\.jsonp/;
306
307				var match = video_src.match(pattern);
308
309				console.log(match);
310
311				if (match === null) {
312
313					if (fcaPcDebug) {
314						console.log('no video id match');
315					}
316
317					return;
318				}
319
320				this.url = match[1];
321
322				var video_id = match[2];
323
324				if (typeof video_id === 'undefined') {
325					if (fcaPcDebug.debug) {
326						console.log('pixel cat video: wistia video_id not found.');
327					}
328					return;
329				}
330
331				window._wq = window._wq || [];
332
333				this.api = window._wq;
334
335				this.api.push({
336					id: video_id,
337					onReady: this.api_wistia_ready.bind(this)
338				});
339			}
340		}, {
341			key: 'api_wistia_ready',
342			value: function api_wistia_ready(video) {
343
344				if (fcaPcDebug.debug) {
345					console.log('pixel cat video: wistia video ready.');
346				}
347
348				this.video_ready = true;
349				this.api = video;
350
351				this.video_id = video.data.media.hashedId;
352				this.title = video.data.media.name !== undefined ? video.data.media.name : 'Untitled';
353				this.url = this.url + '/' + this.video_id;
354				this.events_triggered = {};
355				this.api_wistia_state_change.bind(this)();
356			}
357		}, {
358			key: 'api_wistia_state_change',
359			value: function api_wistia_state_change() {
360				var _this10 = this;
361
362				this.api.bind('play', function (event) {
363					_this10.trigger_event('VideoPlay');
364				});
365
366				this.api.bind('pause', function (event) {
367					_this10.trigger_event('VideoPause', { percentage_watched: _this10.percentage_watched() + '%' });
368				});
369
370				this.api.bind('percentwatchedchanged', function (percent, lastPercent) {
371					_this10.track_progress();
372				});
373
374				this.api.bind('end', function (event) {
375					_this10.trigger_event('VideoWatchToEnd');
376				});
377			}
378
379			//YOUTUBE
380
381		}, {
382			key: 'api_youtube_load',
383			value: function api_youtube_load() {
384				this.load_async_script('https://www.youtube.com/iframe_api');
385			}
386		}, {
387			key: 'api_youtube_setup',
388			value: function api_youtube_setup() {
389				var player_dom = this.element[0];
390				this.api = new YT.Player(player_dom, {
391					events: {
392						'onReady': this.api_youtube_ready.bind(this),
393						'onStateChange': this.api_youtube_state_change.bind(this)
394					}
395				});
396			}
397		}, {
398			key: 'api_youtube_ready',
399			value: function api_youtube_ready(event) {
400
401				if (fcaPcDebug.debug) {
402					console.log('pixel cat video: youtube video ready');
403				}
404
405				// @todo: we will need to build this one in future to make sure the video is ready to use the object
406				this.video_ready = true;
407				this.data = this.api.getVideoData();
408				this.video_id = this.data.video_id;
409				this.title = this.data.title;
410				this.url = this.api.getVideoUrl();
411
412				this.events_triggered = {};
413			}
414		}, {
415			key: 'api_youtube_state_change',
416			value: function api_youtube_state_change(event) {
417				if (fcaPcDebug.debug) {
418					console.log(event);
419				}
420
421				switch (event.data) {
422					case 0:
423						// end video
424						this.trigger_event('VideoWatchToEnd');
425						clearInterval(this.timer);
426						break;
427
428					case 1:
429						// play video
430						this.trigger_event('VideoPlay');
431						// Since we check progress using range: ( percent >= 10 && percent < 25 )
432						// So we do not need to set interval too fast. 1 - 2 seconds should be fine
433						this.timer = setInterval(this.track_progress.bind(this), 1000);
434						break;
435
436					case 2:
437						// pause video
438						this.trigger_event('VideoPause', { percentage_watched: this.percentage_watched() + '%' });
439						clearInterval(this.timer);
440						break;
441				}
442			}
443		}, {
444			key: 'video_youtube_end',
445			value: function video_youtube_end() {
446				if (fcaPcDebug) {
447					console.log('end');
448				}
449			}
450		}, {
451			key: 'load_async_script',
452			value: function load_async_script(url) {
453				var new_script = document.createElement('script');
454				var first_script = document.getElementsByTagName('script')[0];
455
456				new_script.src = url;
457
458				first_script.parentNode.insertBefore(new_script, first_script);
459
460				if (fcaPcDebug.debug) {
461					console.log('pixel cat video: ' + url + ' has been loaded.');
462				}
463			}
464		}, {
465			key: 'track_progress',
466			value: function track_progress() {
467				switch (this.video_type()) {
468					case 'YOUTUBE':
469					case 'VIMEO':
470					case 'WISTIA':
471						this.video_track_progress();
472						break;
473
474					// Other cases
475				}
476			}
477		}, {
478			key: 'video_track_progress',
479			value: function video_track_progress() {
480				var percent = this.percentage_watched();
481
482				if (fcaPcDebug.debug) {
483					console.log(this.percentage_watched());
484				}
485
486				// Need to cover all the cases and reduce interval time -> better performance
487				// Use switch here for better code readable
488				switch (true) {
489					// 10% milestone
490					case percent >= 10 && percent < 25:
491						this.trigger_event('VideoWatch10Percent');
492						break;
493
494					// 25% milestone
495					case percent >= 25 && percent < 50:
496						this.trigger_event('VideoWatch25Percent');
497						break;
498
499					case percent >= 50 && percent < 75:
500						this.trigger_event('VideoWatch50Percent');
501						break;
502
503					case percent >= 75 && percent < 90:
504						this.trigger_event('VideoWatch75Percent');
505						break;
506
507					case percent >= 90 && percent < 100:
508						this.trigger_event('VideoWatch90Percent');
509						break;
510				}
511			}
512		}, {
513			key: 'video_params',
514			value: function video_params() {
515				return {
516					video_title: this.title,
517					video_url: this.url,
518					video_id: this.video_id
519				};
520			}
521		}, {
522			key: 'percentage_watched',
523			value: function percentage_watched() {
524				var _this11 = this;
525
526				switch (this.type) {
527					case 'YOUTUBE':
528						return Math.round(this.api.getCurrentTime() / this.api.getDuration() * 100);
529
530					case 'VIMEO':
531						this.api.getCurrentTime().then(function (current_time) {
532							_this11.current_time = current_time;
533						});
534						return Math.round(this.current_time / this.duration * 100);
535
536					case 'WISTIA':
537						return Math.round(this.api.time() / this.api.duration() * 100);
538
539					default:
540						return false;
541				}
542			}
543		}, {
544			key: 'trigger_event',
545			value: function trigger_event(action) {
546				var additional_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
547
548
549				if (this.events_triggered[action]) {
550					return;
551				}
552
553				var params = Object.assign({}, this.video_params(), additional_params);
554
555				this.emit('pixel_event', 'trackCustom', action, params);
556
557				// Add exception for VideoPause event
558				if (action !== 'VideoPause') {
559					this.events_triggered[action] = true;
560				}
561			}
562		}]);
563
564		return FCA_PC_Video;
565	}(EventEmitter);
566
567	FCA_PC_Video.prototype.__proto__ = EventEmitter.prototype;
568
569	window.fcaPcVideos = [];
570
571	detect_videos();
572}

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.