| @@ -1,17 +1,7 @@ | ||
| 1 | 1 | /*global $, jQuery, wpstream_integrations_vars*/ |
| 2 | -/* | |
| 3 | - * WpStream integrations front-end script (BuddyPress/BuddyBoss). | |
| 4 | - * | |
| 5 | - * Wires up the profile "Live Video" tab: the channel-selection dropdown that | |
| 6 | - * saves the chosen channel over AJAX. Timeline activities are posted | |
| 7 | - * server-side from the channel lifecycle hooks, not from the browser. | |
| 8 | - * Localized data (admin URL, buddyboss flag, nonce) arrives via the | |
| 9 | - * wpstream_integrations_vars object. | |
| 10 | - */ | |
| 11 | 2 | jQuery(document).ready(function ($) { |
| 12 | 3 | "use strict"; |
| 13 | - // Only bind the channel picker when the BuddyBoss integration is active. | |
| 14 | 4 | if(wpstream_integrations_vars.is_buddyboss==='yes'){ |
| 15 | 5 | wpstream_buddy_boss_select_channel(); |
| 16 | 6 | } |
| 17 | 7 | }); |
| @@ -18,27 +8,32 @@ | ||
| 18 | 8 | |
| 19 | 9 | |
| 20 | 10 | /* |
| 21 | 11 | * |
| 12 | +* On this function we receive note that the event is on | |
| 13 | +* | |
| 14 | +*/ | |
| 15 | + | |
| 16 | + | |
| 17 | +function wpstream_integration_notifications(show_id){ | |
| 18 | + if(wpstream_integrations_vars.is_buddyboss==='yes'){ | |
| 19 | + wpstream_buddyb_generate_player_html(show_id); | |
| 20 | + } | |
| 21 | +} | |
| 22 | + | |
| 23 | + | |
| 24 | +/* | |
| 25 | +* | |
| 22 | 26 | * Select streaming channet on BuddyBoss |
| 23 | 27 | * |
| 24 | 28 | */ |
| 25 | 29 | |
| 26 | 30 | |
| 27 | -/** | |
| 28 | - * Bind the profile tab's channel <select> so a change persists the selection. | |
| 29 | - * | |
| 30 | - * On change, POSTs the chosen channel id to the select-channel AJAX action and | |
| 31 | - * reloads the page when the server confirms it was saved. | |
| 32 | - */ | |
| 33 | 31 | function wpstream_buddy_boss_select_channel(){ |
| 34 | - // Listen for the user picking a different channel in the dropdown. | |
| 35 | 32 | jQuery('#wpstream_buddyboss_select_channel').on('change',function(){ |
| 36 | 33 | |
| 37 | - // Build the admin-ajax endpoint and read the newly selected channel id. | |
| 38 | 34 | var ajaxurl = wpstream_integrations_vars.admin_url+ 'admin-ajax.php';; |
| 39 | 35 | var show_id = jQuery('#wpstream_buddyboss_select_channel').val(); |
| 40 | - var nonce = wpstream_integrations_vars.buddy_nonce; | |
| 41 | 36 | jQuery.ajax({ |
| 42 | 37 | type: 'POST', |
| 43 | 38 | url: ajaxurl, |
| 44 | 39 | dataType: 'json', |
| @@ -43,23 +38,53 @@ | ||
| 43 | 38 | url: ajaxurl, |
| 44 | 39 | dataType: 'json', |
| 45 | 40 | timeout: 300000, |
| 46 | 41 | |
| 47 | - // Server action, the selected channel id and the integration nonce. | |
| 48 | 42 | data: { |
| 49 | 43 | 'action' : 'wpstream_buddy_boss_select_channel_function', |
| 50 | - 'show_id' : show_id, | |
| 51 | - 'security' : nonce | |
| 44 | + 'show_id' : show_id, | |
| 52 | 45 | }, |
| 53 | 46 | success: function (data) { |
| 54 | - // Reload so the page reflects the newly selected channel. | |
| 47 | + | |
| 55 | 48 | if(data.saved===true){ |
| 56 | 49 | location.reload(); |
| 57 | 50 | } |
| 58 | - | |
| 51 | + | |
| 59 | 52 | }, |
| 60 | - // Swallow AJAX errors silently. | |
| 61 | - error: function (jqXHR,textStatus,errorThrown) { | |
| 53 | + error: function (jqXHR,textStatus,errorThrown) { | |
| 62 | 54 | } |
| 63 | 55 | }); |
| 64 | 56 | }); |
| 65 | 57 | } |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | +/* | |
| 62 | +* | |
| 63 | +* BuddyB - generate html player to add in timeline | |
| 64 | +* | |
| 65 | +*/ | |
| 66 | + | |
| 67 | +function wpstream_buddyb_generate_player_html(show_id,user_id){ | |
| 68 | + | |
| 69 | + var ajaxurl = wpstream_integrations_vars.admin_url+ 'admin-ajax.php';; | |
| 70 | + var nonce = wpstream_integrations_vars.buddy_nonce; | |
| 71 | + jQuery.ajax({ | |
| 72 | + type: 'POST', | |
| 73 | + url: ajaxurl, | |
| 74 | + dataType: 'json', | |
| 75 | + timeout: 300000, | |
| 76 | + | |
| 77 | + data: { | |
| 78 | + 'action' : 'wpstream_buddyb_integrations_generate_player_html', | |
| 79 | + 'show_id' : show_id, | |
| 80 | + | |
| 81 | + | |
| 82 | + }, | |
| 83 | + success: function (data) { | |
| 84 | + | |
| 85 | + }, | |
| 86 | + error: function (jqXHR,textStatus,errorThrown) { | |
| 87 | + | |
| 88 | + } | |
| 89 | + }); | |
| 90 | +} | |