PageSourceSearch

https://www.legaltechsociety.org/javascripts/flowplayer_setup.js?v=35

js legaltechsociety.org collected 2026-10-05 05:29:30 UTC 6,215 bytes, 171 lines download raw bytes

1// Flowplayer setup
2function flowplayerSetup(key, type, id, width, height, file, file_type, autostart, controlbar, image, caption, no_redirect, resource_id, vhcs, vhmp) {
3    let o_file = file;
4
5    try {
6        file = window.atob(file);
7    } catch(e) {
8        console.log('not encoded');
9    }
10    if (no_redirect && window.navigator.onLine) {
11        on_ready(function () {
12            $.get(file.replace('/files/', '/blob/get_s3_url/'), function (response) {
13                if (response.status == 'ok') {
14                    o_file = response.s3_url;
15                }
16
17                flowplayerSetup(key, type, id, width, height, o_file, file_type, autostart, controlbar, image, caption, false, resource_id, vhcs, vhmp);
18            });
19        });
20    } else {
21        const name = file.split('?')[0].split('/').pop().replace(/_lmsauth_\w+/, '');
22        let $elem;
23
24        if (type == 'audio') {
25            $elem = document.getElementById("flowpa" + id).parentNode;
26        } else if (type == 'video') {
27            const flowpv = document.getElementById("flowpv" + id);
28            $elem = flowpv.parentNode;
29            flowpv.dataset.resourceId = resource_id;
30        }
31
32        if (!hasClass($elem, "_processed")) {
33            if (controlbar == "over" && hasParentId($elem, "news1")) {
34                const newCode = "" + '<a href="javascript:void(0);" onclick=\'showVideo("' + key + '", "' + type + '", "' + id + '", "' + width + '", "' + height + '", "' + file + '", "' + file_type + '", ' + image + ', "' + caption + '" ,' + resource_id + ', "' + vhcs + '", ' + vhmp + ')\'>' + '<img src="/images/icons/video-play.png" width="40" alt="' + name + '" title="' + name + '" />' + '</a>' + '<span>' + name + '</span>';
35                const newElem = document.createElement('p');
36                newElem.innerHTML = newCode;
37                newElem.setAttribute("id", 'videoPrev' + id);
38                $elem.parentNode.insertBefore(newElem, $elem);
39                $elem.style.display = 'none';
40            } else {
41                if ($elem.getAttribute("class")) {
42                    $elem.setAttribute("class", $elem.getAttribute("class") + " _processed" + (is_responsive_flowplayer(height) ? " responsive_flowplayer" : ""));
43                } else {
44                    $elem.setAttribute("class", "_processed" + (is_responsive_flowplayer(height) ? " responsive_flowplayer" : ""));
45                }
46
47                setup_player(key, type, id, width, height, file, file_type, autostart, image, caption, resource_id, vhcs, vhmp);
48            }
49        }
50    }
51}
52
53function is_responsive_flowplayer(height) {
54    return ((height.indexOf(':') != -1) || (window.innerWidth < 768));
55}
56
57function hasClass(el, cls) {
58    var elemClassName = el.getAttribute("class");
59    return ((" " + elemClassName + " ").replace(/[\n\t]/g, " ").indexOf(cls) > -1);
60}
61
62function showVideo(key, type, id, width, height, file, file_type, image, caption, resource_id, vhcs, vhmp) {
63    if (type == 'audio') {
64        var $elem = document.getElementById("flowpa" + id).parentNode;
65    } else if (type == 'video') {
66        var $elem = document.getElementById("flowpv" + id).parentNode;
67    }
68
69    var $p = document.getElementById("videoPrev" + id);
70    $p.parentNode.removeChild($p);
71
72    if (!hasClass($elem, "_processed")) {
73        $elem.style.display = "block";
74
75        if ($elem.getAttribute("class")) {
76            $elem.setAttribute("class", $elem.getAttribute("class") + " _processed");
77        } else {
78            $elem.setAttribute("class", "_processed");
79        }
80
81        setup_player(key, type, id, width, height, file, file_type, true, image, caption, resource_id, vhcs, vhmp);
82
83        if (type == 'video') {
84            flowplayer(document.getElementById('flowpv' + id)).play();
85        }
86    }
87}
88
89function hasParentId(el, id) {
90    var $parent = el.parentNode;
91
92    while ($parent.getAttribute) {
93        if ($parent.getAttribute("id") == id) {
94            return true;
95        }
96
97        $parent = $parent.parentNode;
98    }
99
100    return false;
101}
102
103function setup_player(key, type, id, width, height, file, file_type, autostart, image, caption, resource_id, vhcs, vhmp) {
104    var options = {
105        key: key,
106        swf: '/libraries/flowplayer/7.2.7/flowplayer.swf',
107        swfHls: '/libraries/flowplayer/7.2.7/flowplayerhls.swf',
108        autoplay: autostart,
109        native_fullscreen: true,
110        fullscreen: true,
111        share: false,
112        clip: {
113            sources: [
114                {type: file_type, src: file}
115            ]
116        },
117        embed: false,
118        debug: is_flowplayer_debug_mode(),
119        playerId: `#flowpv${id}`,
120        resourceId: resource_id,
121        completed: vhcs === 'finished'
122    };
123
124    if (type == 'audio') {
125        var container = document.getElementById('flowpa' + id);
126        container.innerHTML = '';
127
128        options.audio = true;
129        options.audioOnly = true;
130        options.clip.audio = true;
131    } else if (type == 'video') {
132        var container = document.getElementById('flowpv' + id);
133        container.innerHTML = '';
134
135      if (caption != null) {
136        options.clip.subtitles = [
137          { "default": true, kind: "subtitles", srclang: "en", label: "Track 1", src: caption }
138        ]
139      }
140    }
141
142    if (is_responsive_flowplayer(height)) {
143        //options.ratio = ((window.innerWidth < 768) ? '16:9' : height);
144        options.adaptiveRatio = true;
145
146        container.style.width = ((window.innerWidth < 768) ? '100%' : width);
147    } else {
148        container.style.width = width;
149        container.style.height = height;
150    }
151
152    if (autostart != true) {
153        options.splash = true;
154    } else {
155        options.splash = false;
156    }
157
158    const player = flowplayer(container, options);
159    // video activity detector
160    new VideoActivityDetectorExtension(player);
161    // video autoplay
162    if (isAutoplayEnabled()) new VideoAutoplayExtension(player);
163    // video completion
164    if (resource_id && isVideoCompletionEnabled()) new VideoCompletionExtension(player, vhcs, vhmp);
165}
166
167on_ready(function () {
168    $(window).on('beforexload', function () {
169        window.flowplayer && flowplayer.resetPlayer();
170    });
171})

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.