Skip to content

Instantly share code, notes, and snippets.

@owain-stratton
Last active July 4, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owain-stratton/3762eee700aa8f3cd23b5a2e08b28333 to your computer and use it in GitHub Desktop.
Save owain-stratton/3762eee700aa8f3cd23b5a2e08b28333 to your computer and use it in GitHub Desktop.
README for gmFeedWidget

gmFeedWidget Guide

The Globalmouth feedwidget is a widget showing sports events from the Kambi Sportsbook API. The events shown are requested from a CMS to determine which events to show. The widget alternates views between live and pre-match events on a sliding animation.

gmFeedWidget function

Parameters

Parameter key Type Default Description
container string or HTMLElement 'gmFeedWidget-container' Element ID in the DOM or the HTMLElement. The widget will be rendered inside this container
numberOfLiveEvents number 4 The number of 'Live Events' to show in the widget. The widget is styled with overflow-y: auto in the css.
numberOfPrematchEvents number 3 The number of 'Prematch Events' to show in the widget. The widget is styled with overflow-y: auto in the css.
liveHeaderLabel string null Header for 'live' widget view for localization
preMatchHeaderLabel string null Header for 'pre-match' widget view for localization
liveLabel string null Label for 'LIVE' keyword used for localization
cmsDataUrl string null Absolute URL to CMS endpoints for fetching events
sportsbookBaseUrl string null Relative URL to the sportsbook for placing bet and navigating.
lang string en_GB Language to use when fetching data from the Kambi API. This should be in the format: language_Locale, for example en_GB for English Global, or de_DE for German Germany or pt_BR for Portuguese Brazilian
refreshTimeout number 60000 The timeout required for updating the data and performing new data fetches. The timeout is in miliseconds.
switchViewTimeout number 10000 The timeout required for switching between 'pre-match' and 'live' feeds for the widget. The timeout is in milliseconds.
onError function callback for when an error happens when running the widget
onSuccess function callback for when the widget successfully loads and fetches data
redirectCallback function callback for the widget to open the sportsbook using the parameter path
tennisSetLabel string Set Provide a string to be used for the score in tennis events e.g. "Set 1", "Set 2" the string passed should be translated for different locales
platformName string null Name of platform currently it should only be 'admiral' or 'starvegas'

Returns

Name Type Description
updateNow function Perform a force refresh of the widget. Fetching data and re-rendering updates.
destroy function Destroys the widget removing it from the DOM and along with all event listeners associated.

Supported Sports

const supportedSports = [
   'FOOTBALL',
   'TENNIS',
   'BASKETBALL',
   'ICE_HOCKEY',
   'HANDBALL',
   'VOLLEYBALL',
   'MOTORSPORT',
   'AMERICAN_FOOTBALL',
   'DARTS'
];

Supported Languages

  • bg_BG: Bulgarian
  • cs_CZ: Czech
  • da_DK: Danish
  • de_AT: German in Austria
  • de_CH: German in Switzerland
  • de_DE: German
  • el_GR: Greek
  • en_AU: Australian English
  • en_GB: English
  • es_ES: Spanish
  • et_EE: Estonian
  • fi_FI: Finnish
  • fr_BE: Belgian French
  • fr_CA: French in Canada
  • fr_CH: French Switzerland
  • fr_FR: French
  • hr_HR: Croatian
  • hu_HU: Hungarian
  • it_IT: Italian
  • lt_LT: Lithuanian
  • lv_LV: Latvian
  • nl_BE: Belgian Dutch
  • nl_NL: Dutch
  • no_NO: Norwegian
  • pl_PL: Polish
  • pt_BR: Portuguese in Brazil
  • pt_PT: Portuguese in Portugal
  • ro_RO: Romanian
  • ru_RU: Russian
  • sv_SE: Swedish
  • tr_TR: Turkish

Example

Admiral

The following example implementation of the Admiral widget

<body>

   <div id="gmFeedWidget-container">
      <!-- Widget rendered inside here -->
   </div>

   <!-- Script tag pointing to hosted bundle on CDN -->
   <script src="https://d3tt3wt50tdn9c.cloudfront.net/feedWidget-admiral/bundle.js"></script>

   <!-- Example of calling the function -->
   <script>
   var widget = window.gmFeedWidget({
      container:           document.getElementById('gmFeedWidget-container')
      liveHeaderLabel:     'Live Matches',
      preMatchHeaderLabel: 'Pre-Match Events',
      liveLabel:           'LIVE',
      sportsbookBaseUrl:   'SPORTSBOOK-URL',
      lang:                'en_GB',
      cmsDataUrl:          'https://d1i6rvicdtllxe.cloudfront.net/',
      platformName:        'admiral',
      tennisSetLabel:      'Set'
   });
   </script>
</body>

Starvegas

The following example implementation of the Starvegas widget

<body>

   <div id="gmFeedWidget-container">
      <!-- Widget rendered inside here -->
   </div>

   <!-- Script tag pointing to hosted bundle on CDN -->
   <script src="https://d3tt3wt50tdn9c.cloudfront.net/feedWidget-starvegas/bundle.js"></script>

   <!-- Example of calling the function -->
   <script>
   var widget = window.gmFeedWidget({
      container:              document.getElementById('gmFeedWidget-container'),
      numberOfLiveEvents:     6,
      numberOfPrematchEvents: 6,
      liveHeaderLabel:        'Live Matches',
      preMatchHeaderLabel:    'Pre-Match Events',
      liveLabel:              'LIVE',
      sportsbookBaseUrl:      'SPORTSBOOK-URL',
      lang:                   'en_GB',
      cmsDataUrl:             'https://d1i6rvicdtllxe.cloudfront.net/',
      platformName:           'starvegas',
      tennisSetLabel:         'Set'
   });
   </script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment