You can embed BuboBox in your website with the Javascript that is displayed after you create a new widget or you can copy the code snippet from the widget settings page. Go to My BuboBoxes and select the widget you want to embed in your page. Now click on “Embed Code” in the submenu.
The code snippet will look something like below. WIDGET_ID will be replaced with your selected widget.
<div class="bbbx-widget" data-widget="WIDGET_ID"></div>
<script type="text/javascript">
/*** CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE ***/
var bbbx_widget_id = WIDGET_ID; // required: replace with the widget ID of the widget you want to show
/*** DON'T EDIT BELOW THIS LINE ***/
(function() {
var bbbx = document.createElement('script'); bbbx.type = 'text/javascript'; bbbx.async = true;
bbbx.src = '//api.bubobox.com/widget.js?id=' + bbbx_widget_id;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bbbx);
})();
</script>
There are two global javascript variables that you can use to interact with your widget and those are mybb and bubobox_x where x is a widget ID.
Don’t use these global variables between directly between script tags because this will give a Javascript error because the BuboBox code is loaded asynchronously. A place where you can use these global variables is for example in a an onclick event of an <a>
element. For example:
<a href="javascript:void(0);" onclick="mybb.openRecorder('video')">Open Recorder</a>
More about what methods are available on these global BuboBox vars can be found below.
There is a global callback function available that is executed once all BuboBox resources are loaded. The function is bbbx_config and if you use this inside that function you have access to the global currently loaded widget object. This is actually the same like the global vars described above. On this object you can call methods to execute a specific action like opening a recorder, play a certain item, and much more. It’s also possible to listen for specific events that happen in the widget and execute some code one that event happens. Below an example of listening to the widget for a published event.
var bbbx_widget_id = WIDGET_ID;
function bbbx_config() {
// all resources are loaded
this.subscribe("event", function() {
alert('Thanks for your entry');
});
}
/*** DON'T EDIT BELOW THIS LINE ***/
You can configure your widget through our admin panel but sometimes it’s possible you’ll want to apply some settings through code. In this case you’ll place your settings just below the line where bbbx_widget_id gets defined:
var bbbx_widget_id = WIDGET_ID;
var bbbx_visual = false; // example setting through code
/*** DON'T EDIT BELOW THIS LINE ***/
More information about the example setting above can be found on the visual mode page(add link).
Below you find a list of methods that you can call on the widget object.
All examples below are executed on the this object so these must be used inside the bbbx_config function. If you want to use these functions outside bbbx_config you should use mybb or bubobox_x.
Open a recorder lightbox so the user can create a new entry.
Parameter | Default | Description |
---|---|---|
type | video | Type of media entry recorder you want to open: video, image, url, text |
Open a specific media item in a lightbox.
Parameter | Default | Description |
---|---|---|
id | video | ID of the media item you want to open. |
this.openPlayer(3434)
With this method you can get the html code that can be used to embed a player in your html page.
Parameter | Default | Description |
---|---|---|
id | ID of the media item you want to open. | |
width | Width of the embedded player (pixels). | |
height | Height of the embeded player (pixels). | |
callback | Callback that is executed once the embed code is fetched from the server. The first parameter will contain the html you can use to embed the player on your page. |
this.getPlayerEmbed(1396, 400, 300, function(embed) {
BBBX.$('#player').html(embed);
});
For this example to work, make sure to create an html element with id “player” on your page:
<div id="player"></div>
Get an array of entries from the current widget. The returned value is an array of objects. Every object has the following properties:
Property | Description |
---|---|
direct_link | Direct link that can be used to redirect user to this specific item. This link is also used to share the items on social networks. |
media_type | The type of the entry: video, image, url, text |
stat_facebook | Number of times the entry is share, liked, commented on Facebook. |
stat_googleplus | Number of shares on Google+ |
stat_leaderboard | Number of point in the BuboBox leaderboard. |
stat_plays | Number of point in the BuboBox leaderboard. |
stat_plays_end | If the entry is a video this number will show how many times the video is watched till the end. |
stat_position | The position in the leaderboard based on the stat_leaderboard |
stat_stars | Average number of stars |
stat_twitter | Average number of stars |
thumb_url | Url of the thumb image for this item. The thumbs have following dimensions: 200x142 |
update_hash | This is a MD5 hash that is calculated based on the last time this item was updated. This can be used to invalidate cached thumb url’s. |
user_company | Company name of the user that added this entry if provided |
user_website | Website url of the user that added this entry if provided |
user_name | User name of the user that added this entry if provided |
user_thumb_small_url | Avatar url of the user if he was logged in with Twitter or Facebook when he added this item |
user_thumb_url | Avatar url of the user if he was logged in with Twitter or Facebook when he added this item |
widget_id | ID of the widget this entry belongs to |
video_datetime | Date and time when this entry was added to the widget |
video_description | Extra note that is added to a video or image entry if provided by the user. If the entry is a text testimonial this property will contain the testimonial. |
video_id | ID of the entry |
video_location | Url of the location where the entry is added. |
Parameter | Default | Description |
---|---|---|
callback | Callback function that will be called once the results are fetched from the server. The first parameter of the callback function is the object array of all entries. | |
options | Object with extra options. In the table below you find the options that you can use. |
Option | Default | Description |
---|---|---|
search | String to search for in the entries meta data. |
this.getEntries(function(entries) {
console.log(entries);
});
For example to create a thumbnail list of all entries, and when a users clicks on a thumbnail the item is displayed. Below you can find the code to do this:
this.getEntries(function(entries) {
var html = '';
for(idx in entries) {
var entry = entries[idx];
html += '<li><a href="javascript:mybb.openPlayer(' + entry.video_id + ')"><img src="' + entry.thumb_url + '" width="200" /></li>';
}
BBBX.$('.bbbx-custom').html('<ul>' + html + '</ul>');
});
The example below will return entries that contain “Joe” as meta data:
this.getEntries(function(entries) {
console.log(entries);
}, {search: 'Joe'});
Get and object with information about the requested entry ID.
Parameter | Default | Description |
---|---|---|
id | ID of the media item you want to open. | |
callback | Callback function that will be called once the result is fetched from the server. The first parameter of the callback function is the object that contains the information about the entry. |
this.getEntry(4000, function(entries) {
console.log(entries);
});
Open a share lightbox so the user can share an entry.
Parameter | Default | Description |
---|---|---|
entryId | ID of the media item you want to share. |
The set order method can be used to change the order of the entries in the widget. The widget will automatically update once this method is called.
mybb.setOrder([type]);
Type | Description |
---|---|
ASC | |
DESC | |
EXPRESSION_ASC | |
EXPRESSION_DESC | |
FACEBOOK_ASC | |
FACEBOOK_DESC | |
TWITTER_ASC | |
TWITTER_DESC | |
GPLUS_ASC | |
GPLUS_DESC | |
PLAY_ASC | |
PLAY_DESC | |
STARS_ASC | |
STARS_DESC |
With the subscribe method you can listen for a specific event on the widget. Below you find an overview of all the events:
this.subscribe([event], [callback]);
Event | Callback event properties | Description |
---|---|---|
widget.share | network, entryId, url | |
widget.refresh | ||
player.show | entryId | |
player.shown | entryId | |
player.hide | entryId | |
player.hidden | entryId | |
recorder.show | ||
recorder.shown | ||
recorder.hide | ||
recorder.hidden | ||
camera.publish | ||
camera.published | ||
recorder.publish | ||
recorder.published | ||
text.publish | ||
text.published | ||
url.publish | ||
url.published | ||
upload.published | media_id, media_type | |
upload.progress | percent | |
published | entryId, entryType | This event is triggered for all types (video, image, text, url and audio) |
Parameter | Default | Description |
---|---|---|
event | Name of the event. See list above | |
callback | Callback function which will be called when the event is triggered. |
this.subscribe('player.hide', function(e) {
console.log('Player is closing now', e.entryId);
})
Can't find an answer to your question?
Can't find an answer to your question or problem? Support requests are the most efficient way for us to handle your support inquiries.