Specifications
Chapter 3 Customizing How the Wiki Looks 49
To use this example JavaScript code, save it as a .js le in this folder:
/Library/Application Support/Apple/WikiServer/Themes/theme_name/
Shared Instances
The wiki server supports shared instances of a JavaScript class. A shared instance is an
instance of a class that can be referenced globally from anywhere in your theme.
You can create a shared instance of a class by calling Class.createWithSharedInstance
and providing a name for your new instance as a parameter. You can set whether the
instance is created when the page is loaded or the rst time the global is referenced.
The following provides the base code needed for shared instances:
var MyPluginClass = Class.createWithSharedInstance('myPluginClass',
true);
MyPluginClass.prototype =
{
initialize: function() {
// Add code here
}
}
The rst argument ('myPluginClass' above) is the name used to refer to the instance
of the class.
The second argument (true above) determines when the shared instance is
instantiated. If set to true, it is created when the page is loaded. If set to false, it is
created the rst time the instance is referenced.
Add your own code to dene the initialize method, which gets called when the class is
created. You can also add functions.
Notications
The wiki server supports notications. A notication is sent when specic events
happen on the client page such as when a tag is added or a comment is removed.
There are many system-dened notications to subscribe to. You can also publish your
own notications and subscribe to them elsewhere in your custom theme’s JavaScript.
By combining notications with shared instances, you can run custom JavaScript
functions triggered by events.
The wiki server publishes the following messages:
QUICKLOOK_DID_SHOW_PANEL Â
QUICKLOOK_DID_HIDE_PANEL Â
DID_START_EDITING Â