Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.
andrew-smith edited this page Feb 10, 2012 · 3 revisions

The following specifies methods that you can call on the TUI object.

TUI.getTuiMeta ( tagname )

Gets the TUI meta content
tagname can be one of:

  • TUI.META_TUI_ID - to get the id of the current page
  • TUI.META_TUI_ID_PREFIX - to get the TUI prefix of the page
  • TUI.META_TUI_LIKE_COUNT - get total like count
  • TUI.META_TUI_DISLIKE_COUNT - get total dislike count

TUI.setTuiMeta ( tagname , content )

Sets the TUI meta content
tagname (see TUI.getTuiMeta)
content is the data you wish to place in this tag

Notifies listeners that the tag has been set

TUI.createTuiLike ( )

Creates a TUI like semantic message (based on the current page) and returns it

TUI.createTuiDislike ( )

Creates a TUI dislike semantic message (based on the current page) and returns it

TUI.createChangeTitleMessage ( newTitle )

Creates a TUI changeTitle semantic message (based on the current page) and returns it
newTitle the title you wish to suggest

TUI.createComment ( comment )

Creates a TUI comment semantic message (based on the current page) and returns it
comment the comment you wish to post

TUI.encodeTuiString ( str )

Encodes a TUI string based on the TUI string formatting format and returns it
str the string to encode

TUI.init ()

Initialises the TUI object. Should be called on page load and before you start working with this object.
When the TUI object is ready - it notifies all listeners subscribed with the TUI.onReady function.


Event Subscribing

The TUI object is not always ready to be accessed. It needs to load the id and id prefix and then functions will work as they should.
To handle this, you should subscribe to events so that if something changes - or when the TUI object is ready - you will know it is safe to work with it.

TUI.onReady ( f )

Called when the TUI object has loaded the libraries and set placeholder data in the elements.
Once this has been called you can safely work with TUI - although some data (like id and id prefix) may not be set. You should subscribe to the appropriate events in order to access the data.
f function() to be called when TUI is ready

TUI.onIDSet( f )

Called when the ID of the current page has been set.
f function() to be called when the ID has been set

TUI.onIDPrefixSet( f )

Called when the ID Prefix of the current page has been set.
f function() to be called when the ID Prefix has been set

TUI.onLikeCountChange( f )

Called when the like count changes. To access new count call: TUI.getTuiMeta(TUI.META_TUI_LIKE_COUNT)
f function() to be called when the like count changes

TUI.onDislikeCountChange( f )

Called when the dislike count changes. To access new count call: TUI.getTuiMeta(TUI.META_TUI_DISLIKE_COUNT)
f function() to be called when the dislike count changes