User:Gerbrant/mng/listModules.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
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("<dt>"); buffer.push(name); switch(typeof obj) { case "object": buffer.push("</dt><dd><dl>"); for(i in obj) dumpObject(buffer, i, obj[i]); buffer.push("</dl></dd>"); break; case "function": buffer.push("()</dt>"); break; default: buffer.push(" = "); buffer.push(obj); buffer.push("</dt>"); } } function refreshWindow() { var buffer = [], i; buffer.push("<dl>"); for(i in namespaces) dumpObject(buffer, i, namespaces[i]); buffer.push("</dl>"); 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); }); }