The only web actions that the Node engine supports are
KRL actions for the Web primarily result in the DOM being changed in some way. Some of these actions are fairly simple, straightforward methods for manipulating the DOM. For example:
after(<selector>, <html>). This places the HTML fragment given by the second argument after the DOM element identified by the jQuery selector given as the first argument.
move_to_top(<selector>). This moves the item identified by the selector in the argument to the top of whatever container it's in.
Other actions are sophisticated, requiring coordination of resources and data across multiple rules and even rule sets. For example:
notify(<header>, <message>). This places a notification box on the page, similar to Growl notifications in OS X. Multiple notifications stack nicely.
Notify() has numerous options for controlling lifetime, styling, and placement. The following screenshot shows a simple notification box placed on a Web site (
annotate(<name>). This annotates a list (such as Google search results). Optional parameters provide a function for filtering which items are annotated, what the annotation looks like, and how the items are annotated. The following screenshot shows Google search results for "shoes" with AAA and Better Business Bureau reminders annotating some results.
The ability to interact with Web pages as they are rendered in the browser provides a powerful way of giving users important data in context. The annotations in the preceding screenshot provide important, valuable information to users right when they need it: as they search. This mashup of data from one or more services on a Web site the user cares about is an effective use for KRL.
watch(<selector>, <event>). Another Web-specific action that plays a key role in Web interactions is
watch() action attaches a listener to a browser event (don't confuse these with KRL events). The
watch() action provides salience information to the Web Runtime. When you watch, say, a form-submission button for a
submit event and the user clicks that button, the Web Runtime will raise a
web:submit event to KRE and any rules listening for that event will be selected.
The Web endpoint understands dozens of actions, some simple and others more complicated.
The following pages gives a complete description of each Web action: