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, and a helper that posts the live player 7 * into the activity timeline. Localized data (admin URL, buddyboss flag, nonce) 8 * arrives via the wpstream_integrations_vars object. 9 */ 10jQuery(document).ready(function ($) { 11 "use strict"; 12 // Only bind the channel picker when the BuddyBoss integration is active. 13 if(wpstream_integrations_vars.is_buddyboss==='yes'){ 14 wpstream_buddy_boss_select_channel(); 15 } 16}); 17 18 19/* 20* 21* On this function we receive note that the event is on 22* 23*/ 24 25 26/** 27 * Entry point invoked when a channel goes live: post its player to the timeline. 28 * 29 * @param {number|string} show_id Channel post id that just went live. 30 */ 31function wpstream_integration_notifications(show_id){ 32 // Route to the BuddyBoss timeline player generator when that integration is active. 33 if(wpstream_integrations_vars.is_buddyboss==='yes'){ 34 wpstream_buddyb_generate_player_html(show_id); 35 } 36} 37 38 39/* 40* 41* Select streaming channet on BuddyBoss 42* 43*/ 44 45 46/** 47 * Bind the profile tab's channel <select> so a change persists the selection. 48 * 49 * On change, POSTs the chosen channel id to the select-channel AJAX action and 50 * reloads the page when the server confirms it was saved. 51 */ 52function wpstream_buddy_boss_select_channel(){ 53 // Listen for the user picking a different channel in the dropdown. 54 jQuery('#wpstream_buddyboss_select_channel').on('change',function(){ 55 56 // Build the admin-ajax endpoint and read the newly selected channel id. 57 var ajaxurl = wpstream_integrations_vars.admin_url+ 'admin-ajax.php';; 58 var show_id = jQuery('#wpstream_buddyboss_select_channel').val(); 59 jQuery.ajax({ 60 type: 'POST', 61 url: ajaxurl, 62 dataType: 'json', 63 timeout: 300000, 64 65 // Server action plus the selected channel id. 66 data: { 67 'action' : 'wpstream_buddy_boss_select_channel_function', 68 'show_id' : show_id, 69 }, 70 success: function (data) { 71 // Reload so the page reflects the newly selected channel. 72 if(data.saved===true){ 73 location.reload(); 74 } 75 76 }, 77 // Swallow AJAX errors silently. 78 error: function (jqXHR,textStatus,errorThrown) { 79 } 80 }); 81 }); 82} 83 84 85 86/* 87* 88* BuddyB - generate html player to add in timeline 89* 90*/ 91 92/** 93 * Ask the server to post a live-player activity to the BuddyBoss timeline. 94 * 95 * @param {number|string} show_id Channel post id to embed in the timeline. 96 * @param {number|string} [user_id] Optional user id (accepted but not sent). 97 */ 98function wpstream_buddyb_generate_player_html(show_id,user_id){ 99 100 // admin-ajax endpoint and the integration nonce (read but not forwarded here). 101 var ajaxurl = wpstream_integrations_vars.admin_url+ 'admin-ajax.php';; 102 var nonce = wpstream_integrations_vars.buddy_nonce; 103 jQuery.ajax({ 104 type: 'POST', 105 url: ajaxurl, 106 dataType: 'json', 107 timeout: 300000, 108 109 // Server action plus the channel id to embed. 110 data: { 111 'action' : 'wpstream_buddyb_integrations_generate_player_html', 112 'show_id' : show_id, 113 114 115 }, 116 // Fire-and-forget: the activity is created server-side, nothing to do on success. 117 success: function (data) { 118 119 }, 120 error: function (jqXHR,textStatus,errorThrown) { 121 122 } 123 }); 124}
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.