User:Gerbrant/mng/listModules.js

new function {	var globalScope = window; var frameworkObject = Gerbrant.fw; var namespaces = {};

//     --

var self = this; var myWin = null;

function dumpObject(buffer, name, obj) {		var i;

buffer.push(""); buffer.push(name); switch(typeof obj) {		case "object": buffer.push(""); for(i in obj) dumpObject(buffer, i, obj[i]); buffer.push(""); break; case "function": buffer.push(""); break; default: buffer.push(" = "); buffer.push(obj); buffer.push(""); }	}

function refreshWindow {		var buffer = [], i;		buffer.push(""); for(i in namespaces) dumpObject(buffer, i, namespaces[i]); buffer.push(""); myWin.setContentHTML(buffer.join("")); }

var oldLM = frameworkObject.module; var newLM = function(moduleName, callback) {		oldLM(moduleName, callback); var NN = moduleName.slice(0, moduleName.indexOf(".")); namespaces[NN] = globalScope[NN]; if(myWin != null) refreshWindow; }	frameworkObject.module = newLM; globalScope.module = newLM;

this.show = function {		if(myWin == null) myWin = new Gerbrant.gui.window("Modules"); refreshWindow; }	this.caption = "Modules";

loadModule("Gerbrant.gui.window", function	{		module("Gerbrant.mng.listModules", self);	}); }