Global

Methods

__(_msg, _formatopt)

Source

Logging function. To be used everywhere instead of console.log().

The name "__" is chosen to be short and clean. When visually scanning code it looks a bit like indentation so can help differentiate from normal non-logging lines of code.

With this function logging can be enabled/disabled via a query string parameter in the URL hash:

  • ?debug=true displays console output
  • ?debug=overlay displays console output and also displays output in a floating element (useful for logging to eg mobile browsers when we can't access developer tools easily)
  • If ?debug is missing or not set to any of the above values, logging is disabled
Parameters
Name Type Attributes Description
_msg String

Message to be logged to console and/or printed to screen

_format String optional

CSS style to apply to message

importHashParamsTo(_ob)

Source

Process the URL location.hash to import variables into the app

Parameters
Name Type Description
_ob Object

Info about how to process the query string

Name Type Attributes Description
recipient_ob Object

Object which will receive the parameters

filter_ar Array.<String> optional

List of parameters to be accepted (any others are ignored)

setHashParam(_fullParams_ar, _name, _valueopt)

Source

Add or remove a parameter in the location.hash portion of the URL

Parameters
Name Type Attributes Description
_fullParams_ar String

An array of all params accepted by the app (same as passed to importHashParamsTo()). This will be used to order the parameters in the re-written hash.

_name String

The parameter name

_value String optional

The parameter value, if missing or undefined the parameter will be omitted

_values of true or 'true' are treated as a special case, and in the re-written hash they will be left empty eg &item=true becomes &item. This is to keep the hash short and friendly, as in this game people may want to share URLs or edit them eg to jump to a specific level.

To reiterate the above:

Although the re-written hash will omit trues, when calling this function if you want true you must pass _value as true. An omitted _value is taken to mean the parameter should be deleted.