Global

Aside from the functions defined for specific prototypes, it is also possible to define functions and macros (but not actions) in a global context. This is done by adding js-files to the directory [AppDir]/Global. The following example demonstrates the calling of a root and a global function from within a root action.

### Global/functions.js ### 
 
function foo() { 
  return "a global function"; 
} 
 
### Root/functions.js ### 
 
function foo() { 
  return "a root function"; 
} 
 
function main_action() { 
  res.write(root.foo() + " and " + foo()); 
}

A request to http://localhost:8080/appname/main will display the string 'a root function and a global function'. Note, that opposed to prototypes it does not make sense to define actions in a global context, since these can never be accessed via a request path.