PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8
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 / admin / js / wpstream-onboarding2.js

wpstream-onboarding2.js in WpStream – Live Streaming, Video on Demand, Pay Per View 4.8, at admin/js/wpstream-onboarding2.js

1,184 lines 46.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const ONBOARD=(function(){
2
3 document.addEventListener('DOMContentLoaded',init);
4 const BubbleFreeVod = [
5 //free live stream
6 [
7 {id: 1,
8 selector: "#menu-posts-wpstream_product",
9 title: "Hooray! You just created your first Free-To-View Channel.",
10 content:"You can check out all your FTV Channels or create new ones from this menu.<div class='onboard_line_break'></div>Just look for ‘Free-To-View Live Channels’.",
11 left:"175px",
12 right:"-30px",
13 top:"-30px",
14 arrow:"boarding-left-arrow"},
15 {id: 2,
16 selector: "#wpstream-sidebar-meta",
17 title: "Control your Live Channel",
18 content:"Look for the 'Live Streaming' box to the right of the page.",
19 left:"-430px",
20 right:"60px",
21 top:"0px",
22 arrow:"boarding-right-arrow"},
23 {id: 3,
24 selector: ".wpstream_show_settings_wrapper",
25 title: "Channel Settings",
26 content:'Clicking on the <div class="wpstream_sample_icon_settings"></div> icon will let you access the channel settings.<div class="onboard_line_break"></div> You can adjust preferences for <strong>recording, autoplay</strong>, etc.',
27 left:"-444px",
28 right:"0px",
29 top:"100px",
30 arrow:"boarding-right-arrow"},
31 {id: 4,
32 selector: ".wpstream_stream_browser_wrapper",
33 title: "Turn it ON",
34 content:"To Go Live, first TURN ON your channel. Go ahead, click the big green button below! <div id=\"wpstream_onboarding_start_chanel\">TURN ON</div> Turning on may take a minute or so. You can wait or move on to the next step.",
35 left:"-444px",
36 right:"auto",
37 top:"0px",
38 arrow:"boarding-right-arrow"},
39
40 {id: 5,
41 selector: ".wpstream_show_settings_wrapper",
42 title: "Your Channel Page",
43 content:"This is the link to the page with your live stream. Viewers will be able to watch your live stream here.<div class='onboard_line_break'></div>To see it, click <div id=\"wpstream_onboarding_open_chanel\" class=\"wpstream_sample_icon_settings wpstream_sample_icon_open_channel\"></div> Page will open in a new tab.",
44 left:"-400px",
45 right:"auto",
46 top:"100px",
47 arrow:"boarding-right-arrow"},
48 {id: 6,
49 selector: ".wpstream_stream_browser_wrapper",
50 title: "Go LIVE",
51 content:"To go live, first turn on your channnel.<div class='onboard_line_break'></div> If it's already <strong>Turning ON</strong>, wait until <strong>Channel is ON</strong>",
52 left:"-444px",
53 right:"auto",
54 top:"58px",
55 arrow:"boarding-right-arrow"}
56 ] ,
57 // paid live stream
58 [
59 {id: 1,
60 selector: "#menu-posts-product",
61 title: "Hooray! You just created your first Pay-Per-View Channel.",
62 content:"You can check out all your PPV Channels or create new ones from this menu. Just look for ‘Products’.",
63 left:"175px",
64 right:"-30px",
65 top:"-30px",
66 arrow:"boarding-left-arrow"},
67 {id: 2,
68 selector: "#normal-sortables",
69 title: "A Pay-Per-View Channel is a Custom Woocommerce Product",
70 content:"Note the type of the product: <strong>Live Channel</strong> </br>This sets it apart from other products you may want to sell.",
71 left:"345px",
72 right:"-30px",
73 top:"-35px",
74 arrow:"boarding-left-arrow"},
75 {id: 3,
76 selector: "#normal-sortables",
77 title: "Set the Pay-Per-View price here",
78 content:"Your users will have to purchase the product in order to be allowed to watch the live stream.",
79 left:"550px",
80 right:"-30px",
81 top:"25px",
82 arrow:"boarding-left-arrow"},
83 {id: 4,
84 selector: "#wpstream-sidebar-meta",
85 title: "Control your channel from here",
86 content:"Look for the 'Live Streaming' box on the side bar.",
87 left:"-430px",
88 right:"60px",
89 top:"0px",
90 arrow:"boarding-right-arrow"},
91 {id: 5,
92 selector: ".wpstream_show_settings_wrapper",
93 title: "Channel Settings",
94 content:'Clicking on the <div class="wpstream_sample_icon_settings"></div> icon will let you access the channel settings.<div class="onboard_line_break"></div> You can adjust preferences for <strong>recording, autoplay</strong>, etc.',
95 left:"-444px",
96 right:"0px",
97 top:"100px",
98 arrow:"boarding-right-arrow"},
99 {id: 6,
100 selector: ".wpstream_stream_browser_wrapper",
101 title: "Turn it ON",
102 content:"To Go Live, first TURN ON your channel. Go ahead, click the big green button below!<div id=\"wpstream_onboarding_start_chanel\">TURN ON</div> Turning on may take a minute or so. You can wait or move on to the next step.",
103 left:"-444px",
104 right:"auto",
105 top:"0px",
106 arrow:"boarding-right-arrow"},
107 {id: 7,
108 selector: ".wpstream_show_settings_wrapper",
109 title: "Your Channel Page",
110 content:"This is the link to the page with your live stream. Viewers will be able to watch your live stream here.<div class='onboard_line_break'></div>To see it, click <div id=\"wpstream_onboarding_open_chanel\" class=\"wpstream_sample_icon_settings wpstream_sample_icon_open_channel\"></div> Page will open in a new tab.",
111 left:"-385px",
112 right:"auto",
113 top:"105px",
114 arrow:"boarding-right-arrow"},
115 {id: 8,
116 selector: ".wpstream_stream_browser_wrapper",
117 title: "Go LIVE",
118 content:"To go live, first turn on your channnel.<div class='onboard_line_break'></div> If it's already <strong>Turning ON</strong>, wait until <strong>Channel is ON</strong>",
119 left:"-430px",
120 right:"auto",
121 top:"50px",
122 arrow:"boarding-right-arrow"}
123 ] ,
124 // free vod
125 [
126 {id: 1,
127 selector: "#menu-posts-wpstream_product_vod",
128 title: "Hooray! You just created your first FTV Video-On-Demand.",
129 content:"You can check out all your FTV VODs or create new ones from this menu. Just look for 'Free-To-View VODs'",
130 left:"175px",
131 right:"-30px",
132 top:"-30px",
133 arrow:"boarding-left-arrow"},
134 {id: 2,
135 selector: "#add_wpstream_product_metaboxes-sectionid",
136 title: "The FTV VOD can be a Recording, self hosted, or external video",
137 content:"Recordings are stored in the WpStream cloud. <div class='onboard_line_break'></div> Self hosted videos are videos in your WordPress Media Library.<div class='onboard_line_break'></div>External videos are videos hosted on YouTube or Vimeo.",
138 left:"245px",
139 right:"-30px",
140 top:"30px",
141 arrow:"boarding-left-arrow"},
142 {id: 3,
143 selector: "#add_wpstream_product_metaboxes-sectionid",
144 title: "Choose a specific recording to create the VOD from",
145 content:"You can create new recordings by recording a live channel or uploading video files directly.",
146 left:"245px",
147 right:"-30px",
148 top:"100px",
149 arrow:"boarding-left-arrow"},
150 {id: 4,
151 selector: "#post-body",
152 title: "The VOD Page",
153 content:"This is the page that your <strong>viewers</strong> see when they <strong>watch</strong> your VOD.<div class='onboard_line_break'></div> To see it yourself, click the permalink. Page will open in a new tab. <div id=\"wpstream_onboarding_view_vod\">View VOD Page</div>",
154 left:"350px",
155 right:"0px",
156 top:"-10px",
157 arrow:"boarding-left-arrow"},
158
159 /*{id: 5,
160 selector: "#post-body",
161 title: "And Thats it",
162 content:"That's it , you users will be free to view this Video on Demand",
163 left:"350px",
164 right:"0px",
165 top:"155px",
166 arrow:""},
167 */
168 ] ,
169 //paid vod
170 [
171 {id: 1,
172 selector: "#menu-posts-product",
173 title: "Hooray! You just created your first PPV Video-On-Demand.",
174 content:"You can check out all your PPV VODs or create new ones from this menu. Just look for ‘Products’",
175 left:"175px",
176 right:"-30px",
177 top:"-30px",
178 arrow:"boarding-left-arrow"},
179 {id: 2,
180 selector: "#normal-sortables",
181 title: "A Pay-Per-View VOD is a Custom Woocommerce Product",
182 content:"Note the type of the product: <strong>Video On Demand</strong>.<div class='onboard_line_break'></div>This sets it apart from other products you may want to sell.",
183 left:"345px",
184 right:"-30px",
185 top:"-35px",
186 arrow:"boarding-left-arrow"},
187 {id: 3,
188 selector: "#normal-sortables",
189 title: "Set the Pay-Per-View price here",
190 content:"Your users will have to purchase the product in order to be allowed to watch the VOD stream. ",
191 left:"550px",
192 right:"-30px",
193 top:"25px",
194 arrow:"boarding-left-arrow"},
195 {id: 4,
196 selector: "#normal-sortables",
197 title: "Choose a specific recording to create the VOD from ",
198 content:"You can create new recordings by recording a live channel or uploading video files directly." ,
199 left:"700px",
200 right:"-30px",
201 top:"135px",
202 arrow:"boarding-left-arrow"},
203 {id: 5,
204 selector: "#post-body",
205 title: "The VOD Page",
206 content:"This is the page that your <strong>viewers</strong> see when they <strong>watch</strong> your VOD.<div class='onboard_line_break'></div>To see it yourself, click the permalink. Page will open in a new tab.<div class='onboard_line_break'></div><div id=\"wpstream_onboarding_view_vod\">View VOD Page</div>.",
207 left:"350px",
208 right:"0px",
209 top:"-10px",
210 arrow:"boarding-left-arrow"},
211 {id: 4,
212 selector: "#post-body",
213 title: "Your PPV VOD is now for sale.",
214 content:"Upon successful purchase, your viewers will be able to watch it as many times as they like.",
215 left:"350px",
216 right:"-200px",
217 top:"25px",
218 arrow:""},
219
220
221
222 ]
223
224 ];
225
226 function init(){
227 wpstream_by_pass_login();
228 wpstream_onboard_login();
229 wpstream_get_videos_list();
230 wpstream_onboard_register();
231 wpstream_main_on_boarding_function();
232 wpstream_on_boarding_click_actions();
233 wpstream_create_free_channel_action();
234 wpstream_create_ppv_channel_action();
235 wpstream_create_free_vod_action();
236 wpstream_create_ppv_vod_action();
237 wpstream_local_modal_onboarding();
238 wpstream_on_boarding_initial_close();
239 wpstream_onboard_initial_bubble_prev_action();
240
241 }
242
243 /*
244 * Start browser broadcaster
245 *
246 **/
247 function wpstream_start_camera(){
248
249 if( jQuery('.event_list_unit .wpstream_button').hasClass('wpstream_stop_event') ){
250 jQuery('.wpstream_sample_icon_camera').css('cursor','pointer');
251
252 jQuery('.wpstream_sample_icon_camera').on('click',function(){
253 jQuery('.start_webcaster').trigger('click');
254 jQuery(this).unbind('click');
255
256 })
257 }
258 }
259
260
261 /*
262 * ByPass Login if already in
263 *
264 **/
265 function wpstream_by_pass_login(){
266 if(jQuery('#wpstream_have_token').length >0 ){
267
268 var nextThing = 'wpstream_step_2';
269 jQuery('.wpstream_step_wrapper').hide();
270 jQuery('#'+nextThing).show();
271
272
273 }else{
274 jQuery('.wpstream_on_board_register_wrapper').show();
275 jQuery('#wpstream_onboarding_action_login').show();
276 }
277 jQuery('.wpstream_check_account_status').hide();
278 }
279
280
281
282 /*
283 * On Board Login
284 *
285 */
286
287 function wpstream_onboard_login() {
288 jQuery('.wpstream_onboard_login').on('click',function(){
289 wpstream_onboard_actual_login();
290 });
291
292
293 jQuery('.wpstream_on_board_login_wrapper #api_username,.wpstream_on_board_login_wrapper #api_password').keydown(function (e) {
294 if (e.keyCode === 13) {
295 e.preventDefault();
296 wpstream_onboard_actual_login();
297 }
298 });
299 }
300
301 function wpstream_onboard_actual_login(){
302 var api_username = jQuery('#api_username').val();
303 var api_password = jQuery('#api_password').val();
304 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
305 var nonce = jQuery('#wpstream_onboarding_nonce').val();
306
307
308 jQuery('.wpstream_onboarding_notification').removeClass('onboarding_error').text('Sending data. Please Stand by...').show();
309
310 jQuery.ajax({
311 type: 'POST',
312 url: ajaxurl,
313 dataType: 'json',
314 data: {
315 'action' : 'wpstream_on_board_login',
316 'api_username' : api_username,
317 'api_password' : api_password,
318 'security' : nonce
319 },
320 success: function (data) {
321 if(!data.success){
322 jQuery('.wpstream_onboarding_notification').addClass('onboarding_error').text(data.error).show();
323 }else{
324 jQuery('.wpstream_onboarding_notification').text('Login successful, please stand by...').show();
325 setTimeout(function() {
326
327 var nextThing = 'wpstream_step_2';
328 jQuery('.wpstream_onboarding_notification').empty().hide();
329 jQuery('.wpstream_step_wrapper').hide();
330 jQuery('#'+nextThing).show();
331
332 }, 2500);
333 }
334
335
336 },
337 error: function (errorThrown) {
338
339 }
340 });
341 }
342
343 function wpstream_get_videos_list() {
344 var nonce = jQuery('#wpstream_onboarding_video_list_nonce').val();
345 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
346
347 jQuery('.wpstream_action_next_step.wpstream_step_4a, .wpstream_action_next_step.wpstream_step_4b').on('click', function() {
348 // check the current object
349 var data_control = jQuery(this).attr('data-control');
350 jQuery.ajax({
351 type: 'POST',
352 url: ajaxurl,
353 dataType: 'json',
354 data: {
355 'action': 'wpstream_get_videos_list',
356 'security': nonce
357 },
358 success: function(data) {
359 if(data.success) {
360 if ( data.videos === null ||
361 data.videos === undefined ||
362 data.videos === '' ||
363 Array.isArray(data.videos) && data.videos.length === 0
364 ) {
365 // No videos found
366 wpstream_no_videos_notice(data_control === 'wpstream_onboard_vod_free' ? '' : '_for_ppv');
367 } else {
368 if ( data_control === 'wpstream_onboard_vod_free' ) {
369 wpstream_create_videos_list_content(data.videos, '');
370 jQuery('#wpstream_onboard_vod_free > .spinner').css('display', 'none');
371 jQuery('#wpstream_onboard_vod_free > .wpstream-step-container').css('display', 'block');
372 } else {
373 wpstream_create_videos_list_content(data.videos, '_for_ppv');
374 jQuery('#wpstream_onboard_vod_ppv > .spinner').css('display', 'none');
375 jQuery('#wpstream_onboard_vod_ppv > .wpstream-step-container').css('display', 'block');
376 }
377 }
378 }
379 },
380 error: function(data) {
381 jQuery('.wpstream_onboarding_notification').addClass('onboarding_error').text('Couldn\'t retrieve data.').show();
382 }
383 })
384 })
385 }
386
387 function wpstream_create_videos_list_content( data, data_control ) {
388 // if data_control is empty, it means it's for free vod
389 var container = data_control === '' ? jQuery('#wpstream_free_vod_dropdown_videos_list') : jQuery('#wpstream_ppv_vod_dropdown_videos_list');
390 container.empty();
391 var label = jQuery('<label value="">' + wpstream_admin_control_vars.choose_recording + '</label>');
392 container.append(label);
393 var select = jQuery('<select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name' + data_control + '">');
394 var option = jQuery('<option value="">' + wpstream_admin_control_vars.select_recording + '</option>');
395 select.append(option);
396 for (let key in data) {
397 let option = jQuery('<option value="' + key + '">' + data[key] + '</option>');
398 select.append(option);
399 }
400 select.append('</select>');
401 container.append(select);
402 }
403
404 function wpstream_no_videos_notice(data_control) {
405 jQuery('#wpstream_onboard_vod_free, #wpstream_onboard_vod_ppv').css('display', 'none');
406 jQuery('.wpstream_warning_onboarding').css('display', 'block');
407 }
408
409
410
411 /*
412 * On Board Register
413 *
414 */
415 function wpstream_onboard_register(){
416
417 jQuery('.wpstream_onboard_register').on('click',function(){
418 wpstream_on_board_actual_register();
419 });
420
421
422 jQuery('#wpstream_register_email, #wpstream_register_password,#wpstream_register_captcha').keydown(function (e) {
423 if (e.keyCode === 13) {
424 e.preventDefault();
425 wpstream_on_board_actual_register();
426 }
427 });
428
429 }
430
431
432 function wpstream_on_board_actual_register(){
433 var button=jQuery(this);
434 button.css('pointer-events','none');
435
436 var wpstream_register_email = jQuery('#wpstream_register_email').val();
437 var wpstream_register_password = jQuery('#wpstream_register_password').val();
438 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
439 var nonce = jQuery('#wpstream_onboarding_nonce').val();
440 var wpstream_register_captcha = jQuery('#wpstream_register_captcha').val();
441 var wpstream_register_captcha_id = jQuery('#wpstream_register_captcha_id').val();
442
443
444
445 if(wpstream_register_email ==='' || wpstream_register_password==='' || wpstream_register_captcha===''){
446 jQuery('.wpstream_onboarding_notification').addClass('onboarding_error').text('Please fill all the fields!').show();
447 button.css('pointer-events','auto');
448 return;
449 }
450
451
452 jQuery('.wpstream_onboarding_notification').removeClass('onboarding_error').text('Sending data. Please Stand by...').show();
453
454
455 jQuery.ajax({
456 type: 'POST',
457 url: ajaxurl,
458 dataType: 'json',
459 data: {
460 'action' : 'wpstream_on_board_register',
461 'wpstream_register_email' : wpstream_register_email,
462 'wpstream_register_password': wpstream_register_password,
463 'wpstream_register_captcha' : wpstream_register_captcha,
464 'wpstream_register_captcha_id': wpstream_register_captcha_id,
465 'security' : nonce
466 },
467 success: function (data) {
468
469 if(data.success){
470 if(data.token==='false' || data.token===false){
471 jQuery('.wpstream_onboarding_notification').addClass('onboarding_error').text('We couldn\'t authenticate with your new credentials').show();
472 }else{
473 jQuery('.wpstream_onboarding_notification').text('Registration successful, please stand by...').show();
474 setTimeout(function() {
475
476 var nextThing = 'wpstream_step_2';
477 jQuery('.wpstream_step_wrapper').hide();
478 jQuery('.wpstream_onboarding_notification').empty().hide();
479 jQuery('#'+nextThing).show();
480
481 }, 2500);
482 }
483 }else{
484 jQuery('.wpstream_onboarding_notification').addClass('onboarding_error').text(data.message).show();
485 wpstream_fetchCaptcha();
486
487 }
488 button.css('pointer-events','auto');
489
490 },
491 error: function (errorThrown) {
492 button.css('pointer-events','auto');
493 }
494 });
495
496 }
497
498
499
500 /*
501 * Check and Start the on Board
502 *
503 */
504
505
506 async function wpstream_fetchCaptcha () {
507
508 var result;
509 var requestOptions = {
510 method: 'POST',
511 redirect: 'follow'
512 };
513
514 fetch("https://baker.wpstream.net/user/getcapthca", requestOptions)
515 .then(response => response.json())
516 .then(result => wpstream_process_capthca(result))
517 .catch(error => console.log('error', error));
518
519 }
520
521
522 function wpstream_process_capthca(response){
523
524
525 jQuery('#wpstream_capthca').empty().append(response.capthca);
526 jQuery('#wpstream_register_captcha_id').val(response.capthca_id);
527 jQuery('#wpstream_register_captcha').empty();
528
529 }
530
531
532
533
534 /*
535 * Check and Start the on Board
536 *
537 */
538
539
540 function wpstream_main_on_boarding_function(){
541
542 jQuery('#wpstream_trigger_quick_start').on('click',function(){
543
544 jQuery(".wpstream_on_boarding_wrapper").show();
545 jQuery(".wpstream_modal_background_onboard").show();
546
547 jQuery('.wpstream_on_board_login_wrapper,#wpstream_onboarding_action_register,.wpstream_onboarding_notification').hide();
548 jQuery('#wpstream_step_1,.wpstream_close_initial_onboarding,.wpstream_on_board_register_wrapper').show();
549 wpstream_by_pass_login();
550 });
551
552
553 let params = (new URL(document.location)).searchParams;
554 let onboard = params.get('onboard_start');
555
556 if(onboard!=='yes'){
557 return;
558 }
559
560 jQuery('.wpstream_on_boarding_wrapper').show();
561 jQuery('.wpstream_modal_background_onboard').show();
562
563
564
565 }
566
567 /*
568 * WpStream on Boarding CLick actions
569 *
570 */
571
572
573 function wpstream_on_boarding_click_actions(){
574 jQuery('#wpstream_onboarding_action_login').on('click',function(){
575 jQuery(this).hide();
576 jQuery('.wpstream_onboarding_notification').hide();
577 jQuery('.wpstream_on_board_register_wrapper').hide();
578 jQuery('.wpstream_on_board_login_wrapper').show();
579 jQuery('#wpstream_onboarding_action_register').show();
580 });
581
582 jQuery('#wpstream_onboarding_action_register').on('click',function(){
583 jQuery(this).hide();
584 jQuery('.wpstream_onboarding_notification').hide();
585 jQuery('.wpstream_on_board_login_wrapper').hide();
586 jQuery('.wpstream_on_board_register_wrapper').show();
587 jQuery('#wpstream_onboarding_action_login').show();
588 });
589
590
591 jQuery('.wpstream_action_next_step').on('click',function(){
592 var nextThing = jQuery(this).attr('data-nextthing');
593 jQuery('.wpstream_step_wrapper').hide();
594 jQuery('#'+nextThing).show();
595 });
596 }
597
598
599 /*
600 * Create free Channel action
601 *
602 */
603
604 function wpstream_create_free_channel_action(){
605 jQuery('#wpstream_on_board_create_channel').on('click',function(){
606 wpstream_actual_create_free_channel_action();
607 });
608
609 jQuery('#wpstream_onboarding_channel_name').keydown(function (e) {
610 if (e.keyCode === 13) {
611 e.preventDefault();
612 wpstream_actual_create_free_channel_action();
613 }
614 });
615
616
617 }
618
619 function wpstream_actual_create_free_channel_action(){
620 jQuery('#wpstream_onboard_live_notice').removeClass('onboarding_error').text('Creating your FTV live channel. Please Stand by...').show();
621 jQuery('#wpstream_on_board_create_channel').prop('disabled', true);
622 var channel_name = jQuery('#wpstream_onboarding_channel_name').val();
623 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
624 var nonce = jQuery('#wpstream_onboarding_nonce').val();
625
626 jQuery.ajax({
627 type: 'POST',
628 url: ajaxurl,
629 dataType: 'json',
630 data: {
631 'action' : 'wpstream_on_board_create_channel',
632 'channel_name' : channel_name,
633 'security' : nonce
634 },
635 success: function (data) {
636
637 if( data.success ) {
638 var new_link = data.link;
639 var decoded = new_link.replace(/&amp;/g, '&');
640 window.location.href=decodeURI(decoded);
641 } else {
642 jQuery('#wpstream_onboard_live_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
643 jQuery('#wpstream_on_board_create_channel').prop('disabled', false);
644 }
645 },
646 error: function ( errorThrown ) {
647 jQuery('#wpstream_onboard_live_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
648 jQuery('#wpstream_on_board_create_channel').prop('disabled', false);
649 }
650 });
651 }
652
653 /*
654 * Create PPV Channel action
655 *
656 */
657
658 function wpstream_create_ppv_channel_action(){
659 jQuery('#wpstream_onboard_live_ppv_action').on('click',function(){
660 wpstream_actual_create_ppv_channel_action();
661 });
662
663
664 jQuery('#wpstream_onboarding_channel_name_ppv,#wpstream_onboarding_event_price_ppv').keydown(function (e) {
665 if (e.keyCode === 13) {
666 e.preventDefault();
667 wpstream_actual_create_ppv_channel_action();
668 }
669 });
670
671 }
672
673
674 function wpstream_actual_create_ppv_channel_action(){
675 jQuery('#wpstream_onboard_live_ppv_notice').removeClass('onboarding_error').text('Creating your Pay Per View live channel. Please Stand by...').show();
676 jQuery('#wpstream_onboard_live_ppv_action').prop('disabled', true);
677 var channel_name = jQuery('#wpstream_onboarding_channel_name_ppv').val();
678 var channel_price = jQuery('#wpstream_onboarding_event_price_ppv').val();
679 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
680 var nonce = jQuery('#wpstream_onboarding_nonce').val();
681
682
683 jQuery.ajax({
684 type: 'POST',
685 url: ajaxurl,
686 dataType: 'json',
687 data: {
688 'action' : 'wpstream_on_board_create_channel_ppv',
689 'channel_name' : channel_name,
690 'channel_price' : channel_price,
691 'security' : nonce
692 },
693 success: function (data) {
694
695 if( data.success ) {
696 var new_link = data.link;
697 var decoded = new_link.replace(/&amp;/g, '&');
698 window.location.href=decodeURI(decoded);
699 } else {
700 jQuery('#wpstream_onboard_live_ppv_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
701 jQuery('#wpstream_onboard_live_ppv_action').prop('disabled', false);
702 }
703
704 },
705 error: function (errorThrown) {
706 jQuery('#wpstream_onboard_live_ppv_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
707 jQuery('#wpstream_onboard_live_ppv_action').prop('disabled', false);
708 }
709 });
710 }
711
712
713 /*
714 * Create Free VOD Action
715 *
716 */
717
718
719 function wpstream_create_free_vod_action(){
720 jQuery('#wpstream_onboard_vod_free_action').on('click',function(){
721 wpstream_actual_create_free_vod_action();
722 });
723
724 jQuery('#wpstream_onboarding_vod_name, #wpstream_free_vod_file_name').keydown(function (e) {
725 if (e.keyCode === 13) {
726 e.preventDefault();
727 wpstream_actual_create_free_vod_action();
728 }
729 });
730 }
731
732
733 function wpstream_actual_create_free_vod_action(){
734 jQuery('#wpstream_onboard_vod_free_notice').removeClass('onboarding_error').text('Creating your VOD. Please Stand by...').show();
735 jQuery('#wpstream_onboard_vod_free_action').prop('disabled', true);
736 var channel_name = jQuery('#wpstream_onboarding_vod_name').val();
737 var file_name = jQuery('#wpstream_free_vod_file_name').val();
738 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
739 var nonce = jQuery('#wpstream_onboarding_nonce').val();
740
741
742 if(file_name===''){
743 jQuery('#wpstream_onboard_vod_free_notice').empty().addClass('onboarding_error').show().text('Please select a recording from the list')
744 jQuery('#wpstream_onboard_vod_free_action').prop('disabled', false);
745 return;
746 }
747
748 jQuery.ajax({
749 type: 'POST',
750 url: ajaxurl,
751 dataType: 'json',
752 data: {
753 'action' : 'wpstream_on_board_create_free_vod',
754 'channel_name' : channel_name,
755 'file_name' : file_name,
756 'security' : nonce
757 },
758 success: function (data) {
759 if( data.success ) {
760 var new_link = data.link;
761 var decoded = new_link.replace(/&amp;/g, '&');
762 window.location.href=decodeURI(decoded);
763 } else {
764 jQuery('#wpstream_onboard_vod_free_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
765 jQuery('#wpstream_onboard_vod_free_action').prop('disabled', false);
766 }
767 },
768 error: function (errorThrown) {
769 jQuery('#wpstream_onboard_vod_free_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
770 jQuery('#wpstream_onboard_vod_free_action').prop('disabled', false);
771 }
772 });
773 }
774
775
776 /*
777 * Create PPV VOD Action
778 *
779 */
780
781
782 function wpstream_create_ppv_vod_action(){
783 jQuery('#wpstream_onboard_vod_ppv_action').on('click',function(){
784 wpstream_actual_create_ppv_vod_action();
785 });
786
787 jQuery('#wpstream_onboarding_ppv_vod_name, #wpstream_free_vod_file_name_for_ppv,#wpstream_onboarding_vod_price').keydown(function (e) {
788 if (e.keyCode === 13) {
789 e.preventDefault();
790 wpstream_actual_create_ppv_vod_action();
791 }
792 });
793
794
795 }
796
797 function wpstream_actual_create_ppv_vod_action(){
798 jQuery('#wpstream_onboard_vod_ppv_notice').removeClass('onboarding_error').text('Creating your VOD. Please Stand by...').show();
799 jQuery('#wpstream_onboard_vod_ppv_action').prop('disabled', true);
800
801 var channel_name = jQuery('#wpstream_onboarding_ppv_vod_name').val();
802 var file_name = jQuery('#wpstream_free_vod_file_name_for_ppv').val();
803 var vod_price = jQuery('#wpstream_onboarding_vod_price').val()
804 var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php';
805 var nonce = jQuery('#wpstream_onboarding_nonce').val();
806
807
808 if( file_name === '' ) {
809 jQuery('#wpstream_onboard_vod_ppv_notice').empty().addClass('onboarding_error').show().text('Please select a recording from the list')
810 jQuery('#wpstream_onboard_vod_ppv_action').prop('disabled', false);
811 return;
812 }
813
814
815 jQuery.ajax({
816 type: 'POST',
817 url: ajaxurl,
818 dataType: 'json',
819 data: {
820 'action' : 'wpstream_on_board_create_ppv_vod',
821 'channel_name' : channel_name,
822 'file_name' : file_name,
823 'vod_price' : vod_price,
824 'security' : nonce
825 },
826 success: function (data) {
827 if( data.success ) {
828 var new_link = data.link;
829 var decoded = new_link.replace(/&amp;/g, '&');
830 window.location.href=decodeURI(decoded);
831 } else {
832 jQuery('#wpstream_onboard_vod_ppv_notice').empty().addClass('onboarding_error').show().text(wpstream_admin_control_vars.channel_create_error)
833 jQuery('#wpstream_onboard_vod_ppv_action').prop('disabled', false);
834 }
835 },
836 error: function (errorThrown) {
837 jQuery('#wpstream_onboard_vod_ppv_notice').empty().addClass('onboarding_error').show().text('Something did not work .Please try again.')
838 jQuery('#wpstream_onboard_vod_ppv_action').prop('disabled', false);
839 }
840 });
841 }
842
843 /*
844 * Start Modal on Particular Pages
845 *
846 */
847
848 function wpstream_local_modal_onboarding(){
849 let params = (new URL(document.location)).searchParams;
850 let onboard = params.get('onboard');
851
852 if(onboard!=='yes'){
853 return;
854 }
855
856 let branch= params.get('branch');
857 branch=parseInt(branch);
858
859 if(isNaN(branch)){
860 return;
861 }
862
863 branch=branch-1;
864
865
866 var help_bubble_to_insert='<div id="wpstream_onboard_bubble" data-bubble-step="0"><div class="wpstream_close_onboarding"></div>'+
867 '<h2 id="wpstream_onboard_bubble_tile"></h2>'+
868 '<p id="wpstream_onboard_bubble_content"></p>'+
869 '<span class="wpstream_onboard_bubble_prev">Prev</span>'+
870 '<span class="wpstream_onboard_bubble_next">Next</span>'+
871 '<span class="wpstream_onboard_bubble_finish">Finish</span>'+
872 // '<ul class="wpstream_round_bubble">';
873 // for (let step = 0; step < BubbleFreeVod[branch].length ; step++) {
874 // help_bubble_to_insert=help_bubble_to_insert+'<li></li>';
875 // }
876
877 //help_bubble_to_insert=help_bubble_to_insert+'</ul>'+
878 '</div><div class="wpstream_modal_background_onboard2"></div>';
879
880 jQuery('#wpcontent').append(help_bubble_to_insert);
881
882 wpstream_show_bubble(0,branch);
883 jQuery('.woocommerce-layout__header').hide();
884 jQuery('.wpstream_modal_background_onboard2,#wpstream_onboard_bubble').show();
885
886 wpstream_on_boarding_close();
887 wpstream_bubble_controls(branch);
888
889 }
890
891
892 /*
893 * Close initial on boarding
894 *
895 */
896
897 function wpstream_on_boarding_initial_close(){
898
899 jQuery('.wpstream_close_initial_onboarding').on('click',function(){
900 var parent_modal=jQuery(this).parent();
901 parent_modal.find('.wpstream_close_initial_onboarding,.wpstream_step_wrapper').hide();
902 parent_modal.find('.wpstream_close_onboarding_warning').show().html('You can run the wizard again at any time.</br> In the left menu navigate to WpStream -> WpStream Quick Start <div id="wpstrean_close_modal_ack" class="wpstrean_close_modal_ack_action">Okay, Close it now!</div>');
903 wpstrean_close_modal_ack_function();
904 });
905 }
906
907
908 /*
909 * Close ACK
910 *
911 */
912 function wpstrean_close_modal_ack_function(){
913 jQuery('.wpstrean_close_modal_ack_action').on('click',function(){
914
915 var parent_modal=jQuery(this).parent();
916 parent_modal.hide();
917 jQuery('.wpstream_modal_background_onboard2,.wpstream_modal_background_onboard').hide();
918 jQuery('.wpstream_on_boarding_wrapper').hide();
919 jQuery('#wpstream_onboard_bubble').hide();
920 });
921 }
922
923
924
925
926 /*
927 * Iniial next prev actions
928 *
929 */
930
931 function wpstream_onboard_initial_bubble_prev_action(){
932 jQuery('.wpstream_onboard_initial_bubble_prev').on('click',function(){
933 var prev_step = jQuery(this).attr('data-step');
934 jQuery('.wpstream_step_wrapper').hide();
935 jQuery("#"+prev_step).show();
936 });
937
938
939 jQuery('.wpstream_onboarding_tryagain').on('click',function(){
940 location.reload();
941 });
942
943 jQuery('.wpstream_install_plugin').on('click',function(){
944 var url = wpstreamonboarding_js_vars.plugin_url;
945 window.open(url, '_blank');
946 });
947
948 jQuery('.wpstream_upload_video').on('click',function(){
949 var url = wpstreamonboarding_js_vars.upload_url;
950 window.open(url, '_blank');
951 });
952
953 }
954
955
956
957 /*
958 * Show MOdal/Bubble for local pages
959 *
960 */
961
962 function wpstream_show_bubble(current_bubble_step,branch){
963
964 var current_bubble = jQuery('#wpstream_onboard_bubble');
965 current_bubble.detach();
966
967 var new_info = BubbleFreeVod[branch][current_bubble_step];
968 var new_title = new_info.title;
969 var new_selector = new_info.selector;
970 var new_content = new_info.content;
971 var new_css = new_info.css;
972 var new_left = new_info.left;
973 var new_top = new_info.top;
974 var new_right = new_info.right;
975 var new_arrow = new_info.arrow;
976
977 current_bubble.find('#wpstream_onboard_bubble_tile').html(new_title);
978 current_bubble.find('#wpstream_onboard_bubble_content').html(new_content);
979 current_bubble.attr('data-bubble-step',current_bubble_step);
980 current_bubble.removeClass('boarding-left-arrow boarding-right-arrow');
981 current_bubble.addClass(new_arrow);
982 current_bubble.css({
983 'left':new_left,
984 'right':new_right,
985 'top':new_top
986 });
987
988
989 if( BubbleFreeVod[branch].hasOwnProperty(parseInt(current_bubble_step+1)) ){
990 current_bubble.find('.wpstream_onboard_bubble_next').show();
991 current_bubble.find('.wpstream_onboard_bubble_finish').hide();
992 }else{
993 current_bubble.find('.wpstream_onboard_bubble_next').hide();
994 current_bubble.find('.wpstream_onboard_bubble_finish').show().css('display','inline-block');
995 }
996
997
998
999 jQuery(new_selector).append(current_bubble);
1000
1001 jQuery('html, body').animate({
1002 scrollTop: jQuery(new_selector).offset().top-200
1003 }, 1000);
1004
1005 wpstream_on_boarding_trigger_event_start_channel();
1006 wpstream_on_boarding_trigger_event_open_channel();
1007 wpstream_on_boarding_open_vod_page();
1008 wpstream_start_camera();
1009
1010 }
1011
1012
1013 /*
1014 * Trigger Start Event
1015 *
1016 */
1017
1018 function wpstream_on_boarding_trigger_event_start_channel(){
1019 if(jQuery('.start_event').hasClass('wpstream_turning_on')){
1020
1021 jQuery('#wpstream_onboarding_start_chanel').hide();
1022 var bubble_Step =jQuery('#wpstream_onboard_bubble').attr('data-bubble-step');
1023
1024
1025 var check_against='3';
1026 if(jQuery('#woocommerce-product-data').length>0){
1027 check_against='5';
1028 }
1029
1030
1031 if(bubble_Step===check_against ){
1032 jQuery('#wpstream_onboard_bubble_tile').text('Turning ON ');
1033 jQuery('#wpstream_onboard_bubble_content').text('Good, the channel is now turning on. This may take a minute or so. You can wait or move on to the next step.');
1034 }
1035
1036 }else if( jQuery('.event_list_unit .wpstream_button').hasClass('wpstream_stop_event') ){
1037 jQuery('#wpstream_onboarding_start_chanel').hide();
1038
1039 var bubble_Step =jQuery('#wpstream_onboard_bubble').attr('data-bubble-step');
1040 var check_against='3';
1041 check_against_camera_icon='5';
1042 if(jQuery('#woocommerce-product-data').length>0){
1043 check_against='5';
1044 check_against_camera_icon='7';
1045 }
1046
1047
1048 if(bubble_Step===check_against){
1049 jQuery('#wpstream_onboard_bubble_tile').text('Channel is now ON');
1050 jQuery('#wpstream_onboard_bubble_content').text('You are ready to GO LIVE. Click Next to see how.');
1051 }
1052
1053
1054 if(bubble_Step===check_against_camera_icon){
1055 jQuery('#wpstream_onboard_bubble_tile').html('Go LIVE');
1056 jQuery('#wpstream_onboard_bubble_content').html('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.');
1057 wpstream_start_camera();
1058 }
1059
1060
1061
1062
1063 }else {
1064 jQuery('#wpstream_onboarding_start_chanel').show();
1065
1066 jQuery('#wpstream_onboarding_start_chanel').on('click',function(){
1067 start_onboarding = 'yes';
1068 jQuery('.start_event.wpstream_button').trigger('click');
1069 jQuery('#wpstream_onboarding_start_chanel').unbind('click');
1070 jQuery('#wpstream_onboard_bubble_tile').text('Turning ON');
1071 jQuery('#wpstream_onboard_bubble_content').text('Good, the channel is now turning on. This may take a minute or so. You can wait or move on to the next step.');
1072 })
1073
1074 }
1075
1076 }
1077
1078
1079 /*
1080 * Trigger open page
1081 *
1082 */
1083
1084 function wpstream_on_boarding_trigger_event_open_channel(){
1085 jQuery('#wpstream_onboarding_open_chanel').on('click',function(){
1086 var link = jQuery('.wpstream_view_channel').attr('href');
1087 window.open(link, '_blank');
1088 })
1089 }
1090
1091
1092 /*
1093 * Trigger VOD Page
1094 *
1095 */
1096
1097 function wpstream_on_boarding_open_vod_page(){
1098 jQuery('#wpstream_onboarding_view_vod').on('click',function(event){
1099 event.stopPropagation();
1100 var link = jQuery('#sample-permalink a').attr('href');
1101 window.open(link, '_blank');
1102
1103 });
1104 }
1105
1106
1107
1108 /*
1109 * Close Modal
1110 *
1111 */
1112 function wpstream_on_boarding_close(){
1113 jQuery('.wpstream_close_onboarding,.wpstream_onboard_bubble_finish').on('click',function(){
1114 wpstream_onboarding_close_modal_logic(this);
1115 });
1116 jQuery('.wpstream_on_boarding_wrapper').keydown(function(e) {
1117 if ( e.keyCode === 27 ) { // ESC key
1118 wpstream_onboarding_close_modal_logic(this);
1119 }
1120 });
1121 }
1122
1123 function wpstream_onboarding_close_modal_logic(context) {
1124 jQuery('.wpstream_onboard_bubble_finish').hide();
1125 var parent_modal=jQuery(context).parent();
1126
1127 parent_modal.find('.wpstream_close_onboarding').hide();
1128 parent_modal.find('#wpstream_onboard_bubble_tile').html('You did it!');
1129 parent_modal.find('.wpstream_onboard_bubble_prev,.wpstream_onboard_bubble_next').hide();
1130
1131 parent_modal.find('#wpstream_onboard_bubble_content').html('You can run the wizard again at any time. </br>In the left menu navigate to WpStream -> WpStream Quick Start </br> <div id="wpstrean_close_modal_ack" class="wpstrean_close_modal_ack_action">Okay, Close it now!</div>');
1132 // parent_modal.find('#wpstream_onboard_bubble_content').after('<div id="wpstrean_close_modal_ack" class="wpstrean_close_modal_ack_action">Okay, Close it now!</div>');
1133
1134 wpstrean_close_modal_ack_function();
1135 }
1136
1137
1138 /*
1139 * Bubble/Modal Controls
1140 *
1141 */
1142
1143
1144 function wpstream_bubble_controls(branch){
1145
1146 jQuery('.wpstream_onboard_bubble_next,.wpstream_onboard_bubble_prev').on('click',function(){
1147
1148 var current_bubble_step = jQuery('#wpstream_onboard_bubble').attr('data-bubble-step');
1149
1150 current_bubble_step = parseInt(current_bubble_step,10);
1151 if( jQuery(this).hasClass('wpstream_onboard_bubble_next')){
1152 current_bubble_step++;
1153 }else{
1154 current_bubble_step--;
1155 }
1156
1157 if( current_bubble_step<0){
1158 current_bubble_step=0;
1159 var url = window.location.href;
1160 jQuery('#wpstream_onboard_bubble,.wpstream_modal_background_onboard2').hide();
1161
1162 jQuery('.wpstream_on_boarding_wrapper').show();
1163 jQuery('.wpstream_modal_background_onboard').show();
1164
1165 }
1166
1167 var max_length = BubbleFreeVod[branch].length-1;
1168
1169 if( current_bubble_step>max_length){
1170 current_bubble_step=max_length;
1171 }
1172
1173 wpstream_show_bubble(current_bubble_step,branch)
1174
1175
1176
1177 })
1178 }
1179
1180
1181 return {
1182
1183 }
1184 })();