Initialize
After DOM is successfully loaded, Partner has to init BTRenderer by calling initialize() method.
note
Sportsbook inherits fonts from the parent page. Specific font can be applied on the sportsbook div element as well.
note
Once a player has switched the language, signed in/out it is necessary to call initialize() method and pass the updated parameters to it.
note
It is strongly recommended to use and update betSlipOffsetTop and betSlipOffsetBottom parameters to avoid UX conflicts in cases when your header/footer has dynamic height.
Partner can directly open a page inside of the frame by specifying ?bt-path=/page_address
in the URL.
List of parameters
Name | Type | Required | Description |
---|---|---|---|
brand_id | string | Yes | Unique Partner's Website ID obtained during the onboarding process Partner receives it from Fungamess |
token | string | Yes | Unique time-limited JWT token assigned to each user Pass token: null for unauthorized users Platform would receive it from the Fungamess |
onTokenExpired | function | Yes | A function that returns a response with a new JWT token when the previous one is expired Mandatory for authorized users To get such token, the platform must send a request from its front to back end, along with the POST -request, from the backend to Fungamess, with a refreshSportbookToken method, that contains { id: User ID , api_token: User Token } request body The platform's frontend should not send a request directly to the Fungamess |
themeName | string | Yes | Unique name of the theme, provided by Fungamess |
lang | string | Yes | Frame language (default: en ) The full list of supported languages can be found in Appendices section The abbreviation is case-sensitive Language code in ISO 639-1 format (e.g., en , ru , es ) |
target | HTMLElement | Yes | An element of DOM to render a betslip, in the form of div element instead of iframe Works similarly to Defining container |
betSlipOffsetTop | number | Yes | The parameter that defines the gap between top of the window and a betslip (for example, fixed header ) |
betSlipOffsetBottom | number | Yes | The parameter that defines the gap between bottom of the window and a betslip (for example, fixed footer ) |
betSlipOffsetRight | number | Yes | The parameter that defines the gap between right side of the window and a betslip (for example, fixed sidebar ) |
betslipZIndex | number | Yes | The parameter that defines the index of betslip in relation to DOM elements used on Partners website It helps to avoid overlapping conflicts between different elements Value should be 100 or more |
url | string | Yes | The parameter that defines the page that will be shown to the user after the initialization of the application For example, if url= /1 page with soccer will be shown |
stickyTop | number | Yes | The parameter that defines the range between top of the window and sticky (fixed) elements in the application (sidebar etc.) It is recommended to use the parameters of Partner's fixed header Use 0 in cases when there is no fixed header |
scrollTopButtonPosition | string | Yes | The parameter that defines the scroll button position in the mobile version of the website There are two possible values: left and right |
scrollToTopButtonVisible | boolean | Yes | The parameter that defines the scroll button display in the mobile version of the website There are two possible values: true and false |
onRouteChange | callback | Yes | Callback function provided by Partner, it will be called when a player navigates across the frame |
onLogin | callback | Yes | Callback function provided by Partner, it will be called when a player logins with the frame Partners must specify what should happen when the login button is pressed For example, open a modal window with a login form or switch to another page (don't forget about the bt.kill() method, which should be called when the user refreshes the page) |
onRegister | callback | Yes | Callback function provided by Partner, it will be called when a player registers with the frame Partners must specify what should happen when user clicks on the register button For example, open a modal window with a register form or switch to another page (don't forget about the bt.kill() method, which should be called when the user refreshes the page) |
onSessionRefresh | callback | Yes | Callback function provided by Partner, it is responsible for the process of page refresh and sport initialization with the updated parameters |
onRecharge | callback | Yes | Callback function provided by Partner, it will be called when a player makes a deposit with the frame Partners must indicate where the user goes when they click on Make a deposit button |
onBannerClick | callback | Yes | Callback function provided by Partner, it will be called when a player clicks on line_banner |
onOutcomeClick | callback | Yes | Callback function provided by Partner, it will be called when a player clicks on line_banner or any widget, and the outcome is added to the betslip |
onBetSlipStateChange | callback | Yes | Callback function provided by Partner, it will be called when player opens or closes the betslip This function accepts a boolean parameter isOpen { isOpen: true \ false } |
betSlipButton | HTMLElement | Yes | Will be used when a player adds outcome to the betslip on mobile device Relevant in case when Partner uses his own betslip button Animation will be directed to the DOM element provided by Partner with the options { betSlipButton: someHTMLElement } |
handlePageChange | HTMLElement | Yes | Callback function provided by Partner, it will be called when a user navigates between pages inside of the application This function accepts a single parameter - url This callback should be used only for custom routing |
Example
var bt = new BTRenderer().initialize({
brand_id: "11111111111111111",
token: "<JWT token>",
onTokenExpired: function() {},
themeName: "default",
lang: "en",
target: document.getElementById('betby'),
betSlipOffsetTop: 0,
betslipZIndex: 999,
onRouteChange: function() {},
onLogin: function() {},
onRegister: function() {},
onSessionRefresh: function() {},
onBetSlipStateChange: function() {}
});