r20517: re-add cleaned-up webapps
[sfrench/samba-autobuild/.git] / webapps / qooxdoo-0.6.3-sdk / frontend / framework / source / class / qx / dev / Pollution.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
12
13    Authors:
14      * Sebastian Werner (wpbasti)
15      * Andreas Ecker (ecker)
16
17 ************************************************************************ */
18
19 /* ************************************************************************
20
21 #module(dev)
22
23 ************************************************************************ */
24
25 qx.OO.defineClass("qx.dev.Pollution");
26
27 qx.Class.names =
28 {
29   "window" : window,
30   "document" : document,
31   "body" : document.body
32 }
33
34 qx.Class.ignore =
35 {
36   "window" :
37   [
38     // Firefox
39     "__firebug__",
40     "Components",
41     "controllers",
42
43     // Firefox extension: Firebug
44     "console",
45
46     // IE
47     "event",
48     "offscreenBuffering",
49     "clipboardData",
50     "clientInformation",
51     "Option",
52     "Image",
53     "external",
54     "screenTop",
55     "screenLeft",
56
57     // Standard
58     "length",
59     "window",
60     "document",
61     "location",
62     "navigator",
63     "netscape",
64     "parent",
65     "frames",
66     "top",
67     "scrollbars",
68     "name",
69     "scrollX",
70     "scrollY",
71     "self",
72     "screen",
73     "history",
74     "content",
75     "menubar",
76     "toolbar",
77     "locationbar",
78     "personalbar",
79     "statusbar",
80     "directories",
81     "closed",
82     "crypto",
83     "pkcs11",
84     "opener",
85     "status",
86     "defaultStatus",
87     "innerWidth",
88     "innerHeight",
89     "outerWidth",
90     "outerHeight",
91     "screenX",
92     "screenY",
93     "pageXOffset",
94     "pageYOffset",
95     "scrollMaxX",
96     "scrollMaxY",
97     "fullScreen",
98     "frameElement"
99   ],
100
101   "document" :
102   [
103     "domConfig",
104     "location",
105     "compatMode",
106     "implementation",
107     "defaultView",
108     "title",
109     "body",
110     "styleSheets",
111     "documentElement",
112     "nodeName",
113     "nodeType",
114     "firstChild",
115     "lastChild",
116     "doctype",
117     "images",
118     "applets",
119     "links",
120     "forms",
121     "anchors",
122     "cookie",
123     "embeds",
124     "plugins",
125     "designMode",
126     "childNodes"
127   ],
128
129   "body" :
130   [
131     "textContent",
132     "innerHTML",
133     "outerHTML",
134     "innerText",
135     "outerText",
136     "scopeName",
137     "parentElement",
138     "tagName",
139     "filters",
140     "contentEditable",
141     "document",
142     "currentStyle",
143     "isMultiLine",
144     "clientHeight",
145     "clientWidth",
146
147     "lastChild",
148     "firstChild",
149     "offsetTop",
150     "offsetLeft",
151     "offsetWidth",
152     "offsetHeight",
153     "tabIndex",
154     "className",
155     "attributes",
156     "previousSibling",
157     "nextSibling",
158     "ownerDocument",
159     "localName",
160     "childNodes",
161     "parentNode",
162     "nodeType",
163     "nodeName",
164     "style",
165
166     "scrollTop",
167     "scrollLeft",
168     "scrollWidth",
169     "scrollHeight"
170   ]
171 }
172
173 qx.Class.consoleInfo = function(object)
174 {
175   alert("Global namespace is polluted by:\n\n" + qx.dev.Pollution.getTextList(object));
176 }
177
178 qx.Class.extract = function(object)
179 {
180   var ext = [];
181   var ign = qx.dev.Pollution.ignore[object];
182   var obj = qx.dev.Pollution.names[object];
183
184   for (var key in obj)
185   {
186     try
187     {
188       // Ignore null or undefined values
189       if (typeof obj[key] == "undefined" || obj[key] === null) {
190         continue;
191       }
192
193       // Ignore native code
194       if (typeof obj[key] == "function" && obj[key].toString().indexOf("[native code]") != -1) {
195         continue;
196       }
197
198       // Ignore if configured
199       if (qx.lang.Array.contains(ign, key)) {
200         continue;
201       }
202     }
203     catch(ex)
204     {
205       continue;
206     }
207
208     ext.push({ "key" : key, "value" : obj[key] });
209   }
210
211   return ext;
212 }
213
214 qx.Class.getHtmlTable = function(object)
215 {
216   var all = [];
217
218   var rowStart = "<tr style='vertical-align:top'><td>";
219   var cellSplit = "</td><td>";
220   var rowEnd = "</td></tr>";
221
222   all.push("<table>");
223
224   var ext = this.extract(object);
225
226   for (var i=0; i<ext.length; i++) {
227     all.push(rowStart + ext[i].key + cellSplit + ext[i].value + rowEnd);
228   }
229
230   all.push("</table>");
231
232   return all.join("");
233 }
234
235 qx.Class.getTextList = function(object)
236 {
237   var all = [];
238
239   var cellSplit = ": ";
240   var rowEnd = "\n";
241
242   var ext = this.extract(object);
243
244   for (var i=0; i<ext.length; i++) {
245     all.push(ext[i].key + cellSplit + ext[i].value + rowEnd);
246   }
247
248   return all.join("");
249 }