VoodooPad Events Explained
Events are a way for you to augment VoodooPad when various actions happen. For example there are events when a document is opened, a page is created or closed, and when a web export starts or finishes.
You can use page events to:
- Add extra text to a page when it is created.
- Check in your document to a source control system when it's closed.
- Add extra content to web exports, such as RSS feeds.
- Perform special scripts when certain pages are opened.
There are four special pages you can create in a document which help with these tasks:
- VPPageEventScript, where page events are written.
- VPDocumentEventScript, where document events are written.
- VPWebExportScript, where web export events are written.
- VPJSPrefixScript, which is a special page that is loaded before any of the other events are run. You can use this page to put common functions which are used for event scripts or scriptlets.
These pages don't exist automatically in a document, you'll have to create them first. But when you do make them, VoodooPad will fill in the page with a template to get things rolling for you.
Global Variables For the Events
Staring in VoodooPad 5.0.2, there is a single global variable that is common to all the event scripts, and that is the document object. It represents an instance of the document which is executing the event. You might notice that some event functions are already passed a document object (such as pageWasOpened). This is the exact same object as the global variable.