JavaScript API

Search:

Welcome

Login to contribute. Register if you haven't yet.

Need Support?

Search this site to find an answer. If you still need help, post a Question. Private or account-related support inquiries can be made at the Private Support forum.

JavaScript API

Return to Developer Support 

EditMe's Layouts use a combination of layout commands and JavaScript to provide dynamic behavior, such as listing the comments on a page, or only showing a login form for anonymous users.

Similarities and Differences to Browser-based JavaScript 

EditMe's JavaScript implementation is based on Mozilla's Rhino JavaScript engine. All of the basic language features such as the literal types, functions, and the core classes of Array, Boolean, Date, etc. are available. Mozilla's JavaScript 1.5 Guide is the best reference to use. Parts of this guide do cover language features unavailable in EditMe, however, such as E4X and most of LiveConnect.

The implicit objects provided by EditMe differ from objects made available by a web browser. For example the "document" and "window" objects are not available. EditMe does provide access to the layout content via an XML API called DOM4J, however. Its important to remember that JavaScript in an EditMe layout is running on the server, much like ASP or PHP. Most JavaScript developers are accustomed to writing code for the client, or browser, environment. 

Implicit Objects 

An implicit object is a variable that is made available by EditMe's Layout engine. While you can write JavaScript to create your own variables using the classes provided or those you create, implicit variables are already declared and set for you.

EditMe provides the following implicit variables. Click the linked class names to see the methods and properties available for each.

Variable Name  Type  Value 
attachments Array of Attachment
An array of the visible attachments for the current page in alphabetic order.
comments Array of Comment
An array of comments for the current page in chronological order.
data  Data  An instance of the Data class that can be used to store and retrieve arbitrary textual data by key.
layout Page
The layout that is being processed. The XML document that makes up the layout is available at layout.document.
page Page The page that was requested by the browser.
server Server
An instance of the Server class, which provides access to  things like request parameters, cookies, etc.
site Site
An instance of the Site class,which provides access to various site settings.
stylesheet String A string containing the name of the CSS style sheet being applied to the requested page.
user User
An instance of the User class representing the currently logged in user. If the user is not logged in, this object represents the anonymous user.
util
Util An instance of the Util class, which provides access to utility methods such as URL encoding and decoding.

Classes 

The following classes are made available by EditMe. While none of these can be directly instantiated using the "new" keyword, they can be accessed via the implicit variables discussed above. Click one of the class names for a full listing of methods and properties. 

  • Attachment - represents a file attached to a page.
  • Comment - represents a comment on a page.
  • Data - represents a name/value pair data structure and provides data query functions.
  • Email - sends an email message.
  • Group - represents a User Group.
  • Page - represents a Page of content.
  • Policy - represents a Security Policy.
  • Server - functions related to the server.
  • Site - access to site settings and data.
  • User - represents a Registered or Administrator User.
  • Util - miscellaneous utility functions.