As a basic example, this first test page creates a singleton object called
alerter, this is initialised using an
init method to which you pass a name and a containing HTML element. Two methods can then be called to update the HTML element with “Hello” and “Goodbye” messages address to the name given in the
init method. The following screenshots should give you a better idea:
The page can be found here, and this is the output that you will see in Firebug:
To attach JSCT to the alerter object above, the following code was used:
<code>JSCT.setupTrace( [ 'alerter' ] );</code>
This works best when namespacing objects and methods. JSCT currently requires that the methods/objects that you’re registering are attached to the window object (i.e. essentially they need to be globally scoped) but this could be altered to fit requirements.
Together with the test page mentioned above, I’ve knocked up another two pages, please take a look and let me know your thoughts by adding comments to this page.