v24
Initialization
1
var leaderboardId = "test",
2
record = {},
3
privateId = getUserIdFromLocalStorage();
4
5
var leaderboard = new window.LViS.Leaderboard({
6
lvis: window.LViS,
7
id: leaderboardId
8
});
9
10
var success = function (response) {
11
record = response;
12
};
13
14
var failure = function (error) {
15
console.log("error:" + error.error);
16
};
17
18
if (privateId) {
19
leaderboard.getRecord(privateId, success, failure);
20
} else {
21
leaderboard.setRecord(object, success, failure);
22
}
Copied!

Constructor

Create a new instance as follows:
1
var leaderboard = new window.LViS.Leaderboard({
2
lvis: <LViS object>,
3
id: <id>,
4
eventId: <eventId>,
5
timeout: <timeout>
6
});
Copied!
where:
  • lvis is the initialised LViS API object.
  • id is an up to 36 chars length string unique identifier. It can be whatever you need, depending on application logic.
  • eventId (optional) is a 36 chars length string unique identifier. It should be event UUID if you need to collect information in the context of a single event. Or this param can be skipped if you need to collect information for the whole project context.
  • timeout (optional) is request timeout in milliseconds.
There are some parameters that can be changed on the LViS-service side and they will be automatically configured in the API using service assets:
  • read_endpoint (string) - web-service endpoint for read operations.
  • write_endpoint (string) - web-service endpoint for write operations.
  • use_base64 (bool) - send and receive base64-encoded data.
LViS API object must be initialised before creating leaderboard instance.
Last modified 2yr ago
Copy link
Contents
Constructor