PageSourceSearch

https://en.falundafa.org/shared/js/functions.js

js falundafa.org collected 2026-10-02 02:30:27 UTC 9,070 bytes, 263 lines download raw bytes

1/* Init Methods */
2function InitHomePage() {
3    $(function () {
4        InitPage();
5        InitSlideshow();
6    });
7}
8
9function InitIntroductionPage() {
10}
11
12function InitBooksPage() {
13    AddCollapsedStyle();
14
15    $(function () {
16        InitPage();
17        InitTables('book');
18    });
19}
20
21function InitWritingsPage() {
22    AddCollapsedStyle();
23
24    $(function () {
25        InitPage();
26        InitTables('book');
27    });
28}
29
30function startPlayingM3U8_exercises() {
31    console.log("startPlayingM3U8_exercises() called");
32    document.getElementById('player-container-image').style.display = "none";
33    document.getElementById('player-container-video').style.display = "block";
34    InitExerciseAudioVideoPageM3U8();
35}
36
37function InitExerciseAudioVideoPageM3U8() {
38    $(function () {
39
40        var streamUrl = 'https://media2.falundafa.org/media1/stream/dafa/EnglishExercise_2021-08-24_m3u8/EnglishExercise_2021-08-24m.m3u8';
41        var video = document.getElementById('movieplayer');
42        if (Hls.isSupported()) {
43            var hls = new Hls();
44            hls.loadSource(streamUrl);
45            hls.attachMedia(video);
46            hls.on(Hls.Events.MANIFEST_PARSED, function () {
47                video.play();
48            });
49        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
50            video.src = streamUrl;
51            video.addEventListener('canplay', function () {
52                video.play();
53            });
54        }
55
56    });
57}
58
59/**
60 * Show and hide preview image
61 */
62function startPlayingM3U8_lecture() {
63    console.log("startPlayingM3U8_lecture() called");
64    document.getElementById('player-container-image').style.display = "none";
65    InitLectureAudioVideoPageM3U8();
66}
67
68function InitLectureAudioVideoPageM3U8() {
69    // see InitExerciseAudioVideoPageM3U8
70    // for ease of use we can call this on a new page
71    $(function () {
72
73        var videos = [
74            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L1English_20160205m.m3u8",
75            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L2English_20160205m.m3u8",
76            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L3English_20160205m.m3u8",
77            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L4English_20160205m.m3u8",
78            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L5English_20160205m.m3u8",
79            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L6English_20160205m.m3u8",
80            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L7English_20160205m.m3u8",
81            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L8English_20160205m.m3u8",
82            "https://media2.falundafa.org/media1/stream/dafa/EnglishGuangzhouLectures/L9English_20160205m.m3u8"
83        ];
84
85        var setupPlayer = function (index) {
86            var streamUrl = videos[index];
87            var image = 'shared/media/video-lecture-' + (index + 1) + '.jpg';
88
89            var video = document.getElementById('lecture-player');
90            video.poster = image;
91            video.width = video.clientWidth;
92            video.height = video.clientWidth * 400/534
93
94            if (Hls.isSupported()) {
95                var hls = new Hls();
96                hls.loadSource(streamUrl);
97                hls.attachMedia(video);
98                hls.on(Hls.Events.MANIFEST_PARSED, function () {
99                    console.log("hls.on(Hls.Events.MANIFEST_PARSED, function()) video play was called");
100                    video.play();
101                });
102            } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
103                video.src = streamUrl;
104                video.addEventListener('canplay', function () {
105                    video.play();
106                });
107            }
108        };
109
110        $('.tabs').TabsAccordion().on('expand', function (event, index, panel) {
111            // console.log("TabsAccordion:expand:event", event, index, panel);
112            var video = document.getElementById('lecture-player');
113            if (video && video.stop) video.stop();
114            var container = $('.player-container', panel);
115            $('#lecture-player-outer').detach().appendTo(container);
116            setupPlayer(index);
117        });
118
119        setupPlayer(0)
120    });
121}
122
123function InitMusicAudioVideoPage() {
124}
125
126function InitGlobalContactsPage() {
127    AddCollapsedStyle();
128
129    $(function () {
130        InitPage();
131        InitTables('contact');
132        InitMap('#map-background a');
133    });
134}
135
136function InitLocalContactsPage() {
137    AddCollapsedStyle();
138
139    $(function () {
140        InitPage();
141        InitTables('contact');
142        InitMap('map area');
143    });
144}
145
146/* Helpers */
147function AddCollapsedStyle() {
148    document.write('<style>.collapsed { height:31px; overflow: hidden; display:block; }</style>');
149}
150
151function InitPage() {
152    $('.title-hidden').attr('title', '');
153}
154
155function InitSlideshow() {
156    $(document).ready(function () {
157        $('.slideshow')
158            .after('<div id="nav" class="ir">')
159            .cycle({
160                fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
161                speed: 4000,
162                timeout: 3000,
163                pager: '#nav',
164                fit: true,
165                before: fixSliderImageHeight_forFirefox,
166                width: '100%'
167            });
168        $('.title-hidden').attr('title', '');
169
170        $(window).resize(function () {
171            setTimeout(fixSliderImageHeight_forFirefox, 200);
172        });
173
174        // maybe $( window ).on( "load", fixSliderImageHeight_forFirefox ); is enough
175        setTimeout(fixSliderImageHeight_forFirefox, 200);
176        setTimeout(fixSliderImageHeight_forFirefox, 1200);
177        setTimeout(fixSliderImageHeight_forFirefox, 2000);
178    });
179    $(window).on("load", fixSliderImageHeight_forFirefox);
180}
181
182function fixSliderImageHeight_forFirefox() {
183    var imageHeight = $('.first').height();
184    if (imageHeight > 10) {
185        $('.slideshow').height(imageHeight);
186    }
187}
188
189function InitTables(rowtype) {
190    // console.log('Pos0: InitTables');
191    $('.row-' + rowtype + '.collapsed').removeClass('collapsed').addClass('closed');
192    var $closedRow = $('.row-' + rowtype + '.closed');
193    $closedRow.find('div.row:not(:first-child)').hide();  // ADDED
194    $closedRow.find('div div.row').hide();  // ADDED
195    var $rows = $('.row-' + rowtype);
196    $rows.find('div.row:first-child').on('click', function (event) {
197        var $ele = $(this).parent().first();
198        if ($ele.hasClass('closed')) {
199            $ele.removeClass('closed').addClass('open');
200            $ele.find('div.row:not(:first-child)').show('slow');
201        } else {
202            $ele.removeClass('open').addClass('closed');
203        }
204
205    });
206
207    $('.row-' + rowtype + '.opened').find('div.row:first-child').on('click', function (event) {
208        $(this).parent().first().removeClass('opened').addClass('closed');
209        $(this).parent().first().find('div.row:not(:first-child)').hide();   // ADDED
210        $(this).parent().first().find('div div.row').hide();   // ADDED
211    });
212}
213
214function openContactOnHash(hash) {
215    var jname = $('a[name=' + hash + ']');
216    jname.next('.row-contact').removeClass('closed').addClass('opened');
217    jname.parent().first().find('div.row').show();   // ADDED
218}
219
220function InitMap(map) {
221    $(map).on('click', function (event) {
222        // console.log("pos3: 'click'");
223        var hash = $(this).attr('href').substr(1);
224        openContactOnHash(hash);
225    });
226
227    if (window.location.hash) {
228        var hash = window.location.hash.substr(1);
229        openContactOnHash(hash);
230    }
231}
232
233function PrintContact(hostname, username, linktext) {
234    if (!linktext) {
235        linktext = username + "@" + hostname;
236    }
237    document.write("<a style='word-wrap: break-word;' href='" + "mail" + "to:" + username + "@" + hostname + "'>" + linktext + "</a>");
238}
239
240// Alternative
241// <span id="e-name"></span><script>PrintContact2('e-name', 'example.com', 'name')</script>
242function PrintContact2(spanId, user, domain, linktext) {
243    if (!linktext) {
244        linktext = username + "@" + hostname;
245    }
246    const link = document.createElement('a');
247    link.href = `mailto:${linktext}`;
248    link.textContent = linktext;
249    document.getElementById(spanId).appendChild(link);
250}
251
252function EnableStats(lang, page) {
253    page = (typeof page !== 'undefined') ? page : 'n/a';
254    var i = /^(localhost|127\.|192\.|172\.|10\.|\w+[\.]?$)/;
255    var v = /http(s|)/;
256    if (!(i.test(document.location.host)) && (v.test(document.location.protocol))) {
257        var u = "//stats.minghui.org/";
258        document.write(
259            decodeURIComponent("%3Cimg src='" + u + "mhstats.php?site=fldforg&lang=" + lang + "&page=" + page + "&q=")
260            + encodeURI(window.location)
261            + decodeURIComponent("' style='display%3Anone%3Bborder%3A0%3Bheight%3A0%3Bwidth%3A0%3B' %2F%3E"));
262    }
263}

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.