Scanner
A basic script that recursively scans through the objects, properties and methods available in your context...
This script is a very basic demonstration of a Scriptix macro and outputs a hierarchical list of objects, properties and methods available to Scriptix.
In particular, this script shows how to generate raw wiki notation (in this case an un-ordered list) and then use the wiki sub-renderer to convert that notation in to XHTML.
Requirements
None.
Script
Name: export-scanner
Author(s): Guy Fraser
Scriptix Version: 1.0 or above
Scripting Engine: Mozilla Rhino
Components: subRenderer
Vectors: Wiki Macro
View source...
var output = '';
var scan = function(obj,star) {
if (star.length > 3) return; // prevent it going too deep
var i;
for (i in obj) {
output += star+' '+i+'\n';
arguments.callee(obj[i],star+'*');
}
}
scan(this,'*');
output = scriptix.subRenderer.render(output, macro.renderContext);
Known issues
- Can grind your server to a halt depending on level of recursion, etc. A simple depth limiter (defaults to 3 levels) has been added to reduce chances of this.
To-Do
It would be nice to do the following:
- Specify the depth as a parameter
- Find some way to easily limit execution time
- Have some way to pass in a param telling it where to start scanning from, eg. this.scriptix or this.user etc. Being JS if we could get that param we could easily eval it (although that could have security implications!) to get the reference to the object