Module: client/token

client/token

Util functions and classes to make working with session tokens a bit easier.
Source:

Methods

<static> extractTokenFromURL() → {external:Promise}

Extracts the session token from the current URL. At the moment it has to follow the format "http://path.to/my/server#myToken".
Source:
See:
Returns:
On success the promise will be resolved with the parsed session token. On error it will be rejected with a NoSuchSessionError.
Type
external:Promise

<static> SymbolArray(symbolCount)

Small helper class for managing symbol fields to connect to existing sessions. The user can click on each symbol to toggle its state - all activated symbols will then build the session token.
- - #
# - -
- - #
for example will convert to the token '238' - the indices of all activated symbols.
Parameters:
Name Type Description
symbolCount integer number of symbols you want to have in your grid
Source:
Example
var symbols = SymbolArray(9);

function onIconClick(event) {
  var icon = $(event.currentTarget);
  var isActive = symbolArray.toggle(icon.index());
  var classes = isActive ? 'active' : 'inactive';
  icon.attr('class', classes);
}

// .... later on:
var token = symbols.toToken();
multi.joinSession(token);