PageSourceSearch

https://kanal8.mk/wp-content/plugins/wpstream/public/js/start_streaming.js?ver=202604100113

js kanal8.mk collected 2026-10-02 23:29:02 UTC 35,979 bytes, 1,119 lines download raw bytes

1/*global $, jQuery, wpstream_start_streaming_vars*/
2var counters={};
3
4// post_type can be FTV or PPV channel or VOD
5var post_type = null;
6
7jQuery(document).ready(function ($) {
8    "use strict";
9
10	wpstream_set_current_post_type();
11    wpstream_check_live_connections();
12    wpestate_start_modal_actions();
13    wpestate_start_modal_error_actions();
14    wpstream_tooltip();
15    wpstream_copy_to_clipboard();
16    // Commenting the following line because we are using the new webcaster
17    wpstream_webcaster_actions();
18    wpstream_save_options_actions();
19	wpstream_save_use_global_event_options();
20    wpstream_bind_start_and_stop();
21
22    wpstream_bind_stats_link();
23    wpstream_adjust_settings_general();
24
25});
26
27function wpstream_safe_track_onboarding(action, step, element_type = 'button', element_name = '') {
28	if (typeof wpstream_track_onboarding_step === 'function') {
29		wpstream_track_onboarding_step(action, step, element_type, element_name);
30	}
31}
32
33function wpstream_set_current_post_type() {
34	let params = (new URL(document.location)).searchParams;
35	let branch= params.get( 'branch' );
36	branch = parseInt( branch );
37
38	if( isNaN( branch ) ) {
39		post_type = null;
40	}
41
42	switch ( branch ) {
43		case 1:
44			post_type = 'ftv_channel';
45			break;
46		case 2:
47			post_type = 'ppv_channel';
48			break;
49		case 3:
50			post_type = 'ftv_vod';
51			break;
52		case 4:
53			post_type = 'ppv_vod';
54			break;
55		default:
56			post_type = null;
57	}
58}
59
60/*
61*
62* genereal settings - low latency vs bitrate vs encrypt
63*
64*/
65
66
67function wpstream_adjust_settings_general(){
68   
69    jQuery('.theme_options_tab_wpstream .wpstream_slider').on('click',function(event){
70        event.stopPropagation();
71        var parent = jQuery(this).parent();
72        var input_element = parent.find('.wpstream_event_option_item');
73        var attr_value = input_element.attr('data-attr-ajaxname');
74      
75
76        if( attr_value === 'adaptive_bitrate' || attr_value==='low_latency'){
77            
78            var timer = setTimeout(function() {
79               
80                if( jQuery('.wpstream-setting-adaptive_bitrate .wpstream_event_option_item').is(':checked') || 
81                    jQuery('.wpstream-setting-low_latency .wpstream_event_option_item').is(':checked') ){
82                    jQuery('.wpstream-setting-encrypt .wpstream_event_option_item') .removeAttr('checked'); 
83                }   
84            }, 300);
85
86        }
87
88        if( attr_value === 'encrypt'){
89            var timer = setTimeout(function() {
90               
91                if( jQuery('.wpstream-setting-encrypt .wpstream_event_option_item').is(':checked') ){
92                    jQuery('.wpstream-setting-low_latency .wpstream_event_option_item') .removeAttr('checked'); 
93                    jQuery('.wpstream-setting-adaptive_bitrate .wpstream_event_option_item') .removeAttr('checked'); 
94                }
95            }, 300);
96
97        }
98
99    });
100}
101
102
103
104
105
106
107
108
109
110
111/*
112*
113* Bind block stats link
114*
115*/
116
117function wpstream_bind_stats_link(){
118 
119    jQuery('.wpstream_statistics_channel,.start_webcaster').each(function(event){
120        var selected_icon = jQuery(this);
121            selected_icon.on('click',function(event){
122                if(selected_icon.hasClass('wpstream_inactive_icon')){
123                    event.preventDefault();
124                    event.stopPropagation();
125                }
126                
127            });
128        
129    })
130
131
132}
133
134
135
136
137/*
138*
139* Bind Start and Stop channel
140*
141*/
142    
143
144function wpstream_bind_start_and_stop(){
145    
146    jQuery('.start_event.wpstream_button').each(function(element){
147        var start_button=jQuery(this);    
148        wpstream_bind_start_event(start_button);
149    });
150
151
152    jQuery('.wpstream_stop_event').each(function(element){
153        var stop_button=jQuery(this);
154        wpstream_bind_stop_event(stop_button);
155    });
156
157}
158
159
160/*
161*
162* Bind start  channel action
163*
164*/
165var start_onboarding='';
166function wpstream_bind_start_event(button){
167   
168    button.click(function(event){
169        wpstream_safe_track_onboarding('stream_attempted', 'wpstream_' + post_type);
170		wpstream_safe_track_onboarding('start_stream_clicked', 'wpstream_' + post_type);
171        var basicStreaming = jQuery('#wpstream_basic_streaming').val() === 'true';
172        if (basicStreaming){
173            console.log("doing basic streaming");
174            if(!confirm(wpstream_start_streaming_vars.basic_streaming_warning)){
175                return false;
176            }
177        }
178        
179        event.preventDefault();
180        button.unbind('click');
181        var ajaxurl             =   wpstream_start_streaming_vars.admin_url + 'admin-ajax.php';
182        var acesta              =   jQuery(this);
183        var notification_area   =   jQuery(this).parent().find('.event_list_unit_notification');
184        var curent_content      =   jQuery(this).parent().find('.server_notification');
185        var is_record           =   false;
186        var is_encrypt          =   false;
187        var show_id             =   parseFloat( jQuery(this).attr('data-show-id') );
188        var nonce               =   jQuery('#wpstream_start_event_nonce').val();
189        var parent              =   jQuery(this).parent();
190        
191        if( jQuery(this).parent().find('.record_event').is(":checked") ){
192            is_record   =   true;
193        }
194        
195        if( jQuery(this).parent().find('.encrypt_event').is(":checked") ){
196            is_encrypt   =   true;
197        }
198        parent.find('.wpstream_show_settings').addClass('wpstream_inactive_icon');
199        jQuery(this).addClass('wpstream_turning_on').empty().html(wpstream_start_streaming_vars.start_streaming_action+'<div class="wpstream_loader"></div><div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turning_on_tooltip+'</div>');
200        parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_turning_on);
201
202        jQuery.ajax({
203            type: 'POST',
204            url: ajaxurl,
205            dataType: 'json',
206            timeout: 300000,
207
208            data: {
209                'action'            :   'wpstream_give_me_live_uri',
210                'security'          :   nonce,
211                'show_id'           :   show_id,
212                'is_record'         :   is_record,
213                'is_encrypt'        :   is_encrypt,
214                'basic_streaming'   :   basicStreaming,
215                'start_onboarding'  :   start_onboarding,
216               
217                
218            },
219            success: function (data) {
220                
221              
222       
223                if(data.conected===true){
224             
225                        if(data.event_data==='err1'){
226							wpstream_safe_track_onboarding('stream_start_failed', 'wpstream_' + post_type, 'system', 'err1');
227                        
228                            wpstream_show_error_on_start(wpstream_start_streaming_vars.error1,parent)
229                        
230                        }else if(data.event_data ==='failed event creation'){
231							wpstream_safe_track_onboarding('stream_start_failed', 'wpstream_' + post_type, 'system', 'failed_event_creation');
232                        
233                            wpstream_show_error_on_start(wpstream_start_streaming_vars.failed_event_creation,parent)
234                        
235                        }else{
236                            curent_content.empty();
237                            var counter =  setInterval( function (){
238								wpstream_check_live_connections_on_start(parent,show_id,data.event_data,data)
239                            },10000);
240                            counters['stop'+show_id]=counter;
241                    
242                        }
243                        
244            
245                }else{
246					wpstream_safe_track_onboarding('stream_start_failed', 'wpstream_' + post_type, 'system', 'api_not_connected');
247                    wpstream_show_error_on_start(data.error,parent)
248                }
249                
250            },
251            error: function (jqXHR,textStatus,errorThrown) {             
252				wpstream_safe_track_onboarding('stream_start_failed', 'wpstream_' + post_type, 'system', 'ajax_error');
253            }
254        });
255        
256    });
257    
258}
259
260
261/*
262*
263* Bind Stop channel action
264*
265*/
266
267function wpstream_bind_stop_event(button){
268    button.click(function(event){
269		wpstream_safe_track_onboarding( 'stop_stream_clicked', 'wpstream_' + post_type );
270
271
272        if(!confirm(wpstream_start_streaming_vars.turn_off_confirm)){
273            return false;
274        }
275        button.unbind('click');
276
277
278        var ajaxurl             =   wpstream_start_streaming_vars.admin_url + 'admin-ajax.php';
279        var show_id             =   parseFloat( jQuery(this).attr('data-show-id') );
280        var nonce               =   jQuery('#wpstream_start_event_nonce').val();
281        var parent              =   jQuery(this).parent();
282        var thisButton          =   jQuery(this);
283      
284        thisButton.removeClass('wpstream_stop_event');
285        thisButton.addClass('wpstream_turning_on').empty().html(wpstream_start_streaming_vars.stop_streaming_action+'<div class="wpstream_loader"></div><div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turning_off_tooltip+'</div>');
286        parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_turning_off);
287        parent.find('.start_webcaster').addClass('wpstream_inactive_icon');
288        parent.find('.wpstream_stream_pro').addClass('wpstream_inactive_icon');
289        parent.find('.wpstream_live_data').addClass('wpstream_inactive_icon');
290
291
292
293        jQuery.ajax({
294            type: 'POST',
295            url: ajaxurl,
296            dataType: 'json',
297            timeout: 300000,
298
299            data: {
300                'action'            :   'wpstream_turn_of_channel',
301                'security'          :   nonce,
302                'show_id'           :   show_id
303               
304                
305            },
306            success: function (data) {
307
308                if(data.conected===true){
309                    
310                    thisButton.unbind('click');
311         
312                    var counter =  setInterval( function (){ 
313                        wpstream_check_live_connections_on_start(parent,show_id,'',data)},10000);
314                        counters["stop"+show_id]=counter;
315
316                }else{
317               
318                    wpstream_show_error_on_stop(data.error,parent)
319                }
320                
321            },
322            error: function (jqXHR,textStatus,errorThrown) {
323             
324            }
325        });
326        
327    
328    
329    });
330    
331}
332
333
334/*
335*
336* Enable copy to clipboard
337*
338*/
339
340function wpstream_enable_cliboard(parent){
341    
342    jQuery(parent).find('.copy_live_uri').click(function(){
343      
344        var value_uri = jQuery(parent).find('.wpstream_live_uri_text').text();
345        var temp = jQuery("<input>");
346        jQuery("body").append(temp);
347        jQuery(temp).val(value_uri).select();
348        document.execCommand("copy");
349        jQuery(temp).remove();
350        
351    });
352    
353    jQuery(parent).find('.copy_live_key').click(function(){
354        var value_uri = jQuery(parent).find('.wpstream_live_key_text').text();
355        var temp = jQuery("<input>");
356        jQuery("body").append(temp);
357        jQuery(temp).val(value_uri).select();
358        document.execCommand("copy");
359        jQuery(temp).remove();
360        
361    });
362}
363
364
365/*
366 *
367 * Check live events/channels on starts 
368 * 
369 * 
370 * 
371*/
372
373
374function wpstream_check_live_connections_on_start( parent,show_id,server_id,data){
375      
376    // server_url is dns change
377  
378    wpstream_check_event_status_in_js(show_id,'wpstream_check_live_connections_on_start',
379        function(server_status){
380      
381            if(server_status.status==='active' ){
382                parent.find('.start_webcaster').attr('data-webcaster-url',server_status.webcaster_url);
383                parent.find('.wpstream_live_uri_text').text(server_status.obs_uri);
384                parent.find('.wpstream_live_key_text').text(server_status.obs_stream);
385
386                wpstream_event_ready_make_actions_visible(parent);
387
388                var larix_rtmp= server_status.obs_uri+server_status.obs_stream;
389                parent.find('.wpstream_larix_rtmp').text(larix_rtmp); 
390
391                var   larix_qr ='larix://set/v1?conn[][url]='+encodeURIComponent(larix_rtmp);
392                parent.find('.wpstream_start_with_larix_mobile').attr('href',larix_qr); 
393
394                parent.find('.wpstream_larix_rtmp').text(larix_rtmp); 
395                parent.find('.larrix_test').text(larix_rtmp); 
396              
397
398                var print_qrcode= "https://qrcode.tec-it.com/API/QRCode?size=small&dpi=110&data="+encodeURIComponent(larix_qr);
399
400
401                parent.find('.print_qrcode').attr('src',print_qrcode); 
402                
403                parent.parent().find('.wpstream_live_data').attr('href',server_status.live_data_url);         
404                clearInterval( counters["stop"+show_id]);
405
406				if (counters[show_id]) {
407					clearInterval(counters[show_id]);
408				}
409				var server_id   =   jQuery(this).attr('data-server-id');
410				counters[show_id] = setInterval( function (){
411					wpstream_check_live_connections_from_database(parent,show_id,server_id);
412				},60000);
413
414                if (typeof wpstream_integration_notifications === 'function') {
415                    wpstream_integration_notifications(show_id);
416                }
417
418                
419            }else if(server_status.status==='stopped' ){    
420             console.log('stopped status from _on_start');
421                clearInterval( counters["stop"+show_id]);
422                wpstream_event_stopped_make_actions(parent);
423
424            }else if(server_status.status==='error' ){
425                wpstream_safe_track_onboarding('stream_start_failed', 'wpstream_' + post_type, 'system', 'status_error');
426               
427                clearInterval( counters["stop"+show_id]);
428                var curent_content = parent.find('.wpstream_channel_status');
429                curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'+wpstream_start_streaming_vars.failed_event_creation+'</div>');
430            }
431    });
432
433}
434
435
436
437
438/*
439 * check channell id status
440 * 
441 * @param {type} channel_id
442 * @param {type} callback
443 * @returns {undefined}
444 * 
445 * 
446*/
447
448function wpstream_check_event_status_in_js(channel_id,notes,successCallback, errorCallback){
449
450    var ajaxurl = wpstream_start_streaming_vars.admin_url + 'admin-ajax.php';
451	var nonce = jQuery('#wpstream_start_event_nonce').val();
452
453    jQuery.ajax({
454        type: 'POST',
455        dataType: 'json',
456        url: ajaxurl,
457        timeout: 3000000,
458
459        data: {
460            'action'            :   'wpstream_check_event_status',
461            'channel_id'        :   channel_id,
462            'notes'             :   notes,
463	        'nonce'             :   nonce
464        },
465        success: function (data) {
466
467            var obj = data;
468            var channel_status = obj.status;
469
470            if(channel_status=='active' || channel_status=='stopped'  ){
471                successCallback(obj);
472            }else if(channel_status=='error'){
473                successCallback(obj);
474            }else{
475                successCallback(false);
476            }
477            
478        }, error: function (jqXHR,textStatus,errorThrown) {
479            errorCallback();
480        }
481  });
482}
483
484
485/*
486*
487* Make actions visible on event if ready
488*
489*
490*/
491function wpstream_event_ready_make_actions_visible(parent){
492
493    var actionButton = parent.find('.start_event');
494    parent.addClass('wpstream_show_started');
495    actionButton.unbind('click');
496    wpstream_bind_stop_event(actionButton);
497    
498    actionButton.addClass('wpstream_stop_event').removeClass('start_event').html(wpstream_start_streaming_vars.stop_streaming+'<div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turned_off_tooltip+'</div>');
499    parent.find('.wpstream-button-icon').removeClass('wpstream_inactive_icon');
500    parent.find('.wpstream_show_settings').addClass('wpstream_inactive_icon');
501    const channelStatus = parent.find('.wpstream_channel_status');
502	channelStatus.each(function( index, element ) {
503		if ( !jQuery(element).hasClass('not_ready_to_stream') && jQuery(element).css('display', 'none') ) {
504			console.log('put back channel on');
505			jQuery(element).text(wpstream_start_streaming_vars.channel_on);
506			jQuery(element).fadeIn(200);
507		}
508		if ( jQuery(element).hasClass('not_ready_to_stream') ) {
509			console.log('hide the element');
510			jQuery(element).hide();
511		}
512	});
513	const stopEventButton = parent.find('.wpstream_stop_event');
514	if ( stopEventButton.css('display', 'none') ) {
515		stopEventButton.fadeIn(200);
516	}
517    var webcasterUrl = parent.find('.start_webcaster').attr('data-webcaster-url');
518    if (webcasterUrl === ""){
519        parent.find('.start_webcaster').addClass('wpstream_inactive_icon');
520        parent.find('.start_webcaster .wpstream_tooltip_disabled').text('Browser Broadcasting is not Available for your plan.');
521    }
522
523    //for onboarding
524    var check_against='3';
525    var check_against_camera_icon='5';
526    if(jQuery('#woocommerce-product-data').length>0){
527        check_against='5'
528        check_against_camera_icon='7';
529    }       
530   
531    
532    var bubble_Step =jQuery('#wpstream_onboard_bubble').attr('data-bubble-step');
533
534    if(bubble_Step===check_against){
535        jQuery('#wpstream_onboard_bubble_tile').text('Channel is now ON');
536        jQuery('#wpstream_onboard_bubble_content').text('You are ready to GO LIVE. Click Next to see how.');
537    }
538    if(bubble_Step===check_against_camera_icon){
539        jQuery('#wpstream_onboard_bubble_tile').html('Go LIVE');
540        jQuery('#wpstream_onboard_bubble_content').html('To Go Live now, click the <div class=\"wpstream_sample_icon_settings wpstream_sample_icon_camera\"></div> icon. The broadcast app will open in a new window.');
541        
542        if( jQuery('.event_list_unit .wpstream_button').hasClass('wpstream_stop_event') ){
543            jQuery('.wpstream_sample_icon_camera').css('cursor','pointer');
544          
545            jQuery('.wpstream_sample_icon_camera').on('click',function(){
546                jQuery('.start_webcaster').trigger('click');
547                jQuery(this).unbind('click');
548
549            })   
550        }
551
552    }
553
554	// console.log('adding pending trigger');
555	// parent.addClass('pending_trigger');
556	// console.log('adding check for status');
557	// // wpstream_check_live_connections();
558	// console.log('parent ' , parent);
559}
560
561function wpstream_event_error_make_actions_visible(parent){
562    var actionButton = parent.find('.start_event');
563    const channelStatus = parent.find('.wpstream_channel_status');
564    actionButton.unbind('click');
565    actionButton.hide();
566    channelStatus.hide();
567
568    parent.find('.server_notification').html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'+wpstream_start_streaming_vars.failed_fetching+'</div>');
569}
570
571
572/*
573*
574* Make actions visible on event if stopped
575*
576*
577*/
578function wpstream_event_stopped_make_actions(parent){
579
580    var  actionButton = parent.find('.wpstream_turning_on');
581    wpstream_bind_start_event(actionButton);
582    parent.removeClass('wpstream_show_started');
583    actionButton.removeClass('wpstream_turning_on');
584    actionButton.addClass('start_event');
585    actionButton.html( wpstream_start_streaming_vars.start_streaming+'<div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turned_on_tooltip+'</div>');
586
587    parent.find('.wpstream-button-icon').removeClass('wpstream_inactive_icon');
588    parent.find('.wpstream_stream_pro').addClass('wpstream_inactive_icon');
589    parent.find('.start_webcaster').addClass('wpstream_inactive_icon');
590    parent.find('.wpstream_statistics_channel').addClass('wpstream_inactive_icon');
591
592    parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_off);
593}
594
595/*
596*
597* Make actions visible on event if stopped
598*
599*
600*/
601function wpstream_event_stopped_after_status_check(parent){
602
603	var actionButton = parent.find('.wpstream_stop_event');
604	actionButton.unbind('click');
605	wpstream_bind_start_event(actionButton);
606	parent.removeClass('wpstream_show_started');
607	actionButton.removeClass('wpstream_turning_on');
608	actionButton.addClass('start_event');
609	actionButton.html( wpstream_start_streaming_vars.start_streaming+'<div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turned_on_tooltip+'</div>');
610
611	parent.find('.wpstream-button-icon').removeClass('wpstream_inactive_icon');
612	parent.find('.wpstream_stream_pro').addClass('wpstream_inactive_icon');
613	parent.find('.start_webcaster').addClass('wpstream_inactive_icon');
614	parent.find('.wpstream_statistics_channel').addClass('wpstream_inactive_icon');
615
616	parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_off);
617}
618
619
620
621function wpstream_show_error_on_start(text,parent){
622    //You don't have enough data to start a new event!
623    jQuery('.wpstream_error_content').text(text);
624    jQuery('.wpstream_modal_background').show();
625    jQuery('.wpstream_error_modal_notification').show();
626    wpstream_event_stopped_make_actions(parent);
627
628}
629
630function wpstream_show_error_on_stop(text,parent){
631    //You don't have enough data to start a new event!
632    jQuery('.wpstream_error_content').text(text);
633    jQuery('.wpstream_modal_background').show();
634    jQuery('.wpstream_error_modal_notification').show();
635    wpstream_event_ready_make_actions_visible(parent);
636
637}
638
639
640/*
641*
642* Streaming modal trigger functions
643*  
644*
645*/
646function wpestate_start_modal_actions(){
647
648    jQuery('.wpstream_close_modal').on('click',function(event){
649        jQuery(this).parent().hide();
650        jQuery('.wpstream_modal_background').hide();
651    });
652
653    document.addEventListener('keydown', function(event) {
654        if(event.keyCode == 27){
655            jQuery('.wpstream_modal_form').hide();
656            jQuery('.wpstream_modal_background').hide();
657        }
658    });
659
660
661    jQuery('.wpstream-trigger-modal').on('click',function(event){
662
663        if( jQuery(this).hasClass('wpstream_inactive_icon') ) {
664            return;
665        };
666
667        jQuery('.wpstream_modal_background').show();
668        var modal_class=jQuery(this).attr('data-modal');
669		wpstream_safe_track_onboarding( 'open_modal', 'wpstream_' + post_type, 'button', modal_class );
670        var parent =jQuery(this).closest('.event_list_unit');
671        jQuery('.wpstream_modal_background').show();
672        parent.find("."+modal_class).css('display','flex').css('flex-direction','column');
673    })
674
675    jQuery('.wpstream_external_broadcast_options').change(function(event){
676        var new_option = jQuery(this).val();
677        var parent = jQuery(this).parent();
678
679        parent.find('.external_software_streaming').hide();
680        parent.find('.'+new_option).show();
681    });
682
683
684}
685
686
687
688/*
689*
690* Tooltips for buttons
691*  
692*
693*/ 
694
695function wpstream_tooltip(){
696
697    jQuery( ".wpstream_tooltip_wrapper" ).hover(
698    function() {
699
700        if(jQuery( this ).hasClass('wpstream_inactive_icon')){
701            jQuery( this ).find('.wpstream_tooltip_disabled').css('opacity',1);
702        }else{
703            jQuery( this ).find('.wpstream_tooltip').css('opacity',1);
704        }
705
706
707    }, function() {
708        jQuery( this ).find('.wpstream_tooltip').css('opacity',0);
709        jQuery( this ).find('.wpstream_tooltip_disabled').css('opacity',0);
710    }
711);
712}
713
714/*
715*
716* Modal errors
717*  
718*
719*/ 
720
721
722function wpestate_start_modal_error_actions(){
723    jQuery('.wpstream_error_ok').on('click',function(event){
724        jQuery(this).parent().hide();
725        jQuery('.wpstream_modal_background').hide();
726        jQuery(this).parent().find('.wpstream_error_content').text('');
727    });
728}
729
730
731
732
733/*
734*
735* Copy to Clipboard
736*  
737*
738*/ 
739
740function wpstream_copy_to_clipboard(){
741       
742    jQuery('.copy_live_uri').on('click',function(){
743        var value_uri = jQuery(this).parent().find('.wpstream_live_uri_text').text();
744        var temp = jQuery("<input>");
745        jQuery("body").append(temp);
746        jQuery(temp).val(value_uri).select();
747        document.execCommand("copy");
748        jQuery(temp).remove();
749
750	    // Show "Copied" tooltip
751	    var tooltip = jQuery('<div class="wpstream_copy_tooltip">Copied</div>');
752	    tooltip.css({
753		    position: 'absolute',
754		    background: '#333',
755		    color: '#fff',
756		    padding: '5px 10px',
757		    borderRadius: '3px',
758		    fontSize: '12px',
759		    zIndex: 9999,
760		    pointerEvents: 'none'
761	    });
762
763	    var offset = jQuery(this).offset();
764	    tooltip.css({
765		    top: offset.to
765p - 35,
766		    left: offset.left + (jQuery(this).outerWidth() / 2) - (tooltip.outerWidth() / 2)
767	    });
768
769	    jQuery('body').append(tooltip);
770	    tooltip.fadeIn(200);
771
772	    setTimeout(function() {
773		    tooltip.fadeOut(200, function() {
774			    tooltip.remove();
775		    });
776	    }, 1500);
777    });
778    
779    jQuery('.copy_live_key').on('click',function(){
780        var value_uri = jQuery(this).parent().find('.wpstream_live_key_text').text();
781        var temp = jQuery("<input>");
782        jQuery("body").append(temp);
783        jQuery(temp).val(value_uri).select();
784        document.execCommand("copy");
785        jQuery(temp).remove();
786    });
787}
788
789/*
790*
791* Webcaster button action
792*  
793*
794*/ 
795
796function wpstream_webcaster_actions(){
797    jQuery('.start_webcaster').on('click',function(event){
798        if(jQuery(this).hasClass('wpstream_inactive_icon')){
799            return;
800        }
801		wpstream_safe_track_onboarding( 'open_webcaster', 'wpstream_' + post_type );
802        var $this = jQuery(this);
803        var ajaxurl = wpstream_start_streaming_vars.admin_url + 'admin-ajax.php';
804        var channelId      = jQuery(this).closest('.event_list_unit').data('show-id');
805        var whipUrl = '';
806		var pendingPopup = window.open('', '_blank', 'location=yes,scrollbars=yes,status=yes');
807		var nonce = jQuery('#wpstream_start_event_nonce').val();
808
809        jQuery.ajax({
810            type: 'POST',
811            dataType: 'json',
812            url: ajaxurl,
813            timeout: 3000000,
814            data: {
815                'action': 'wpstream_check_whipurl',
816                'channel_id': channelId,
817	            'nonce': nonce,
818            },
819            success: function (data) {
820                if( data.success == true ){
821                    whipUrl = data.whip_url;
822
823	                if ( whipUrl !== '' ) {
824		                // Open the new broadcaster in a new window
825		                var broadcasterUrl = wpstream_start_streaming_vars.broadcaster_url + channelId;
826						if ( wpstream_start_streaming_vars.is_onboarding == 'yes' ) {
827							broadcasterUrl += '/?onboarding=1';
828                            if (pendingPopup) {
829                                var popupSessionId = (new URLSearchParams(window.location.search)).get('session_id') || '';
830                                var popupPayload = {
831                                    wpstream_onboarding_popup_payload: {
832                                        session_id: popupSessionId,
833                                    }
834                                };
835
836                                try {
837                                    pendingPopup.name = JSON.stringify(popupPayload);
838                                } catch (e) {
839                                    pendingPopup.name = '';
840                                }
841                            }
842						}
843		                // window.open(broadcasterUrl, 'wpstream_broadcaster_' + channelId, 'fullscreen=yes');
844		                if (pendingPopup) {
845			                pendingPopup.location.href = broadcasterUrl;
846		                } else {
847							if (pendingPopup) {
848								pendingPopup.close();
849							}
850		                }
851	                }
852                } else {
853	                var caster_url = $this.attr('data-webcaster-url');
854	                $this.parent().find('.external_software_streaming').slideUp()
855	                window.open(caster_url, '_blank', 'location=yes,scrollbars=yes,status=yes');
856                }
857            },
858            error: function() {
859                // fallback to the old broadcaster if the AJAX request fails
860                var caster_url = $this.attr('data-webcaster-url');
861                $this.parent().find('.external_software_streaming').slideUp()
862                window.open(caster_url, '_blank', 'location=yes,scrollbars=yes,status=yes');
863            }
864        });
865    })
866}
867
868
869
870/*
871*
872*  per event - low latency vs bitrate vs encrypt
873*
874*/
875
876
877function wpstream_adjust_settings(input_element){
878
879   
880   
881    var attr_value = input_element.attr('data-attr-ajaxname');
882    console.log(attr_value);
883
884 
885
886    if( attr_value === 'adaptive_bitrate' || attr_value==='low_latency'){
887        console.log('perform ');
888
889        var timer = setTimeout(function() {
890           
891            if( jQuery('.wpstream-setting-adaptive_bitrate .wpstream_event_option_item').is(':checked') || 
892                jQuery('.wpstream-setting-low_latency .wpstream_event_option_item').is(':checked') ){
893                jQuery('.wpstream-setting-encrypt .wpstream_event_option_item') .removeAttr('checked');           
894            }      
895        }, 300);
896
897    }
898
899    if( attr_value === 'encrypt'){
900        console.log('perform2 ');
901
902        var timer = setTimeout(function() {
903           
904            if( jQuery('.wpstream-setting-encrypt .wpstream_event_option_item').is(':checked') ){
905                   
906                jQuery('.wpstream-setting-low_latency .wpstream_event_option_item') .removeAttr('checked'); 
907                jQuery('.wpstream-setting-adaptive_bitrate .wpstream_event_option_item') .removeAttr('checked'); 
908           
909            }
910
911           
912        }, 300);
913
914    }
915
916}
917
918/*
919*
920* Save options actions
921*  
922*
923*/ 
924
925function wpstream_save_options_actions(){
926    jQuery('.wpestate_settings_modal .wpstream_event_option_item').on('click',function(){
927
928        wpstream_adjust_settings(jQuery(this));
929
930        var holder  =   jQuery(this).parents('.wpstream_event_streaming_local');
931        var show_id =   jQuery(this).parents('.event_list_unit').find('.start_event').attr('data-show-id');
932        var optionarray ={};
933        var nonce               =   jQuery('#wpstream_start_event_nonce').val();
934        var timer = setTimeout(function() {
935            holder.find('.wpstream_event_option_item').each(function(){
936                optionarray[jQuery(this).attr('data-attr-ajaxname')]=jQuery(this).prop("checked") ? 1 : 0 ;
937            });
938
939
940            var myJSON = JSON.stringify(optionarray);
941            jQuery.ajax({
942                type: 'POST',
943                url: ajaxurl,
944                timeout: 300000,
945                data: {
946                    'action'            :   'wpstream_update_local_event_settings',
947                    'show_id'           :   show_id,
948                    'option'            :   optionarray,
949                    'security'          :   nonce
950                                
951                },
952                success: function (data) {
953                },
954                error: function (jqXHR,textStatus,errorThrown) {
955                }
956                
957            });
958        }, 300);
959        
960    });
961    
962}
963
964function wpstream_save_use_global_event_options() {
965	jQuery('.wpestate_settings_modal #local_event_options_enabled').on('click',function(){
966		var nonce   = jQuery('#wpstream_start_event_nonce').val();
967		var show_id = jQuery(this).parents('.event_list_unit').find('.start_event').attr('data-show-id');
968
969		var use_global_settings = jQuery(this).prop("checked") ? 1 : 0 ;
970		jQuery.ajax({
971			type: 'POST',
972			url: ajaxurl,
973			timeout: 300000,
974			data: {
975				'action'     : 'wpstream_update_use_global_event_options',
976				'show_id'    : show_id,
977				'use_global' : jQuery(this).prop("checked") ? 0 : 1 ,
978				'security'   : nonce
979			},
980			success: function (data) {
981				jQuery('.wpestate_settings_modal .wpstream_event_option_item').each(function(){
982					jQuery(this).prop("disabled", !jQuery('#local_event_options_enabled').prop("checked"));
983				});
984			},
985			error: function (jqXHR,textStatus,errorThrown) {
986				console.log('error');
987			}
988		});
989	});
990}
991
992/*
993*
994* Function to check live connections
995*  
996*
997*/ 
998 
999function wpstream_check_live_connections(){
1000    // was .pending_streaming.pending_trigger
1001    if( jQuery('.event_list_unit.pending_trigger').length>0 ){
1002        jQuery('.event_list_unit.pending_trigger').each(function(){
1003            var acesta      =   jQuery(this);
1004            var show_id     =   jQuery(this).attr('data-show-id');
1005            var server_id   =   jQuery(this).attr('data-server-id');
1006
1007            wpstream_check_live_connections_from_database(acesta,show_id,server_id);
1008            var counter_long     =   '';
1009            counter_long =  setInterval( function (){
1010				wpstream_check_live_connections_from_database(acesta,show_id,server_id)
1011            },60000);
1012            counters[show_id]=counter_long;
1013
1014        });
1015    }
1016 
1017}
1018
1019
1020
1021  
1022/*
1023*
1024* check live connection
1025*
1026*
1027*/
1028
1029    
1030function wpstream_check_live_connections_from_database( acesta,channel_id,server_id){
1031    var server_status = wpstream_check_event_status_in_js(channel_id,'wpstream_check_live_connections_from_database',
1032        function(server_status){
1033
1034            if(server_status.status==='active' ){
1035                
1036                acesta.find('.wpstream_ready_to_stream .start_webcaster').attr('data-webcaster-url',server_status.webcaster_url);
1037                acesta.find('.wpstream_live_uri_text').text(server_status.obs_uri);
1038                acesta.find('.wpstream_live_key_text').text(server_status.obs_stream);
1039            
1040                wpstream_event_ready_make_actions_visible( acesta );
1041
1042                var larix_rtmp= server_status.obs_uri+server_status.obs_stream;
1043                acesta.find('.wpstream_larix_rtmp').text(larix_rtmp);
1044
1045                acesta.find('.larrix_test').text(larix_rtmp);
1046
1047                var   larix_qr ='larix://set/v1?conn[][url]='+encodeURIComponent(larix_rtmp);
1048                acesta.find('.wpstream_start_with_larix_mobile').attr('href',larix_qr); 
1049                
1050             
1051                var print_qrcode= "https://qrcode.tec-it.com/API/QRCode?size=small&dpi=110&data="+encodeURIComponent(larix_qr);
1052
1053                acesta.find('.print_qrcode').attr('src',print_qrcode); 
1054                acesta.find('.wpstream_live_data').attr('href',server_status.live_data_url);
1055                clearInterval( counters["stop"+channel_id]);
1056         
1057            }else if(server_status.status==='stopped' ){
1058	            clearInterval( counters["stop"+channel_id]);
1059	            wpstream_event_stopped_after_status_check(acesta);
1060            }else if(server_status.status==='error' ){
1061                
1062                clearInterval( counters["stop"+channel_id]);
1063                var curent_content = acesta.find('.wpstream_channel_status ');
1064                
1065                curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'+wpstream_start_streaming_vars.failed_event_creation+'</div>');
1066            }
1067        },
1068        function(){
1069            wpstream_event_error_make_actions_visible(acesta);
1070        }
1071        );
1072
1073}
1074
1075
1076
1077/*
1078*
1079* Check event/channel status
1080*
1081*
1082*/
1083
1084    
1085function wpstream_check_server_status(url_param,callback) {
1086
1087    var url = url_param ;
1088    var status='';
1089    jQuery.ajax({
1090        url: url,
1091        type: "get",
1092        cache: false,
1093        dataType: 'jsonp', // it is for supporting crossdomain
1094        crossDomain : true,
1095        asynchronous : false,
1096        timeout : 1500, // set a timeout in milliseconds
1097        callback:'',
1098        complete : function(xhr) {
1099    
1100            if(xhr.status == "200" || xhr.status == "400") {
1101                callback(true);
1102            }
1103            else {
1104                callback(false);
1105            }
1106        }
1107    });
1108}
1109
1110function wpstream_convert_mb_to_gb(megabits) {
1111	let gigabit = megabits / 1000;
1112	gigabit = parseFloat( gigabit.toFixed( 1 ) );
1113
1114	if ( gigabit < 0 ) {
1115		return 0
1116	}
1117
1118	return gigabit;
1119}

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.