// object
var _objekt = app;
var _resultArray = [];
// hier wird Array mit den Werten von app gefüllt.
readObject(_objekt);
// nun durchlaufe ich das Array und prüfe, ob einer der Werte nach Split und Substring den Inhalt "object" hat.
for (x = 0; x < _resultArray.length; x++) {
try {
var tempResult = _resultArray[x].toString().split(" = ");
if (tempResult[1].substring(1,7) == "object") {
var subObjekt = tempResult[0].split(".");
// hier sollte eigentlich die Funktion erneut aufgerufen werden mit dem Parameter
readObject(_objekt+"."+subObjekt[1]);
}
} catch (e) {
alert(e);
}
}
// display properties
alert_scroll("Object properties", _resultArray.sort());
//Eigenschaften auslesen
function readObject (_objekt){
for (var i = 0; i < _objekt.reflect.properties.length; i++) {
var _property = _objekt.reflect.properties[i];
if (_property.toString() === "__proto__" || _property.toString() === "reflect" || _property.toString() === "properties") continue;
try { _result = _objekt[_property]; }
catch (e) { _result = "cannot read"; }
if (_result != null && _result.constructor.name === "Array") _resultArray.push(_objekt.constructor.name + "." + _property + " = [" + _result + "]");
else _resultArray.push(_objekt.constructor.name + "." + _property + " = " + _result);
}
}
// Scrollable alert function
function alert_scroll (title, input){
if (input instanceof Array)
input = input.join ("\r");
var w = new Window ("dialog", title);
var list = w.add ("edittext", undefined, input, {multiline: true, scrolling: true});
list.maximumSize.height = w.maximumSize.height-100;
list.minimumSize.width = 250;
w.add ("button", undefined, "Close", {name: "ok"});
w.show ();
}