PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 1.5
WpStream – Live Streaming, Video on Demand, Pay Per View v1.5
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / js / admin_control.js

admin_control.js in WpStream – Live Streaming, Video on Demand, Pay Per View 1.5, at js/admin_control.js

385 lines 12.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*global $, jQuery, */
2 var counters={};
3
4 jQuery(document).ready(function ($) {
5 "use strict";
6
7 wpstream_check_live_connections();
8
9
10 jQuery('.copy_live_uri').click(function(){
11 var value_uri = jQuery(this).parent().find('.wpstream_live_uri_text').text();
12 var temp = jQuery("<input>");
13 jQuery("body").append(temp);
14 jQuery(temp).val(value_uri).select();
15 document.execCommand("copy");
16 jQuery(temp).remove();
17
18 });
19
20 jQuery('.copy_live_key').click(function(){
21 var value_uri = jQuery(this).parent().find('.wpstream_live_key_text').text();
22 var temp = jQuery("<input>");
23 jQuery("body").append(temp);
24 jQuery(temp).val(value_uri).select();
25 document.execCommand("copy");
26 jQuery(temp).remove();
27 });
28
29
30
31 var product_type= jQuery('#product-type').val();
32
33 if ( product_type === 'video_on_demand' ) {
34 jQuery('.show_if_video_on_demand' ).show();
35
36 }
37 else if ( product_type === 'live_stream' ) {
38 $( '.show_if_live_stream' ).show();
39
40 }
41
42
43
44
45
46 jQuery('#_subscript_live_event').change(function(){
47 if ( product_type === 'video_on_demand' || product_type === 'live_stream' ) {
48
49 }else{
50 var value= jQuery(this).val();
51 if(value==="no"){
52 jQuery("._movie_url_field").parent().removeClass("hide_if_subscription").show();
53 }else{
54 jQuery("._movie_url_field").parent().addClass("hide_if_subscription").hide();
55 }
56 }
57 });
58
59 jQuery('#_subscript_live_event').trigger('change');
60
61
62 $('#wpstream_product_type').change(function(){
63 $('.video_free').hide();
64
65 if( $('#wpstream_product_type').val()=== "2"){
66 $('.video_free').show();
67 }
68 });
69 $('#wpstream_product_type').trigger('change');
70
71
72
73
74 $('.close_event').click(function(event){
75 event.preventDefault();
76 var ajaxurl = admin_control_vars.admin_url + 'admin-ajax.php';
77 var acesta = $(this);
78 var parent = $(this).parent();
79 var notification_area = $(this).parent().find('.event_list_unit_notificationx');
80 var show_id = parseFloat( $(this).attr('data-show-id') );
81 var nonce = $('#wpstream_start_event_nonce').val();
82 $(this).unbind();
83 notification_area.text('Closing Event');
84
85
86 jQuery.ajax({
87 type: 'POST',
88 url: ajaxurl,
89 dataType: 'json',
90 data: {
91 'action' : 'wpstream_close_event',
92 'security' : nonce,
93 'show_id' : show_id
94 },
95 success: function (data) {
96 parent.remove();
97 },
98 error: function (errorThrown) {
99
100 }
101 });
102
103 });
104
105
106 $('.start_webcaster').on('click',function(){
107 var caster_url = $(this).attr('data-webcaster-url');
108 $(this).parent().find('.external_software_streaming').slideUp()
109 window.open(caster_url, '_blank', 'location=yes,height=390,width=660,scrollbars=yes,status=yes');
110 })
111
112 $('.start_external').on('click',function(){
113 $(this).parent().parent().find('.external_software_streaming').slideToggle();
114 });
115
116
117
118
119
120
121
122
123
124 function wpstream_check_live_connections(){
125 $('.pending_streaming.pending_trigger').each(function(){
126 var server_url = $(this).attr('data-server-url');
127 var counter = '';
128 var acesta = $(this);
129
130
131
132
133
134 wpstream_check_live_connections_step(acesta,server_url)
135 counter = setInterval( function (){ wpstream_check_live_connections_step(acesta,server_url)},3000);
136 counters[server_url]=counter;
137
138
139 var show_id = $(this).attr('data-server-id');
140 var counter_long = '';
141 counter_long = setInterval( function (){ wpstream_check_live_connections_from_database(acesta,show_id)},60000);
142 counters[show_id]=counter_long;
143
144 });
145
146
147
148 }
149
150
151
152
153 function wpstream_check_live_connections_step( acesta,server_url){
154
155 var server_status = wpstream_check_server_status(server_url,
156 function( server_status ){
157
158 if(server_status ){
159 acesta.removeClass('show_stream_data').addClass('hide_stream_data');
160 acesta.parent().find('.wpstream_ready_to_stream').removeClass('hide_stream_data').addClass('show_stream_data');
161 clearInterval( counters[server_url]);
162 }
163 });
164
165 }
166
167
168 function wpstream_check_live_connections_on_start( parent,server_url,data){
169
170 // server_url is dns change
171 wpstream_check_dns_avb_callback(data.dns_change_id,
172 function(server_status){
173
174 if(server_status ){
175 clearInterval( counters[server_url]);
176
177 parent.find('.pending_streaming').removeClass('show_stream_data').addClass('hide_stream_data');
178 parent.find('.wpstream_ready_to_stream ').removeClass('hide_stream_data').addClass('show_stream_data');
179 parent.find('.external_software_streaming ').removeClass('hide_stream_data').addClass('show_stream_data');
180 parent.find('.wpstream_ready_to_stream .start_webcaster').attr('data-webcaster-url',data.caster_url)
181 parent.find('.wpstream_live_uri_text').text(data.obs_uri);
182 parent.find('.wpstream_live_key_text').text(data.obs_stream);
183
184 }
185 });
186
187 }
188
189
190
191
192 function wpstream_check_live_connections_from_database( acesta,show_id){
193
194 var server_status = wpstream_check_server_status_from_db(show_id,
195 function(server_status){
196
197 if(!server_status ){
198
199 acesta.removeClass('show_stream_data').addClass('hide_stream_data');
200 acesta.parent().find('.wpstream_ready_to_stream').removeClass('show_stream_data').addClass('hide_stream_data');
201 acesta.parent().find('.external_software_streaming').removeClass('show_stream_data').addClass('hide_stream_data');
202 acesta.parent().find('.wpstream_no_stream').removeClass('hide_stream_data').addClass('show_stream_data');
203
204 clearInterval( counters[show_id]);
205 }
206 });
207
208 }
209
210 function wpstream_check_server_status_from_db(show_id,callback){
211 var ajaxurl = admin_control_vars.admin_url + 'admin-ajax.php';
212 jQuery.ajax({
213 type: 'POST',
214 url: ajaxurl,
215 dataType: 'json',
216 data: {
217 'action' : 'wpstream_check_server_against_db',
218 'show_id' : show_id,
219 },
220 success: function (data) {
221 if(data.islive){
222 callback (true);
223 }else{
224 callback (false);
225 }
226
227 },
228 error: function (errorThrown) {
229 }
230 });
231 }
232
233
234
235 function wpstream_check_server_status(url_param,callback) {
236
237 var url = url_param ;
238 var status='';
239 $.ajax({
240 url: url,
241 type: "get",
242 cache: false,
243 dataType: 'jsonp', // it is for supporting crossdomain
244 crossDomain : true,
245 asynchronous : false,
246 timeout : 1500, // set a timeout in milliseconds
247 callback:'',
248 complete : function(xhr) {
249 if(xhr.status == "200" || xhr.status == "400") {
250 callback(true);
251 }
252 else {
253 callback(false);
254 }
255 }
256 });
257 }
258
259
260
261
262 $('.start_event').click(function(event){
263 event.preventDefault();
264 var ajaxurl = admin_control_vars.admin_url + 'admin-ajax.php';
265 var acesta = $(this);
266 var notification_area = $(this).parent().find('.event_list_unit_notification');
267 var curent_content = $(this).parent().find('.server_notification');
268 var is_record = 0;
269 var show_id = parseFloat( $(this).attr('data-show-id') );
270 var nonce = $('#wpstream_start_event_nonce').val();
271 var parent= $(this).parent().parent();
272
273 if( $(this).parent().find('.record_event').is(":checked") ){
274 is_record = 1;
275 }
276
277 $(this).unbind();
278 $(this).hide();
279 parent.find('.record_wrapper').hide();
280 parent.find('.close_event ').hide();
281 curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>Getting ready to stream. Please wait...<img class="" src="'+admin_control_vars.loading_url+'" alt="loading"></div>');
282 parent.find('.multiple_warning_events').html('* Starting a channel can take 1-2 minutes or more. Please be patient.');
283
284
285 jQuery.ajax({
286 type: 'POST',
287 url: ajaxurl,
288 dataType: 'json',
289 timeout: 300000,
290
291 data: {
292 'action' : 'wpstream_give_me_live_uri',
293 'security' : nonce,
294 'show_id' : show_id,
295 'is_record' : is_record
296 },
297 success: function (data) {
298
299 if(data.conected===true){
300
301 curent_content.empty();
302 parent.find('.wpstream_no_stream').removeClass('show_stream_data').addClass('hide_stream_data');
303 parent.find('.pending_streaming').removeClass('hide_stream_data').addClass('show_stream_data');
304 var counter = setInterval( function (){ wpstream_check_live_connections_on_start(parent,data.server_status_check,data)},10000);
305 counters[data.server_status_check]=counter;
306
307 var counter_long = '';
308 counter_long = setInterval( function (){ wpstream_check_live_connections_from_database(parent,show_id)},60000);
309 counters[show_id]=counter_long;
310
311
312 }else{
313 parent.find('.wpstream_no_stream').addClass('show_stream_data').empty().html("You don't have enough streaming bandwidth to start a new event!");
314 }
315
316 },
317 error: function (jqXHR,textStatus,errorThrown) {
318
319 }
320 });
321
322 });
323
324
325 });
326
327
328
329 function wpstream_check_dns_avb_callback(url_param,callback){
330
331 var ajaxurl = admin_control_vars.admin_url + 'admin-ajax.php';
332 jQuery.ajax({
333 type: 'POST',
334 url: ajaxurl,
335 timeout: 3000000,
336
337 data: {
338 'action' : 'wpstream_check_dns_sync',
339 'change_id' : url_param,
340
341 },
342 success: function (data) {
343
344 if(data=='INSYNC'){
345 callback(true);
346 }else{
347 callback(false);
348 }
349
350 }, error: function (jqXHR,textStatus,errorThrown) {
351
352 }
353 });
354 }
355
356
357
358
359
360
361
362
363 function wpstream_enable_cliboard(parent){
364
365 jQuery(parent).find('.copy_live_uri').click(function(){
366 alert('click');
367 var value_uri = jQuery(parent).find('.wpstream_live_uri_text').text();
368 var temp = jQuery("<input>");
369 jQuery("body").append(temp);
370 jQuery(temp).val(value_uri).select();
371 document.execCommand("copy");
372 jQuery(temp).remove();
373
374 });
375
376 jQuery(parent).find('.copy_live_key').click(function(){
377 var value_uri = jQuery(parent).find('.wpstream_live_key_text').text();
378 var temp = jQuery("<input>");
379 jQuery("body").append(temp);
380 jQuery(temp).val(value_uri).select();
381 document.execCommand("copy");
382 jQuery(temp).remove();
383
384 });
385 }