PageSourceSearch

https://e123.hk/themes/inv/e123_enar_sub/assets/e123/js/e123-live-details.js?v=3&v=1

js e123.hk collected 2026-10-01 12:22:57 UTC 12,741 bytes, 243 lines download raw bytes

1jQuery(function ($) {
2    $(document).ready(function () {
3        //Node Page Video to iframe
4        if ($(".node-page-video-info .field--name-field-video-id").length > 0) {
5            var currect_uid = drupalSettings.user.uid;
6            var current_path_in_drupal = drupalSettings.path.currentPath;
7            var current_path_in_drupal_arr = current_path_in_drupal.split("/");
8            var nid = current_path_in_drupal_arr[1];            //  /node/{{id}}  ->  {{id}}
9            var ngo_tid = $(".field--name-field-ngo").text();
10            var video_visibility = $(".field--name-field-video-visibility").text();
11
12            if (video_visibility == "public") {
13                _load_video_iframe_in_details("public");
14            } else {
15                var skip_checking = false;
16
17                if (currect_uid > 0) {
18                    $.ajax({
19                        url: "/current-user-info?_format=json",
20                        cache: false,
21                        method: "GET",
22                        headers: { Accept: "application/json", "Content-Type": "application/json" },
23                        success: function (data, status, xhr) {
24                            //Some admin people will skip the private & unlisted checking
25                            if (data.length > 0) {
26                                var role = data[0]["roles"];
27                                console.log("ngo_tid: " + ngo_tid);
28                                console.log(role);
29                                if (role.toLowerCase().indexOf("administrator") >= 0 || role.toLowerCase().indexOf("1a") >= 0 || role.toLowerCase().indexOf("1b") >= 0) {
30                                    skip_checking = true;
31                                } else {
32                                    if (role.toLowerCase().indexOf("3a") >= 0 || role.toLowerCase().indexOf("3b") >= 0) {
33                                        //Check the current user with NGO user
34                                        $.ajax({
35                                            url: "/code/ngo_user_by_ngo-HGFDXFCGHJDDEF/" + ngo_tid + "?_format=json",
36                                            cache: false,
37                                            method: "GET",
38                                            headers: { Accept: "application/json", "Content-Type": "application/json" },
39                                            success: function (data, status, xhr) {
40                                                console.log(data);
41                                                if (data.length > 0) {
42                                                    var host_users_arr = data[0]["field_host_users"];
43                                                    if (host_users_arr.indexOf(currect_uid) != -1) skip_checking = true;
44                                                }
45                                            },
46                                            error: function (data) {},
47                                        });
48                                    }
49                                }
50                            }
51
52                            if (skip_checking == true) {
53                                _load_video_iframe_in_details("");
54                            } else {
55                                $(".page-title .field--name-title").html("(非公開) " + $(".page-title .field--name-title").text());
56                                if (video_visibility == "unlisted") {
57                                    _show_lity_popup_for_unlisted_in_details();
58                                } else {
59                                    if (video_visibility == "private") {
60                                        if (currect_uid != 0) {
61                                            //Loggon User: Check the currect user is match with "allowed Member"
62                                            $.ajax({
63                                                type: "GET",
64                                                url: "/get_allowed_user-FHGdfdgdfapef/" + nid + "?_format=json",
65                                                cache: false,
66                                                beforeSend: function () {},
67                                                success: function (data) {
68                                                    if (data.length > 0) {
69                                                        var allowed_users_arr = data[0]["field_private_allowed_users"].split("\r\n");
70                                                        if (allowed_users_arr.indexOf(currect_uid) != -1) {
71                                                            _load_video_iframe_in_details("private");
72                                                        } else {
73                                                            _show_lity_popup_if_access_de
73nied_in_details("user");
74                                                        }
75                                                    } else {
76                                                        _show_lity_popup_if_access_denied_in_details("user");
77                                                    }
78                                                },
79                                                error: function (data) {},
80                                                complete: function () {},
81                                            });
82                                        } else {
83                                            // console.log('Not Allow Guest');
84                                            _show_lity_popup_if_access_denied_in_details("guest");
85                                        }
86                                    }
87                                }
88                            }
89                        },
90                        error: function (data) {},
91                    });
92                } else {
93                    $(".page-title .field--name-title").html("(非公開) " + $(".page-title .field--name-title").text());
94                    if (video_visibility == "unlisted") {
95                        _show_lity_popup_for_unlisted_in_details();
96                    } else {
97                        if (video_visibility == "private") {
98                            // console.log('Not Allow Guest');
99                            _show_lity_popup_if_access_denied_in_details("guest");
100                        }
101                    }
102                }
103            }
104        }
105    });
106
107    function _load_video_iframe_in_details(video_visibility) {
108        $.each($(".node-page-video-info"), function () {
109            var html = "";
110            var facebook_pages_id = $.trim($(this).find(".field--name-field-facebook-pages-id").text());
111            var video_id = $.trim($(this).find(".field--name-field-video-id").text());
112            var video_platform = $.trim($(this).find(".field--name-field-video-platform").text());
113
114            // if (video_visibility != "public") {
115            //     $(".page-title .field--name-title").html("(非公開) " + $(".page-title .field--name-title").text());
116            // }
117
118            var embed_link = "";
119            if (video_platform == "youtube") {
120                embed_link = "https://www.youtube.com/embed/" + video_id;
121            }
122
123            if (video_platform == "facebook") {
124                var fb_video_url = "https://www.facebook.com/" + facebook_pages_id + "/videos/" + video_id + "/";
125                embed_link = "https://www.facebook.com/plugins/video.php?href=" + encodeURIComponent(fb_video_url) + "&width=1280";
126            }
127
128            html += '<iframe width="560" height="315" src="' + embed_link + '" ';
129            html += 'frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen>';
130            html += "</iframe>";
131
132            $(this).html(html);
133            $(this).removeClass("d-none");
134        });
135    }
136
137    function _show_lity_popup_for_unlisted_in_details() {
138        // var current_path = drupalSettings.path.currentPath;
139        var current_path = encodeURIComponent(window.location.pathname);
140        var html = "";
141        var title = "";
142        var content = "";
143        var login_link = "";
144
145        title += "重温節目: " + $(".page-title .field--name-title").html();
146        content = "<p>請輸入影片密碼:</p>";
147
148        html += '<div id="access_denied_popup" style="overflow:auto;" class="lity-hide">';
149        html += "<h2>" + title + "</h2>";
150        html += content;
151        html += '<input type="password" id="unlisted_password_input_in_details" value="" size="50" maxlength="50" class="form-text" autocomplete="off">';
152        html += '<p id="unlisted_password_input_message" class="messages d-none"></p>';
153        html += "</div>";
154        if (html != "") {
155            html += '<a class="btn open_access_denied_popup" href="#access_de
155nied_popup" data-lity>Open access_denied_popup</a>';
156            $("body").append(html);
157            setTimeout(function () {
158                $(".open_access_denied_popup").trigger("click");
159                $("#unlisted_password_input_in_details").focus();
160            }, 1000);
161        }
162    }
163
164    function _show_lity_popup_if_access_denied_in_details(user_type) {
165        // var current_path = drupalSettings.path.currentPath;
166        var current_path = encodeURIComponent(window.location.pathname);
167        var html = "";
168        var title = "";
169        var content = "";
170        var login_link = "";
171
172        title += "重温節目: " + $(".page-title .field--name-title").html();
173        if (user_type == "guest") {
174            login_link = "/zh-hant/user/login?destination=" + current_path;
175            content += "請先登錄以觀看視頻";
176            content += '<div class="link_in_popup"><a href="' + login_link + '">立即登入</a></div>';
177        } else {
178            content += "抱歉,您尚未受邀! ";
179        }
180
181        html += '<div id="access_denied_popup" style="overflow:auto;" class="lity-hide">';
182        html += "<h2>" + title + "</h2>";
183        html += content;
184        html += "</div>";
185        if (html != "") {
186            html += '<a class="btn open_access_denied_popup" href="#access_denied_popup" data-lity>Open access_denied_popup</a>';
187            $("body").append(html);
188            setTimeout(function () {
189                $(".open_access_denied_popup").trigger("click");
190            }, 1000);
191        }
192    }
193
194    //Enter passcode
195    $(document).on("keypress", "#unlisted_password_input_in_details", function (e) {
196        if (e.keyCode == 13 && e.target.type !== "submit") {
197            var msg = "#unlisted_password_input_message";
198            var _this = $(this);
199            var input_passcode = $(this).val();
200
201            if (input_passcode != "") {
202                //Check the passcode
203                $.ajax({
204                    type: "GET",
205                    url: "/check-password-kUbUwhqFAhRUiQd/" + input_passcode + "?_format=json",
206                    cache: false,
207                    beforeSend: function () {
208                        $(msg).addClass("d-none");
209                    },
210                    success: function (data) {
211                        if (data.length > 0) {
212                            //Correct
213                            //  Close the popupand load the video
214                            $(msg).removeClass("messages--error");
215                            $(msg).addClass("messages--status");
216                            $(msg).html("影片密碼正確,現在進入影片...");
217
218                            setTimeout(function () {
219                                _load_video_iframe_in_details("unlisted");
220                                $(".lity-close").trigger("click");
221                            }, 1000);
222                        } else {
223                            //Incorrect
224                            //  show the error message
225                            $(msg).removeClass("messages--status");
226                            $(msg).addClass("messages--error");
227                            $(msg).html("影片密碼錯誤! ");
228                            _this.val("");
229                        }
230                        $(msg).removeClass("d-none");
231                    },
232                    error: function (data) {},
233                    complete: function () {},
234                });
235            } else {
236                $(msg).removeClass("messages--status");
237                $(msg).addClass("messages--error");
238                $(msg).html("請輸入影片密碼! ");
239                $(msg).removeClass("d-none");
240            }
241        }
242    });
243});

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.