PageSourceSearch

https://andymagro.com/Plugin/Videos/assets/jquery.lazy.av.min.js?8

js andymagro.com collected 2026-10-07 21:16:13 UTC 4,401 bytes, 115 lines download raw bytes

1/*!
2 * jQuery & Zepto Lazy - AV Plugin - v1.3
3 * http://jquery.eisbehr.de/lazy/
4 *
5 * Copyright 2012 - 2016, Daniel 'Eisbehr' Kern
6 *
7 * Dual licensed under the MIT and GPL-2.0 licenses:
8 * http://www.opensource.org/licenses/mit-license.php
9 * http://www.gnu.org/licenses/gpl-2.0.html
10 */
11;(function($) {
12    // loads audio and video tags including tracks by two ways, like:
13    // <audio>
14    //   <data-src src="audio.ogg" type="video/ogg"></data-src>
15    //   <data-src src="audio.mp3" type="video/mp3"></data-src>
16    // </audio>
17    // <video data-poster="poster.jpg">
18    //   <data-src src="video.ogv" type="video/ogv"></data-src>
19    //   <data-src src="video.webm" type="video/webm"></data-src>
20    //   <data-src src="video.mp4" type="video/mp4"></data-src>
21    //   <data-track kind="captions" src="captions.vtt" srclang="en"></data-track>
22    //   <data-track kind="descriptions" src="descriptions.vtt" srclang="en"></data-track>
23    //   <data-track kind="subtitles" src="subtitles.vtt" srclang="de"></data-track>
24    // </video>
25    //
26    // or:
27    // <audio data-src="audio.ogg|video/ogg,video.mp3|video/mp3"></video>
28    // <video data-poster="poster.jpg" data-src="video.ogv|video/ogv,video.webm|video/webm,video.mp4|video/mp4">
29    //   <data-track kind="captions" src="captions.vtt" srclang="en"></data-track>
30    //   <data-track kind="descriptions" src="descriptions.vtt" srclang="en"></data-track>
31    //   <data-track kind="subtitles" src="subtitles.vtt" srclang="de"></data-track>
32    // </video>
33    $.lazy(["av", "audio", "video"], ["audio", "video"], function(element, response) {
34        var elementTagName = element[0].tagName.toLowerCase();
35
36        if( elementTagName == "audio" || elementTagName == "video" ) {
37            var srcAttr = "data-src",
38                sources = element.find(srcAttr),
39                tracks = element.find("data-track"),
40                sourcesInError = 0,
41
42            // create on error callback for sources
43            onError = function() {
44                if( ++sourcesInError == sources.length )
45                    response(false);
46            },
47
48            // create callback to handle a source or track entry
49            handleSource = function() {
50                var source = $(this),
51                    type = source[0].tagName.toLowerCase(),
52                    attributes = source.prop("attributes"),
53                    target = $(type == srcAttr ? "<source>" : "<track>");
54
55                if( type == srcAttr )
56                    target.one("error", onError);
57
58                $.each(attributes, function(index, attribute) {
59                    target.attr(attribute.name, attribute.value);
60                });
61
62                source.replaceWith(target);
63            };
64
65            // create event for successfull load
66            element.one("loadedmetadata", function() {
67                response(true);
68            })
69
70            // remove default callbacks to ignore loading poster image
71            .off("load error")
72
73            // load poster image
74            .attr("poster", element.attr("data-poster"));
75
76            // load by child tags
77            if( sources.length )
78                sources.each(handleSource);
79
80            // load by attribute
81            else if( element.attr(srcAttr) ) {
82                // split for every entry by comma
83                $.each(element.attr(srcAttr).split(","), function(index, value) {
84                    // split again for file and file type
85                    var parts = value.split("|");
86
87                    // create a source entry
88                    element.append($("<source>")
89                           .one("error", onError)
90                           .attr({src: parts[0].trim(), type: parts[1].trim()}));
91                });
92
93                // remove now obsolete attribute
94                if( this.config("removeAttribute") )
95                    element.removeAttr(srcAttr);
96            }
97
98            else {
99                // pass error state
100                // use response function for Zepto
101                response(false);
102            }
103
104            // load optional tracks
105            if( tracks.length )
106                tracks.each(handleSource);
107        }
108
109        else {
110            // pass error state
111            // use response function for Zepto
112            response(false);
113        }
114    });
115})(window.jQuery || window.Zepto);

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.