content/hifi-public/PlanetDropBundle_v1/scripts/apiPrint.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

74 lines
1.5 KiB
JavaScript

// Allows parsing of HighFidelity API tree from within JS
// Len White 2015
// Defines a container for a class with member functions/variables
function HFClass(name)
{
this.name = name;
this.object = null;
this.members = [];
this.functions = [];
this.properties = [];
this.getString = function() {
var buffer = this.name + "\n";
for (var i = 0; i < this.members.length; i++ )
{
buffer += " " + this.members[i] + "\n";
}
return buffer;
};
}
// Returns class array
function buildApiCollection()
{
var HFClasses = [];
classKeys = Object.keys(this);
for (var i=0; i < classKeys.length; ++i)
{
var newClass = new HFClass(classKeys[i]);
var classObj = this[newClass.name];
newClass.object = classObj;
if (typeof(classObj) == "object")
HFClasses.push(newClass);
}
for (var i=0; i < HFClasses.length; i++)
{
var className = HFClasses[i].name;
var classObj = HFClasses[i].object;
var childKeys = Object.keys(classObj);
for (var j=0; j < childKeys.length; j++)
{
HFClasses[i].members.push(childKeys[j]);
}
HFClasses[i].members.sort();
}
return HFClasses;
}
// Returns display string of API
function createFormattedBuffer(classArray)
{
var buffer = "";
for (var i=0; i < classArray.length; i++)
{
buffer += classArray[i].getString();
}
return buffer;
}
// MAIN
var classes = [];
classes = buildApiCollection();
classes.sort(function(a,b) { return a.name.localeCompare(b.name); } );
var buffer = createFormattedBuffer(classes);
print("\n" + buffer);