-
Notifications
You must be signed in to change notification settings - Fork 5
Configuring the widget
Karthik Balakrishnan edited this page Oct 9, 2017
·
1 revision
Boxoffice is split into two parts, the server/backend app that has the admin dashboard + API, and the frontend javascript ticketing widget that's embeddable on websites.
You need a DOM element with the id boxoffice-widget
in your page. This where you widget will be loaded.
You can have a loading indicator/placeholder inside the element (which will be replaced once the widget loads)
<div id="boxoffice-widget"><p class="text-center regular col-sm-8 col-sm-offset-2 col-xs-12">Loading...</p></div>
Then add this init code in your page. (This assumes you have jQuery version 2.2 or above and font-awesome available).
$(document).ready(function() {
var boxofficeUrl = "https://boxoffice.hasgeek.com";
$.get({
url: boxofficeUrl + "/api/1/boxoffice.js",
crossDomain: true,
timeout: 8000,
retries: 5,
retryInterval: 8000,
success: function (data) {
var boxofficeScript = document.createElement('script');
boxofficeScript.innerHTML = data.script;
document.getElementsByTagName('body')[0].appendChild(boxofficeScript);
window.Boxoffice.init({
org: '', // Organisation to show
itemCollection: '', // ItemCollection ID to show
paymentDesc: '' // Description for payments widget
});
},
error: function (response) {
var ajaxLoad = this;
ajaxLoad.retries -= 1;
var errorMsg;
if (response.readyState === 4) {
errorMsg = "Server error, please try again later.";
$('#boxoffice-widget p').html(errorMsg);
} else if (response.readyState === 0) {
if (ajaxLoad.retries < 0) {
if(!navigator.onLine) {
errorMsg = "Unable to connect. There is no network!";
$('#boxoffice-widget p').html(errorMsg);
} else {
errorMsg = "Unable to connect. If you are behind a firewall or using any script blocking extension (like Privacy Badger). Please ensure your browser can load boxoffice.hasgeek.com, api.razorpay.com and checkout.razorpay.com .";
$('#boxoffice-widget p').html(errorMsg);
}
} else {
setTimeout(function() {
$.get(ajaxLoad);
}, ajaxLoad.retryInterval);
}
}
}
});
});
window.Boxoffice.init({
org: 'hasgeek', // Organisation to show
itemCollection: 'd386dbcf-1a32-11e7-b315-5d5ee7239cc7', // ItemCollection ID to show
paymentDesc: 'HasGeek', // Description for payments widget
categories: [
{
'name': 'conference',
'title': 'Standard',
'item_ids': ['68e27823-1a33-11e7-842a-85544f6e9ad9']
},
{
'name': 'premium',
'title': 'Premium',
'item_ids': ['63d94e70-1b3a-11e7-85fb-737e61409825','19e47ba8-1e8e-11e7-8f39-45cbac6935ba']
}
]
]
});
For security reasons, the server whitelists domains on which the embed is allowed. The whitelist is defined in the settings in instance/
.