Constructor
new CypherPokerUI(protoElement)
Creates a new instance.
Parameters:
Name |
Type |
Description |
protoElement |
HTMLElement
|
A reference to the prototype element that will
be cloned for use with each new game instance. The original element will
remain unchanged (it should be hidden by default). |
- Source:
Members
autoDeal
Properties:
Name |
Type |
Default |
Description |
autoDeal |
Boolean
|
true
|
If true, cards are automatically dealt when
betting is done and it's our turn to deal. If false , the
CypherPokerGame.dealCards function of the
game reference will need to be invoked manually. |
- Source:
cypherpoker
Properties:
Name |
Type |
Description |
cypherpoker |
CypherPoker
|
A reference to the main CypherPoker instance.
This property may only be set once. When set, a number of event listeners are
added to the instance so that the user interface can respond to them. |
- Source:
gameElements
Properties:
Name |
Type |
Description |
gameElements |
Array
|
An indexed array of all game container elements
cloned from the protoGameElement object. |
- Source:
gameUISelectors
Properties:
Name |
Type |
Description |
gameUISelectors |
Object
|
Name/value pairs for game UI elements and their
associated CSS-style DOM selectors. Note that these selectors are relative to/children of
each game element cloned from the CypherPokerUI#protoGameElement.
Properties
Name |
Type |
Default |
Description |
betButton |
String
|
"#betButton"
|
The game's bet button. |
foldButton |
String
|
"#foldButton"
|
The game's fold button. |
newHandButton |
String
|
"#newHandButton"
|
The game's new hand button. |
totalBet |
String
|
"#totalBet"
|
The game's total bet amount display element. |
balance |
String
|
"#balance"
|
The remaining game balance amount display element. |
potAmount |
String
|
"#potAmount"
|
The game's pot amount input element. |
betAmount |
String
|
"#betAmount"
|
The game's bet amount input element. |
publicCards |
String
|
"#publicCards"
|
The game's public cards container element. |
privateCards |
String
|
"#privateCards"
|
The game's private cards container element. |
timeoutAmount |
String
|
"#timeoutAmount"
|
The game's timeout counter container element. |
|
- Source:
lobbyActive
Properties:
Name |
Type |
Default |
Description |
lobbyActive |
Boolean
|
false
|
True if the lobby interface is currently displayed and
enabled, otherwise false. Setting this value to true enables automatic table culling in the lobby. |
- Source:
(readonly) protoGameElement
Properties:
Name |
Type |
Description |
protoGameElement |
HTMLElement
|
A reference to the prototype element in which
the game user interface is contained, as set at instantiation time. This element will be
cloned for each new game instance. |
- Source:
(readonly) ready
Properties:
Name |
Type |
Default |
Description |
ready |
Boolean
|
false
|
Becomes true when the UI has completed loading and initializing
all data such as templates, configurations, etc. |
- Source:
selectedAccount
Properties:
Name |
Type |
Default |
Description |
selectedAccount |
CypherPokerAccount
|
null
|
The currently selected
CypherPokerAccount instance to use when creating or joining games.
Note that once created, a CypherPokerGame#account reference may be different
than this one. |
- Source:
templates
Properties:
Name |
Type |
Description |
templates |
Array
|
The indexed list of sucecssfully loaded, parsed,
and appended HTML templates as specified in the templates index JSON data.
In addition to containing a copy of that data, each element in the array also
contains a document property containing the original HTMLDocument
object of the template and a elements array which contains references
appended element(s), copied from the document within the main index HTML. |
- Source:
UISelectors
Properties:
Name |
Type |
Description |
UISelectors |
Object
|
Name/value pairs for general UI elements and their
associated CSS-style DOM selectors.
Properties
Name |
Type |
Default |
Description |
dialog |
String
|
"#mainDialog"
|
The main or primary dialog element. |
accounts |
String
|
"#accounts"
|
The main accounts container element. |
accountLoginForm |
String
|
"#accounts>#loginForm"
|
The main account login container element. |
accountManageForm |
String
|
"#accounts>#manageForm"
|
The main account management container element. |
accountCreateForm |
String
|
"#accounts>#createAccountForm"
|
The main account creation container element. |
clipboardData |
String
|
"#clipboardData"
|
Proxy data container for global clipboard copy commands. |
lobby |
String
|
"#lobby"
|
The main lobby container element. |
|
- Source:
Methods
addCypherPokerHandlers()
- Source:
addGameUIHandlers(gameElement, gameRef)
Parameters:
Name |
Type |
Description |
gameElement |
HTMLElement
|
The cloned game element to which to add handlers to. |
gameRef |
CypherPokerGame
|
A reference to the game instance associated with the
game element. |
- Source:
clearAccountsUI()
Clears any entries in the accounts list in the user interface. Note that this
function does not affect the
CypherPoker#accounts array.
- Source:
cloneElement(sourceElement, internalReferenceopt) → {HTMLElement}
Clones an HTML element, appends it to the DOM after the source element, and
sets an internal reference to the clone in the source. Use this function
to create copies of a dynamic template element that may change multiple times.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
sourceElement |
HTMLElement
|
|
|
The HTML element to clone. This element
will have an internal _clone reference to the cloned element. |
internalReference |
Boolean
|
<optional>
|
true
|
If true, the sourceElement
will store a refence to the new clonet within itself as a _clone
property so that it can be removed using removeClone. |
- Source:
Returns:
The cloned HTML element.
-
Type
-
HTMLElement
convertDenom(amount, fromDenom, toDenom) → {String}
Converts an amount from a specific denomination to a specific denomination
for display.
Parameters:
Name |
Type |
Description |
amount |
String
|
The amount to convert. |
fromDenom |
String
|
The source denomination. Valid values include:
"satoshi", "bitcoin" |
toDenom |
String
|
The target denomination. Valid values include:
"satoshi", "bitcoin" |
- Source:
Returns:
The amount
converted to from the source
denomination to the target denomination.
-
Type
-
String
disable(elementRef)
Disables a specific HTML element by adding a disabled="true"
attribute to it.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
enable(elementRef)
Enables a specific HTML element by removing the disabled
attribute from it.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
getGroupSelections(containerElement) → {Array}
Returns all of the selected radio button or checkbox elements contained in a specified
container.
Parameters:
- Source:
Returns:
Indexed list of all selected / checked radio buttons or checkboxes
(HTMLElement
objects). Note that radio buttons with the same
name
property are treated by the browser as a group and
will only allow one selection among them.
-
Type
-
Array
getTemplateByName(name) → {Object}
Returns a successfully loaded HTML template by its name from the
templates array.
Parameters:
Name |
Type |
Description |
name |
String
|
The HTML template name to reterieve, as specified in the associated
templates JSON data. |
- Source:
Returns:
The object containing data and references matching the specified template,
or null
if no matching template can be found.
-
Type
-
Object
hide(elementRef)
Hides a specific HTML element by adding a hidden="true"
attribute to it.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
hideDialog(delayopt, contextopt)
Hides the main dialog, as defined in
UISelectors.dialog
,
with an optional delay.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
delay |
Number
|
<optional>
|
0
|
The number of milliseconds to delay before closing the
dialog. |
context |
CypherPokerUI
|
<optional>
|
null
|
A reference to this instance, used in
conjunction with the hide delay. If null , this is
used as the default context. |
- Source:
(async) initialize()
Intializes the UI by loading defined templates and setting
the
ready flag to
true
.
- Source:
isHidden(elementRef) → {Boolean}
Checks if a specified element is hidden.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
Returns:
True if the element is hidden, false if it's visible
-
Type
-
Boolean
(async) loadTemplates(indexURLopt)
Loads and parses HTML templates for the application, then adds them to their
specified targets within the main page HTML. Every successfully loaded template
can be accessed via the
templates array or the
getTemplate function.
Note that templates are appended to their specified targets in the order listed.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
indexURL |
String
|
<optional>
|
"./templates/index.json"
|
The URL of the JSON file containing
the list of templates to load. |
- Source:
onPlayerJoinTable(event)
Event handler invoked when another player has joined a table that we've
joined.
Parameters:
- Source:
Listens to Events:
onPlayerLeaveTable(event)
Event handler invoked when another player has left a table that we've
joined.
Parameters:
- Source:
Listens to Events:
removeClone(sourceElement) → {Boolean}
Removes a cloned HTML element created by cloneElement with
internalReference=true
.
Parameters:
Name |
Type |
Description |
sourceElement |
HTMLElement
|
The soucre HTML element from which the
clone was created. This element must have an internal _clone
property. |
- Source:
Returns:
True if the cloned element could be properly removed.
-
Type
-
Boolean
resetLobbyUI(showOnResetopt)
Resets all of the user interface elements of the lobby to their initial
state, including input fields, announced tables list, etc.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
showOnReset |
Boolean
|
<optional>
|
true
|
If true, the interface is displayed
after being reset otherwise the elements must be shown manually. |
- Source:
show(elementRef)
Shows a specific HTML element by removing the hidden
attribute from it.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
showDialog(contentopt)
Displays the main dialog with any specified content.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
content |
String
|
<optional>
|
""
|
The HTML contents to display in the dialog. |
- Source:
startLobbyCull()
Starts the lobby table culling timer to remove inactive / invalid tables.
- Source:
stopLobbyCull()
Stops the lobby table culling timer if active.
- Source:
toggleShow(elementRef)
Toggles the visibility of a specific HTML element.
Parameters:
Name |
Type |
Description |
elementRef |
HTMLElement
|
String
|
A reference to the object or
a selector to query the document with. |
- Source:
updateJoinedTableStatus(metaData, showStatusopt)
Updates the "joinedTableStatus" HTML template's metatags and visibility.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
metaData |
Object
|
|
|
The template's metatags to parse. |
showStatus |
Boolean
|
<optional>
|
true
|
If true, any existing template clone is removed, the
original template is cloned, metatags parsed, and the clone appended to
the target location specified for the source HTML template. If false,
any existing template clone is simply removed. |
- Source: