Widget loader

Description

The widget loader is a core part of the widgets, as the name states it is responsible for loading all of the widgets on the page. Without initializing the widget loader with the proper configuration, the widgets won't be rendered.

How it works

The way the widget loader works is simple and can be broken down into a few steps

  1. The loader selects all of the widgets on the page using the following data attribute: data-widgetId
  2. When all of the placeholder div elements have been found the loader applies general configurations to the widgets, more on that is explained in the Configuration section
  3. When the previous step has finished next is the loading of javascript libraries for each widget and appending the script tags to the web page
  4. When all of the widget scripts have been appended to the body the respective widgets will be initialized and rendered

Configuration

You can refer to the following table for a list of all of the available configurations

Option nameDescriptionRequiredBehaviour if missing
CDN_URLSpecifies the environment from which to load the widgets: integration or productionNoThe production version of the widgets will be loaded
LINK_OPTIONS_V2Responsible for transforming the following entities into configurable links: players, teams, tournaments, matchesNoThe players, teams, tournaments inside of widgets won't be transformed into links
AUTHORResponsible for showing/hiding the sportal365 footer inside of widgetsNoThe sportal365 logo will be displayed in the footers of the widgets
ODD_CLIENTResponsible for specifying which betting providers can be used inside of the widgetsYesOdds won't be displayed and some widgets won't load
API_URLResponsible for configuring the widgets with the Football API URL towards which they will make requestsYesWidgets won't load
API_KEYResponsible for configuring the API key for the Football API requestsYesWidgets won't load
LANGThe language on which the statistical data will be displayed and also the widget labels will be displayedNoEnglish language will be applied
REQUEST_INTERVALControls how often the widgets will make requests towards the Football API. The minimum accepted value is 15 secondsNo30000 milliseconds timeout will be applied
TOURNAMENT_ORDERLimits the matches for given widgets to a specific tournament list.NoMatches from all available tournaments can be used
PRE_GAME_ODDS_ONLYConfigures widgets to display odds before the start of matches onlyNoOdds will be displayed during the games as well (if available)

Detailed description of each configuration

CDN_URL

The CDN_URL is used to configure the URL from which the widget javascripts will be downloaded.

Configuration value

CDN_URL: "https://widgets.sportal365.com"

LINK_OPTIONS_V2

This options is responsible for transforming the following entities into configurable links: players, teams, tournaments.

Example:
When a widget that lists players is displayed and the configuration is activated, all of the player images and names will become clickable links, which can be configured. These links can lead users to statistical pages for example.

Configuration value

LINK_OPTIONS_V2: {
  "team": {"url": "https://test.com/football/team-{teamId}"},
  "tournament": {"url":"https://test.com/football/tournament-{tournamentId}"},
  "player": {"url":"https://test.com/football/player-{playerId}"},
  "match": {
    "url": "https://test.com/football/match-{teamId}-{teamId}#{matchId}",
    "sort": {"criteria": "alphabetically", "direction": "asc"}
  },
  "configuration": {
    "newWindow": false
  }
}

🚧

Please keep in mind that each URL scheme is can be shaped to your liking. The only mandatory part that must not be changed is the placeholders: {teamId}, {tournamentId}, {playerId}

AUTHOR

The AUTHOR option is responsible for controlling the logo displayed in the footer of the widgets. This option controls ONLY THE VISIBILITY of the logo, you cannot change it.

Configuration value

AUTHOR: false

ODD_CLIENT

The ODD_CLIENT option is used to pass a value which refers to a list of betting providers. These betting providers will be displayed inside of the widgets, if they have available odds for the specific matches.

Configuration value

ODD_CLIENT: "SPORTAL365_ODD_CLIENT_NAME"

🚧

Important

Please keep in mind that this value is generated by our team. If you want to use a specific list of betting providers contact our support at [email protected]

API_URL

This option is responsible for configuring the URL which the widgets will call for the football data. This configuration is mandatory, without it the widgets won't load.

Configuration value

API_URL: "SPORTAL365_FOOTBALL_API_URL"

🚧

Important

Please keep in mind that the URL may be different depending on your region. To request a proper Football API URL, if you have not been provided with such already, contact our support at [email protected]

API_KEY

This option is responsible for configuring the API key which is used for the requests that the widgets make towards the Football API. This option is mandatory, without it the widgets won't load.

Configuration value

API_KEY: "SPORTAL365_API_KEY"

🚧

Important

Please keep in mind that they API key is personal and it must be generated by our team. To request a key please contact our support at [email protected]

LANG

This option controls the language in which the widgets will be displayed. You can find a list of supported languages in the table below

LanguageLanguage code
Englishen
Germande
Portuguesept
Romanianro
Turkishtr
Hungarianhu
Serbiansr
Greekel
Italianit

Configuration value

LANG: "en"

REQUEST_INTERVAL

This configuration controls the how often the widget will refresh automatically.

Configuration value

REQUEST_INTERVAL: "30000"

🚧

Minimum value

The minimum value that the widget loader accepts is 15000, which is 15 seconds

TOURNAMENT_ORDER

The TOURNAMENT_ORDER is responsible for limiting the matches that can be displayed by the widgets. The limitation works by specifying the tournaments in which the matches are being played.

Configuration value

TOURNAMENT_ORDER: "SPORTAL365_TOURNAMENT_ORDER"

🚧

Important

The tournament order is generated by our team. To receive a value please contact our support at [email protected]

PRE_GAME_ODDS_ONLY

The option is responsible for the limitation of the odds by displaying them before the start of the match only.

Configuration value

PRE_GAME_ODDS_ONLY: true

Configuraiton example

Library functions

The widget loader exposes some functionality to the window object. This can help you make updates to the loader directly without the need to re-initialize it.

How to access the window SMP365 object

To access the functionality attached to the window object you can access it through the SMP365 variable, as seen below

window.SMP365

The available functions are the following

FunctionDescription
configurator.addOrUpdateOption(OPTION_NAME, OPTION_VALUE)This function allows for adding options to the widget loader without the need to re-initializing it. This will also automatically reload all of the widgets on the web page
loadWidgets()Reloads all of the widgets on the web page
widgetsReturns a list of all of the widgets that have been rendered on the web page