Gigya Job Openings

gm.showChallengeStatusUI JS

Skip to end of metadata
Go to start of metadata

Description

 

Displays Gigya's Game Mechanics Challenge Status plugin. The plugin enables partners to display all level badges, both locked and unlocked, of a specified challenge.

 

Note: If you plan on integrating the Challenge Status plugin, we highly recommend reading the Challenge Status Plugin page, which is a step-by-step guide for integrating the Challenge Status plugin. In addition, you can read the Game Mechanics Guide for more information. Game Mechanics is a premium platform that requires separate activation. If Game Mechanics is not part of your site package please contact your Gigya account manager or contact us by filling in a support form on our site. You can also access the support page by clicking "Support" on the upper menu of Gigya's site.

 

The plugin presents:

  • A display of the level badges and level titles of a specified challenge
  • A tooltip pop-up that is displayed on mouse-over, describing the level

 

Plugin's Default Design

The following screenshot presents the Challenge Status plugin in a state of a logged in user who has achieved a Beginner level in the specified challenge, in this case Overall Rank, the default challenge:

 

Syntax

 

 

Parameters

The following table lists the available parameters:

RequiredNameTypeDescription
containerIDstringAn ID of a <div> element on the page in which you want to display the plugin.

widthintegerDetermines the width in pixels of the plugin. The default width is 300 pixels.
heightintegerDetermines the height in pixels of the plugin. The default value is 100 pixels.
challengestringThe ID of the challenge for which the plugin is displayed. The default value is "_default", representing the default challenge.
detailsPopupTemplatestringA complete template of the body of the tooltip pop-up. A template is a layout definition for a group of related graphics elements in the plugin. The plugin includes customizable templates, and you may assign each template with an HTML string that overrides its default graphic layout. Accepts the following placeholders: $levelTitle, $levelDescription. To learn more please refer to the Templates Example in the Game Mechanics guide. 
actionAttributesJSON objectThis parameter is used to display the Challenge Status plugin according to a specific attribute, for example you can show the user's challenge status only on the "Glee" page of a site, instead of his challenge status on the entire site. The action attribute is comprised of a single set of a key (category) and a value, e.g. {"tv-show":"glee"}. In order to use this option, you need to give action attributes to actions the user may perform on the site, such as sharing or commenting, and these action attributes will be used to filter. Read more here.
 Events Registration Parameters 
onLoadfunction refA reference to an event handler function that will be called when the plugin has finished drawing itself.
onErrorfunction refA reference to an event handler function that will be called when an error occurs.
 

Plugin Events

An Event Handler is a JavaScript function with the following signature:

functionName(eventObj)

The single argument, eventObj, contains information about the event and has different fields for different events.

The following tables specify the list of fields available in the eventObj for each event:

onLoad Event Data

FieldTypeDescription
   
eventName string The name of the event.
source string The source plugin that generated this event. The value of this field is the name of the plugin's API method, e.g., 'showLoginUI', 'showCommentsUI', etc.
contextobject Any user defined data passed as a value of the context parameter by the application to the API method, it will be returned as an accessible property in the response. If no context parameter was passed, it will not be returned.

onError Event Data

FieldTypeDescription
   
eventName string The name of the event.
source string The source plugin that generated this event. The value of this field is the name of the plugin's API method, e.g., 'showLoginUI', 'showCommentsUI', etc.
contextobject Any user defined data passed as a value of the context parameter by the application to the API method, it will be returned as an accessible property in the response. If no context parameter was passed, it will not be returned.
errorCodeintegerThe result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.
errorMessagestringA short textual description of an error, associated with the errorCode, for logging purposes.
errorDetailsstringThis field will contain the exception info, if available.

 

Code Sample

<div id="divChallengeStatus"></div>
<script>
   var params =
    {
            containerID: 'divChallengeStatus'
    };

    gigya.gm.showChallengeStatusUI(params)
</script>

 

Notes:

  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the gigya.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider ? prior to calling the API method. You can learn more in the Social Login guide.

In the Game Mechanics Plugins demo you will find a complete working example that uses all the Game Mechanics plugins API methods. You may view the code, run it and view the outcome.