1 |
62654413
|
Scott Ullrich
|
/**
|
2 |
|
|
* firebug lite <http://www.getfirebug.com/lite.html>
|
3 |
|
|
* v1.0
|
4 |
|
|
* 04.11.2008, 8:25 PM ~
|
5 |
|
|
* v1.0a
|
6 |
|
|
* 03.27.2008, 5:44 AM ~ 04.01.2008, 21:32 PM
|
7 |
|
|
* Azer Koçulu <http://azer.kodfabrik.com>
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
var firebug = {
|
11 |
|
|
env:{ "cache":{}, "ctmp":[], "dIndex":"console", "init":false, "ml":false, "objCn":[] },
|
12 |
|
|
init:function(){
|
13 |
|
|
firebug.el = {}; // elements
|
14 |
|
|
firebug.el.content = {};
|
15 |
|
|
with(firebug){
|
16 |
|
|
|
17 |
|
|
document.documentElement.childNodes[0].appendChild(
|
18 |
|
|
new pi.element("link").attribute.set("rel","stylesheet").attribute.set("href","http://firebuglite.appspot.com/firebug-lite.css").environment.getElement()
|
19 |
|
|
);
|
20 |
|
|
|
21 |
|
|
/*
|
22 |
|
|
* main interface
|
23 |
|
|
*/
|
24 |
|
|
el.main = new pi.element("DIV").attribute.set("id","Firebug").environment.addStyle({ "width":pi.util.GetWindowSize().width+"px" }).insert(document.body);
|
25 |
|
|
el.header = new pi.element("DIV").attribute.addClass("Header").insert(el.main);
|
26 |
|
|
el.left = {};
|
27 |
|
|
el.left.container = new pi.element("DIV").attribute.addClass("Left").insert(el.main);
|
28 |
|
|
el.right = {};
|
29 |
|
|
el.right.container = new pi.element("DIV").attribute.addClass("Right").insert(el.main);
|
30 |
|
|
el.main.child.add(new pi.element("DIV").environment.addStyle({ "clear":"both" }));
|
31 |
|
|
|
32 |
|
|
/*
|
33 |
|
|
* buttons
|
34 |
|
|
*/
|
35 |
|
|
el.button = {};
|
36 |
|
|
el.button.container = new pi.element("DIV").attribute.addClass("ButtonContainer").insert(el.header);
|
37 |
|
|
el.button.logo = new pi.element("A").attribute.set("title","Firebug Lite").attribute.set("target","_blank").attribute.set("href","http://getfirebug.com/lite.html").update(" ").attribute.addClass("Button Logo").insert(el.button.container);
|
38 |
|
|
el.button.inspect = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.inspector.toggle).update("Inspect").insert(el.button.container);
|
39 |
|
|
el.button.maximize = new pi.element("A").attribute.addClass("Button Maximize").event.addListener("click",win.maximize).insert(el.button.container);
|
40 |
|
|
el.button.minimize = new pi.element("A").attribute.addClass("Button Minimize").event.addListener("click",win.minimize).insert(el.button.container);
|
41 |
|
|
el.button.close = new pi.element("A").attribute.addClass("Button Close").event.addListener("click",win.close).insert(el.button.container);;
|
42 |
|
|
|
43 |
|
|
if(pi.env.ie||pi.env.webkit){
|
44 |
|
|
el.button.container.environment.addStyle({ "paddingTop":"12px" });
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/*
|
48 |
|
|
* navigation
|
49 |
|
|
*/
|
50 |
|
|
el.nav = {};
|
51 |
|
|
el.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.left.container);
|
52 |
|
|
el.nav.console = new pi.element("A").attribute.addClass("Tab Selected").event.addListener("click",d.navigate.curry(window,"console")).update("Console").insert(el.nav.container);
|
53 |
|
|
el.nav.html = new pi.element("A").attribute.addClass("Tab").update("HTML").event.addListener("click",d.navigate.curry(window,"html")).insert(el.nav.container);
|
54 |
|
|
el.nav.css = new pi.element("A").attribute.addClass("Tab").update("CSS").event.addListener("click",d.navigate.curry(window,"css")).insert(el.nav.container);
|
55 |
|
|
el.nav.scripts = new pi.element("A").attribute.addClass("Tab").update("Script").event.addListener("click",d.navigate.curry(window,"scripts")).insert(el.nav.container);
|
56 |
|
|
el.nav.dom = new pi.element("A").attribute.addClass("Tab").update("DOM").event.addListener("click",d.navigate.curry(window,"dom")).insert(el.nav.container);
|
57 |
|
|
el.nav.xhr = new pi.element("A").attribute.addClass("Tab").update("XHR").event.addListener("click",d.navigate.curry(window,"xhr")).insert(el.nav.container);
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* inspector
|
61 |
|
|
*/
|
62 |
|
|
|
63 |
|
|
el.borderInspector = new pi.element("DIV").attribute.set("id","FirebugBorderInspector").event.addListener("click",listen.inspector).insert(document.body);
|
64 |
|
|
el.bgInspector = new pi.element("DIV").attribute.set("id","FirebugBGInspector").insert(document.body);
|
65 |
|
|
|
66 |
|
|
/*
|
67 |
|
|
* console
|
68 |
|
|
*/
|
69 |
|
|
el.left.console = {};
|
70 |
|
|
el.left.console.container = new pi.element("DIV").attribute.addClass("Console").insert(el.left.container);
|
71 |
|
|
el.left.console.mlButton = new pi.element("A").attribute.addClass("MLButton").event.addListener("click",d.console.toggleML).insert(el.left.console.container);
|
72 |
|
|
el.left.console.monitor = new pi.element("DIV").insert(
|
73 |
|
|
new pi.element("DIV").attribute.addClass("Monitor").insert(el.left.console.container)
|
74 |
|
|
);
|
75 |
|
|
el.left.console.container.child.add(
|
76 |
|
|
new pi.element("DIV").attribute.addClass("InputArrow").update(">>>")
|
77 |
|
|
);
|
78 |
|
|
el.left.console.input = new pi.element("INPUT").attribute.set("type","text").attribute.addClass("Input").event.addListener("keydown",listen.consoleTextbox).insert(
|
79 |
|
|
new pi.element("DIV").attribute.addClass("InputContainer").insert(el.left.console.container)
|
80 |
|
|
);
|
81 |
|
|
|
82 |
|
|
el.right.console = {};
|
83 |
|
|
el.right.console.container = new pi.element("DIV").attribute.addClass("Console Container").insert(el.right.container);
|
84 |
|
|
el.right.console.mlButton = new pi.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.console.container);
|
85 |
|
|
el.right.console.input = new pi.element("TEXTAREA").attribute.addClass("Input").insert(el.right.console.container);
|
86 |
|
|
el.right.console.run = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.runMultiline).update("Run").insert(el.right.console.container);
|
87 |
|
|
|
88 |
|
|
el.right.console.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.right.console.input)).update("Clear").insert(el.right.console.container);
|
89 |
|
|
|
90 |
|
|
el.button.console = {};
|
91 |
|
|
el.button.console.container = new pi.element("DIV").attribute.addClass("ButtonSet").insert(el.button.container);
|
92 |
|
|
el.button.console.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.left.console.monitor)).update("Clear").insert(el.button.console.container);
|
93 |
|
|
|
94 |
|
|
/*
|
95 |
|
|
* html
|
96 |
|
|
*/
|
97 |
|
|
|
98 |
|
|
el.left.html = {};
|
99 |
|
|
el.left.html.container = new pi.element("DIV").attribute.addClass("HTML").insert(el.left.container);
|
100 |
|
|
|
101 |
|
|
el.right.html = {};
|
102 |
|
|
el.right.html.container = new pi.element("DIV").attribute.addClass("HTML Container").insert(el.right.container);
|
103 |
|
|
|
104 |
|
|
el.right.html.nav = {};
|
105 |
|
|
el.right.html.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.right.html.container);
|
106 |
|
|
el.right.html.nav.computedStyle = new pi.element("A").attribute.addClass("Tab Selected").event.addListener("click",d.html.navigate.curry(firebug,"computedStyle")).update("Computed Style").insert(el.right.html.nav.container);
|
107 |
|
|
if(!pi.env.ie6)
|
108 |
|
|
el.right.html.nav.dom = new pi.element("A").attribute.addClass("Tab").event.addListener("click",d.html.navigate.curry(firebug,"dom")).update("DOM").insert(el.right.html.nav.container);
|
109 |
|
|
|
110 |
|
|
el.right.html.content = new pi.element("DIV").attribute.addClass("Content").insert(el.right.html.container);
|
111 |
|
|
|
112 |
|
|
el.button.html = {};
|
113 |
|
|
el.button.html.container = new pi.element("DIV").attribute.addClass("ButtonSet HTML").insert(el.button.container);
|
114 |
|
|
|
115 |
|
|
/*
|
116 |
|
|
* css
|
117 |
|
|
*/
|
118 |
|
|
|
119 |
|
|
el.left.css = {};
|
120 |
|
|
el.left.css.container = new pi.element("DIV").attribute.addClass("CSS").insert(el.left.container);
|
121 |
|
|
|
122 |
|
|
el.right.css = {};
|
123 |
|
|
el.right.css.container = new pi.element("DIV").attribute.addClass("CSS Container").insert(el.right.container);
|
124 |
|
|
|
125 |
|
|
el.right.css.nav = {};
|
126 |
|
|
el.right.css.nav.container = new pi.element("DIV").attribute.addClass("Nav").insert(el.right.css.container);
|
127 |
|
|
el.right.css.nav.runCSS = new pi.element("A").attribute.addClass("Tab Selected").update("Run CSS").insert(el.right.css.nav.container);
|
128 |
|
|
|
129 |
|
|
el.right.css.mlButton = new pi.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.css.container);
|
130 |
|
|
el.right.css.input = new pi.element("TEXTAREA").attribute.addClass("Input").insert(el.right.css.container);
|
131 |
|
|
el.right.css.run = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.runCSS).update("Run").insert(el.right.css.container);
|
132 |
|
|
el.right.css.clear = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.clean.curry(window,el.right.css.input)).update("Clear").insert(el.right.css.container);
|
133 |
|
|
|
134 |
|
|
el.button.css = {};
|
135 |
|
|
el.button.css.container = new pi.element("DIV").attribute.addClass("ButtonSet CSS").insert(el.button.container);
|
136 |
|
|
el.button.css.selectbox = new pi.element("SELECT").event.addListener("change",listen.cssSelectbox).insert(el.button.css.container);
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* scripts
|
140 |
|
|
*/
|
141 |
|
|
|
142 |
|
|
el.left.scripts = {};
|
143 |
|
|
el.left.scripts.container = new pi.element("DIV").attribute.addClass("Scripts").insert(el.left.container);
|
144 |
|
|
|
145 |
|
|
el.right.scripts = {};
|
146 |
|
|
el.right.scripts.container = new pi.element("DIV").attribute.addClass("Scripts Container").insert(el.right.container);
|
147 |
|
|
|
148 |
|
|
el.button.scripts = {};
|
149 |
|
|
el.button.scripts.container = new pi.element("DIV").attribute.addClass("ButtonSet Scripts").insert(el.button.container);
|
150 |
|
|
el.button.scripts.selectbox = new pi.element("SELECT").event.addListener("change",listen.scriptsSelectbox).insert(el.button.scripts.container);
|
151 |
|
|
el.button.scripts.lineNumbers = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.scripts.toggleLineNumbers).update("Show Line Numbers").insert(el.button.scripts.container);
|
152 |
|
|
|
153 |
|
|
/*
|
154 |
|
|
* dom
|
155 |
|
|
*/
|
156 |
|
|
|
157 |
|
|
el.left.dom = {};
|
158 |
|
|
el.left.dom.container = new pi.element("DIV").attribute.addClass("DOM").insert(el.left.container);
|
159 |
|
|
|
160 |
|
|
el.right.dom = {};
|
161 |
|
|
el.right.dom.container = new pi.element("DIV").attribute.addClass("DOM Container").insert(el.right.container);
|
162 |
|
|
|
163 |
|
|
el.button.dom = {};
|
164 |
|
|
el.button.dom.container = new pi.element("DIV").attribute.addClass("ButtonSet DOM").insert(el.button.container);
|
165 |
|
|
el.button.dom.label = new pi.element("LABEL").update("Object Path:").insert(el.button.dom.container);
|
166 |
|
|
el.button.dom.textbox = new pi.element("INPUT").event.addListener("keydown",listen.domTextbox).update("window").insert(el.button.dom.container);
|
167 |
|
|
|
168 |
|
|
/*
|
169 |
|
|
* str
|
170 |
|
|
*/
|
171 |
|
|
|
172 |
|
|
el.left.str = {};
|
173 |
|
|
el.left.str.container = new pi.element("DIV").attribute.addClass("STR").insert(el.left.container);
|
174 |
|
|
|
175 |
|
|
el.right.str = {};
|
176 |
|
|
el.right.str.container = new pi.element("DIV").attribute.addClass("STR").insert(el.left.container);
|
177 |
|
|
|
178 |
|
|
el.button.str = {};
|
179 |
|
|
el.button.str.container = new pi.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
|
180 |
|
|
el.button.str.watch = new pi.element("A").attribute.addClass("Button").event.addListener("click",d.navigate.curry(window,"xhr")).update("Back").insert(el.button.str.container);
|
181 |
|
|
|
182 |
|
|
/*
|
183 |
|
|
* xhr
|
184 |
|
|
*/
|
185 |
|
|
|
186 |
|
|
el.left.xhr = {};
|
187 |
|
|
el.left.xhr.container = new pi.element("DIV").attribute.addClass("XHR").insert(el.left.container);
|
188 |
|
|
|
189 |
|
|
el.right.xhr = {};
|
190 |
|
|
el.right.xhr.container = new pi.element("DIV").attribute.addClass("XHR").insert(el.left.container);
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
el.button.xhr = {};
|
194 |
|
|
el.button.xhr.container = new pi.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
|
195 |
|
|
el.button.xhr.label = new pi.element("LABEL").update("XHR Path:").insert(el.button.xhr.container);
|
196 |
|
|
el.button.xhr.textbox = new pi.element("INPUT").event.addListener("keydown",listen.xhrTextbox).insert(el.button.xhr.container);
|
197 |
|
|
el.button.xhr.watch = new pi.element("A").attribute.addClass("Button").event.addListener("click",listen.addXhrObject).update("Watch").insert(el.button.xhr.container);
|
198 |
|
|
|
199 |
|
|
// fix ie6 a:hover bug
|
200 |
|
|
if(pi.env.ie6)
|
201 |
|
|
{
|
202 |
|
|
var buttons = [
|
203 |
|
|
el.button.inspect,
|
204 |
|
|
el.button.close,
|
205 |
|
|
el.button.inspect,
|
206 |
|
|
el.button.console.clear,
|
207 |
|
|
el.right.console.run,
|
208 |
|
|
el.right.console.clear,
|
209 |
|
|
el.right.css.run,
|
210 |
|
|
el.right.css.clear
|
211 |
|
|
];
|
212 |
|
|
for(var i=0; i<buttons.length; i++)
|
213 |
|
|
buttons[i].attribute.set("href","#");
|
214 |
|
|
}
|
215 |
|
|
//
|
216 |
|
|
|
217 |
|
|
env.init = true;
|
218 |
|
|
|
219 |
|
|
for(var i=0; i<env.ctmp.length; i++)
|
220 |
|
|
{
|
221 |
|
|
d.console.log.apply(window,env.ctmp[i]);
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
},
|
225 |
|
|
win:{
|
226 |
|
|
close:function(){
|
227 |
|
|
with(firebug){
|
228 |
|
|
el.main.update("");
|
229 |
|
|
el.main.remove();
|
230 |
|
|
}
|
231 |
|
|
},
|
232 |
|
|
minimize:function(){
|
233 |
|
|
with(firebug){
|
234 |
|
|
el.main.environment.addStyle({ "height":"35px" });
|
235 |
|
|
el.button.maximize.environment.addStyle({ "display":"block" });
|
236 |
|
|
el.button.minimize.environment.addStyle({ "display":"none" });
|
237 |
|
|
d.refreshSize();
|
238 |
|
|
}
|
239 |
|
|
},
|
240 |
|
|
maximize:function(){
|
241 |
|
|
with(firebug){
|
242 |
|
|
el.main.environment.addStyle({ "height":"295px" });
|
243 |
|
|
el.button.minimize.environment.addStyle({ "display":"block" });
|
244 |
|
|
el.button.maximize.environment.addStyle({ "display":"none" });
|
245 |
|
|
d.refreshSize();
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
},
|
249 |
|
|
watchXHR:function(){
|
250 |
|
|
with(firebug){
|
251 |
|
|
d.xhr.addObject.apply(window,arguments);
|
252 |
|
|
if(env.dIndex!="xhr"){
|
253 |
|
|
d.navigate("xhr");
|
254 |
|
|
}
|
255 |
|
|
}
|
256 |
|
|
},
|
257 |
|
|
d: {
|
258 |
|
|
clean:function(_element){
|
259 |
|
|
with(firebug){
|
260 |
|
|
_element.update("");
|
261 |
|
|
}
|
262 |
|
|
},
|
263 |
|
|
console:{
|
264 |
|
|
dir:function(_value){
|
265 |
|
|
with(firebug){
|
266 |
|
|
d.console.addLine().attribute.addClass("Arrow").update(">>> console.dir("+_value+")");
|
267 |
|
|
d.dom.open(_value,d.console.addLine());
|
268 |
|
|
}
|
269 |
|
|
},
|
270 |
|
|
addLine:function(){
|
271 |
|
|
with (firebug) {
|
272 |
|
|
return new pi.element("DIV").attribute.addClass("Row").insert(el.left.console.monitor);
|
273 |
|
|
}
|
274 |
|
|
},
|
275 |
|
|
openObject:function(_index){
|
276 |
|
|
with (firebug) {
|
277 |
|
|
d.dom.open(env.objCn[_index], el.left.dom.container, pi.env.ie);
|
278 |
|
|
d.navigate("dom");
|
279 |
|
|
}
|
280 |
|
|
},
|
281 |
|
|
historyIndex:0,
|
282 |
|
|
history:[],
|
283 |
|
|
log:function(_values){
|
284 |
|
|
with (firebug) {
|
285 |
|
|
if(env.init==false){
|
286 |
|
|
env.ctmp.push(arguments);
|
287 |
|
|
return;
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
var value = "";
|
291 |
|
|
for(var i=0; i<arguments.length; i++){
|
292 |
|
|
value += (i>0?" ":"")+d.highlight(arguments[i],false,false,true);
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
d.console.addLine().update(value);
|
296 |
|
|
d.console.scroll();
|
297 |
|
|
|
298 |
|
|
}
|
299 |
|
|
},
|
300 |
|
|
print: function(_cmd,_text){
|
301 |
|
|
with (firebug){
|
302 |
|
|
d.console.addLine().attribute.addClass("Arrow").update(">>> "+_cmd);
|
303 |
|
|
d.console.addLine().update(d.highlight(_text,false,false,true));
|
304 |
|
|
d.console.scroll();
|
305 |
|
|
d.console.historyIndex = d.console.history.push(_cmd);
|
306 |
|
|
}
|
307 |
|
|
},
|
308 |
|
|
run:function(cmd){
|
309 |
|
|
with(firebug){
|
310 |
|
|
if(cmd.length==0)return;
|
311 |
|
|
el.left.console.input.environment.getElement().value = "";
|
312 |
|
|
try {
|
313 |
|
|
var result = eval.call(window,cmd);
|
314 |
|
|
d.console.print(cmd,result);
|
315 |
|
|
} catch(e){
|
316 |
|
|
d.console.addLine().attribute.addClass("Arrow").update(">>> "+cmd);
|
317 |
|
|
if(!pi.env.ff){
|
318 |
|
|
d.console.scroll();
|
319 |
|
|
return d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+(e.description||e),true);
|
320 |
|
|
}
|
321 |
|
|
if(e.fileName==null){
|
322 |
|
|
d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+e.message,true);
|
323 |
|
|
}
|
324 |
|
|
var fileName = e.fileName.split("\/").getLastItem();
|
325 |
|
|
d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+e.message+" (<em>"+fileName+"</em>,"+e.lineNumber+")",true);
|
326 |
|
|
d.console.scroll();
|
327 |
|
|
}
|
328 |
|
|
d.console.scroll();
|
329 |
|
|
}
|
330 |
|
|
},
|
331 |
|
|
scroll:function(){
|
332 |
|
|
with(firebug){
|
333 |
|
|
el.left.console.monitor.environment.getElement().parentNode.scrollTop = Math.abs(el.left.console.monitor.environment.getSize().offsetHeight-200);
|
334 |
|
|
}
|
335 |
|
|
},
|
336 |
|
|
toggleML:function(){
|
337 |
|
|
with(firebug){
|
338 |
|
|
var open = !env.ml;
|
339 |
|
|
env.ml = !env.ml;
|
340 |
|
|
d.navigateRightColumn("console",open);
|
341 |
|
|
el[open?"left":"right"].console.mlButton.environment.addStyle({ display:"none" });
|
342 |
|
|
el[!open?"left":"right"].console.mlButton.environment.addStyle({ display:"block" });
|
343 |
|
|
el.left.console.monitor.environment.addStyle({ "height":(open?233:210)+"px" });
|
344 |
|
|
el.left.console.mlButton.attribute[(open?"add":"remove")+"Class"]("CloseML");
|
345 |
|
|
}
|
346 |
|
|
}
|
347 |
|
|
},
|
348 |
|
|
css:{
|
349 |
|
|
index:-1,
|
350 |
|
|
open:function(_index){
|
351 |
|
|
with (firebug) {
|
352 |
|
|
var item = document.styleSheets[_index];
|
353 |
|
|
var uri = item.href;
|
354 |
|
|
if(uri.indexOf("http:\/\/")>-1&&getDomain(uri)!=document.domain){
|
355 |
|
|
el.left.css.container.update("<em>Access to restricted URI denied</em>");
|
356 |
|
|
return;
|
357 |
|
|
}
|
358 |
|
|
var rules = item[pi.env.ie ? "rules" : "cssRules"];
|
359 |
|
|
var str = "";
|
360 |
|
|
for (var i=0; i<rules.length; i++) {
|
361 |
|
|
var item = rules[i];
|
362 |
|
|
var selector = item.selectorText;
|
363 |
|
|
var cssText = pi.env.ie?item.style.cssText:item.cssText.match(/\{(.*)\}/)[1];
|
364 |
|
|
str+=d.css.printRule(selector, cssText.split(";"), el.left.css.container);
|
365 |
|
|
}
|
366 |
|
|
el.left.css.container.update(str);
|
367 |
|
|
}
|
368 |
|
|
},
|
369 |
|
|
printRule:function(_selector,_css,_layer){
|
370 |
|
|
with(firebug){
|
371 |
|
|
var str = "<div class='Selector'>"+_selector+" {</div>";
|
372 |
|
|
for(var i=0; i<_css.length; i++){
|
373 |
|
|
var item = _css[i];
|
374 |
|
|
str += "<div class='CSSText'>"+item.replace(/(.+\:)(.+)/,"<span class='CSSProperty'>$1</span><span class='CSSValue'>$2;</span>")+"</div>";
|
375 |
|
|
}
|
376 |
|
|
str+="<div class='Selector'>}</div>";
|
377 |
|
|
return str;
|
378 |
|
|
}
|
379 |
|
|
},
|
380 |
|
|
refresh:function(){
|
381 |
|
|
with(firebug){
|
382 |
|
|
el.button.css.selectbox.update("");
|
383 |
|
|
var collection = document.styleSheets;
|
384 |
|
|
for(var i=0; i<collection.length; i++){
|
385 |
|
|
var uri = collection[i].href;
|
386 |
|
|
d.css.index=d.css.index<0?i:d.css.index;
|
387 |
|
|
el.button.css.selectbox.child.add(
|
388 |
|
|
new pi.element("OPTION").attribute.set("value",i).update(uri)
|
389 |
|
|
)
|
390 |
|
|
};
|
391 |
|
|
d.css.open(d.css.index);
|
392 |
|
|
}
|
393 |
|
|
}
|
394 |
|
|
},
|
395 |
|
|
dom: {
|
396 |
|
|
open: function(_object,_layer){
|
397 |
|
|
with (firebug) {
|
398 |
|
|
_layer.clean();
|
399 |
|
|
var container = new pi.element("DIV").attribute.addClass("DOMContent").insert(_layer);
|
400 |
|
|
d.dom.print(_object, container);
|
401 |
|
|
}
|
402 |
|
|
},
|
403 |
|
|
print:function(_object,_parent, _inTree){
|
404 |
|
|
with (firebug) {
|
405 |
|
|
var obj = _object || window, parentElement = _parent;
|
406 |
|
|
parentElement.update("");
|
407 |
|
|
|
408 |
|
|
if(parentElement.opened&&parentElement!=el.left.dom.container){
|
409 |
|
|
parentElement.environment.getParent().pi.child.get()[0].pi.child.get()[0].pi.attribute.removeClass("Opened");
|
410 |
|
|
parentElement.opened = false;
|
411 |
|
|
parentElement.environment.addStyle({ "display":"none" });
|
412 |
|
|
return;
|
413 |
|
|
}
|
414 |
|
|
if(_inTree)
|
415 |
|
|
parentElement.environment.getParent().pi.child.get()[0].pi.child.get()[0].pi.attribute.addClass("Opened");
|
416 |
|
|
parentElement.opened = true;
|
417 |
|
|
|
418 |
|
|
for (var key in obj) {
|
419 |
|
|
try {
|
420 |
|
|
|
421 |
|
|
var value = obj[key], property = key, container = new pi.element("DIV").attribute.addClass("DOMRow").insert(parentElement),
|
422 |
|
|
left = new pi.element("DIV").attribute.addClass("DOMRowLeft").insert(container), right = new pi.element("DIV").attribute.addClass("DOMRowRight").insert(container);
|
423 |
|
|
|
424 |
|
|
container.child.add(
|
425 |
|
|
new pi.element("DIV").environment.addStyle({ "clear":"both" })
|
426 |
|
|
);
|
427 |
|
|
|
428 |
|
|
var link = new pi.element("A").attribute.addClass(
|
429 |
|
|
typeof value=="object"&&Boolean(value)?"Property Object":"Property"
|
430 |
|
|
).update(property).insert(left);
|
431 |
|
|
|
432 |
|
|
right.update(
|
433 |
|
|
d.highlight(value,false,true)
|
434 |
|
|
);
|
435 |
|
|
|
436 |
|
|
var subContainer = new pi.element("DIV").attribute.addClass("DOMRowSubContainer").insert(container);
|
437 |
|
|
|
438 |
|
|
if(typeof value!="object"||Boolean(value)==false)
|
439 |
|
|
continue;
|
440 |
|
|
|
441 |
|
|
link.event.addListener("click",d.dom.print.curry(window,value, subContainer, true));
|
442 |
|
|
}catch(e){
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
|
|
parentElement.environment.addStyle({ "display":"block" });
|
446 |
|
|
}
|
447 |
|
|
}
|
448 |
|
|
},
|
449 |
|
|
highlight:function(_value,_inObject,_inArray,_link){
|
450 |
|
|
with(firebug){
|
451 |
|
|
var isArray = false, isElement = false;
|
452 |
|
|
try {
|
453 |
|
|
isArray = pi.util.IsArray(_value);
|
454 |
|
|
isElement = _value!=undefined&&Boolean(_value.nodeName)&&Boolean(_value.nodeType);
|
455 |
|
|
}catch(e){};
|
456 |
|
|
|
457 |
|
|
// number, string, boolean, null, function
|
458 |
|
|
if(_value==null||["boolean","function","number","string"].indexOf(typeof _value)>-1){
|
459 |
|
|
// NULL
|
460 |
|
|
if(_value==null){
|
461 |
|
|
return "<span class='Null'>null</span>";
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
// BOOLEAN & NUMBER
|
465 |
|
|
if (["boolean", "number"].indexOf(typeof _value) > -1) {
|
466 |
|
|
return "<span class='DarkBlue'>" + _value + "</span>";
|
467 |
|
|
}
|
468 |
|
|
|
469 |
|
|
// FUNCTION
|
470 |
|
|
if(typeof _value=="function"){
|
471 |
|
|
return "<span class='"+(_inObject?"Italic Gray":"Green")+"'>function()</span>";
|
472 |
|
|
}
|
473 |
|
|
|
474 |
|
|
// STRING
|
475 |
|
|
return "<span class='Red'>\""+( !_inObject&&!_inArray?_value : _value.substring(0,35) ).replace(/\n/g,"\\n").replace(/\s/g," ").replace(/>/g,">").replace(/</g,"<")+"\"</span>";
|
476 |
|
|
}
|
477 |
|
|
// element
|
478 |
|
|
else if(isElement){
|
479 |
|
|
if(_value.nodeType==3)return d.highlight(_value.nodeValue);
|
480 |
|
|
|
481 |
|
|
if(_inArray||_inObject){
|
482 |
|
|
var result = "<span class='Blue'>"+_value.nodeName.toLowerCase();
|
483 |
|
|
if(_value.getAttribute&&_value.getAttribute("id"))result += "<span class='DarkBlue'>#"+_value.getAttribute("id")+"</span>";
|
484 |
|
|
var elClass = _value.getAttribute?_value.getAttribute(pi.env.ie?"className":"class"):"";
|
485 |
|
|
if(elClass)result += "<span class='Red'>."+elClass.split(" ")[0]+"</span>";
|
486 |
|
|
return result+"</span>";
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
var result = "<span class='Blue'><"+_value.nodeName.toLowerCase()+"";
|
490 |
|
|
if(_value.attributes)
|
491 |
|
|
for(var i=0; i<_value.attributes.length; i++){
|
492 |
|
|
var item = _value.attributes[i];
|
493 |
|
|
if(pi.env.ie&&Boolean(item.nodeValue)==false)continue;
|
494 |
|
|
result += " <span class='DarkBlue'>"+item.nodeName+"=\"<span class='Red'>"+item.nodeValue+"</span>\"</span>";
|
495 |
|
|
}
|
496 |
|
|
result += "></span>";
|
497 |
|
|
return result;
|
498 |
|
|
}
|
499 |
|
|
// array & object
|
500 |
|
|
else if(isArray||["object","array"].indexOf(typeof _value)>-1){
|
501 |
|
|
var result = "";
|
502 |
|
|
if(isArray||_value instanceof Array){
|
503 |
|
|
if(_inObject)return "<span class='Gray Italic'>["+_value.length+"]</span>";
|
504 |
|
|
result += "<span class='Strong'>[ ";
|
505 |
|
|
|
506 |
|
|
for(var i=0; i<_value.length; i++){
|
507 |
|
|
if((_inObject||_inArray)&&pi.env.ie&&i>3)break;
|
508 |
|
|
result += (i > 0 ? ", " : "") + d.highlight(_value[i], false, true, true);
|
509 |
|
|
}
|
510 |
|
|
result += " ]</span>";
|
511 |
|
|
return result;
|
512 |
|
|
}
|
513 |
|
|
if(_inObject)return "<span class='Gray Italic'>Object</span>";
|
514 |
|
|
result += "<span class='Strong Green"+ ( !_link?"'":" ObjectLink' onmouseover='this.className=this.className.replace(\"ObjectLink\",\"ObjectLinkHover\")' onmouseout='this.className=this.className.replace(\"ObjectLinkHover\",\"ObjectLink\")' onclick='firebug.d.console.openObject(" +( env.objCn.push( _value ) -1 )+")'" ) + ">Object";
|
515 |
|
|
var i=0;
|
516 |
|
|
for(var key in _value){
|
517 |
|
|
var value = _value[key];
|
518 |
|
|
if((_inObject||_inArray)&&pi.env.ie&&i>3)
|
519 |
|
|
break;
|
520 |
|
|
result += " "+key+"="+d.highlight(value,true);
|
521 |
|
|
i++;
|
522 |
|
|
};
|
523 |
|
|
result += "</span>";
|
524 |
|
|
return result;
|
525 |
|
|
} else {
|
526 |
|
|
if(_inObject)
|
527 |
|
|
return "<span class='Gray Italic'>"+_value+"</span>";
|
528 |
|
|
return _value;
|
529 |
|
|
}
|
530 |
|
|
|
531 |
|
|
}
|
532 |
|
|
},
|
533 |
|
|
html:{
|
534 |
|
|
nIndex:"computedStyle",
|
535 |
|
|
current:null,
|
536 |
|
|
highlight:function(_element,_clear,_event){
|
537 |
|
|
with(firebug){
|
538 |
|
|
if(_clear){
|
539 |
|
|
el.bgInspector.environment.addStyle({ "display":"none" });
|
540 |
|
|
return;
|
541 |
|
|
}
|
542 |
|
|
d.inspector.inspect(_element,true);
|
543 |
|
|
}
|
544 |
|
|
},
|
545 |
|
|
inspect:function(_element){
|
546 |
|
|
var el = _element, map = [], parent = _element;
|
547 |
|
|
while(parent){
|
548 |
|
|
map.push(parent);
|
549 |
|
|
if(parent==document.body)break;
|
550 |
|
|
parent = parent.parentNode;
|
551 |
|
|
}
|
552 |
|
|
map = map.reverse();
|
553 |
|
|
with(firebug){
|
554 |
|
|
d.inspector.toggle();
|
555 |
|
|
var parentLayer = el.left.html.container.child.get()[1].childNodes[1].pi;
|
556 |
|
|
for(var t=0; map[t];){
|
557 |
|
|
if(t==map.length-1){
|
558 |
|
|
|
559 |
|
|
var link = parentLayer.environment.getElement().previousSibling.pi;
|
560 |
|
|
link.attribute.addClass("Selected");
|
561 |
|
|
|
562 |
|
|
if(d.html.current)d.html.current[1].attribute.removeClass("Selected");
|
563 |
|
|
|
564 |
|
|
d.html.current = [_element,link];
|
565 |
|
|
|
566 |
|
|
return;t
|
567 |
|
|
}
|
568 |
|
|
parentLayer = d.html.openHtmlTree(map[t],parentLayer,map[t+1]);
|
569 |
|
|
t++;
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
},
|
573 |
|
|
navigate:function(_index,_element){
|
574 |
|
|
with(firebug){
|
575 |
|
|
el.right.html.nav[d.html.nIndex].attribute.removeClass("Selected");
|
576 |
|
|
el.right.html.nav[_index].attribute.addClass("Selected");
|
577 |
|
|
d.html.nIndex = _index;
|
578 |
|
|
d.html.openProperties();
|
579 |
|
|
|
580 |
|
|
}
|
581 |
|
|
},
|
582 |
|
|
openHtmlTree:function(_element,_parent,_returnParentElementByElement,_event){
|
583 |
|
|
with(firebug){
|
584 |
|
|
var element = _element || document.documentElement,
|
585 |
|
|
parent = _parent || el.left.html.container,
|
586 |
|
|
returnParentEl = _returnParentElementByElement || null,
|
587 |
|
|
returnParentVal = null;
|
588 |
|
|
|
589 |
|
|
if(parent!=el.left.html.container){
|
590 |
|
|
var nodeLink = parent.environment.getParent().pi.child.get()[0].pi;
|
591 |
|
|
if(d.html.current)d.html.current[1].attribute.removeClass("Selected");
|
592 |
|
|
nodeLink.attribute.addClass("Selected");
|
593 |
|
|
|
594 |
|
|
d.html.current = [_element,nodeLink];
|
595 |
|
|
d.html.openProperties();
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
if(element.childNodes&&(element.childNodes.length==0||(element.childNodes.length==1&&element.childNodes[0].nodeType==3)))return;
|
599 |
|
|
parent.clean();
|
600 |
|
|
|
601 |
|
|
if(parent.opened&&Boolean(_returnParentElementByElement)==false){
|
602 |
|
|
parent.opened = false;
|
603 |
|
|
parent.environment.getParent().pi.child.get()[0].pi.attribute.removeClass("Open");
|
604 |
|
|
return;
|
605 |
|
|
}
|
606 |
|
|
if (parent != el.left.html.container) {
|
607 |
|
|
parent.environment.getParent().pi.child.get()[0].pi.attribute.addClass("Open");
|
608 |
|
|
parent.opened = true;
|
609 |
|
|
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
for(var i=0; i<element.childNodes.length; i++){
|
613 |
|
|
var item = element.childNodes[i];
|
614 |
|
|
|
615 |
|
|
if(item.nodeType==3)continue;
|
616 |
|
|
var container = new pi.element().attribute.addClass("Block").insert(parent);
|
617 |
|
|
var link = new pi.element("A").attribute.addClass("Link").update(d.highlight(item)).insert(container);
|
618 |
|
|
var subContainer = new pi.element("DIV").attribute.addClass("SubContainer").insert(container);
|
619 |
|
|
link.event.addListener("click",d.html.openHtmlTree.curry(window,item,subContainer,false));
|
620 |
|
|
link.event.addListener("mouseover",d.html.highlight.curry(window,item, false));
|
621 |
|
|
link.event.addListener("mouseout",d.html.highlight.curry(window,item,true));
|
622 |
|
|
|
623 |
|
|
returnParentVal = returnParentEl==item?subContainer:returnParentVal;
|
624 |
|
|
|
625 |
|
|
if(d.html.current==null&&item==document.body){
|
626 |
|
|
link.attribute.addClass("Selected");
|
627 |
|
|
d.html.current = [item,link];
|
628 |
|
|
d.html.openHtmlTree(item,subContainer);
|
629 |
|
|
}
|
630 |
|
|
|
631 |
|
|
if(item.childNodes&&item.childNodes.length==1&&item.childNodes[0].nodeType==3){
|
632 |
|
|
link.child.get()[0].appendChild(document.createTextNode(item.childNodes[0].nodeValue.substring(0,100)));
|
633 |
|
|
link.child.get()[0].appendChild(document.createTextNode("</"));
|
634 |
|
|
link.child.get()[0].appendChild(new pi.element("span").attribute.addClass("Blue").update(item.nodeName.toLowerCase()).environment.getElement());
|
635 |
|
|
link.child.get()[0].appendChild(document.createTextNode(">"));
|
636 |
|
|
continue;
|
637 |
|
|
}
|
638 |
|
|
else if(item.childNodes&&item.childNodes.length==0)continue;
|
639 |
|
|
link.attribute.addClass("ParentLink");
|
640 |
|
|
|
641 |
|
|
}
|
642 |
|
|
return returnParentVal;
|
643 |
|
|
}
|
644 |
|
|
},
|
645 |
|
|
openProperties:function(){
|
646 |
|
|
with(firebug){
|
647 |
|
|
|
648 |
|
|
var index = d.html.nIndex;
|
649 |
|
|
var node = d.html.current[0];
|
650 |
|
|
d.clean(el.right.html.content);
|
651 |
|
|
var str = "";
|
652 |
|
|
switch(index){
|
653 |
|
|
case "computedStyle":
|
654 |
|
|
var property = ["opacity","filter","azimuth","background","backgroundAttachment","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","border","borderCollapse","borderColor","borderSpacing","borderStyle","borderTop","borderRight","borderBottom","borderLeft","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderWidth","bottom","captionSide","clear","clip","color","content","counterIncrement","counterReset","cue","cueAfter","cueBefore","cursor","direction","display","elevation","emptyCells","cssFloat","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","height","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginTop","marginRight","marginBottom","marginLeft","markerOffset","marks","maxHeight","maxWidth","minHeight","minWidth","orphans","outline","outlineColor","outlineStyle","outlineWidth","overflow","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","page","pageBreakAfter","pageBreakBefore","pageBreakInside","pause","pauseAfter","pauseBefore","pitch","pitchRange","playDuring","position","quotes","richness","right","size","speak","speakHeader","speakNumeral","speakPunctuation","speechRate","stress","tableLayout","textAlign","textDecoration","textIndent","textShadow","textTransform","top","unicodeBidi","verticalAlign","visibility","voiceFamily","volume","whiteSpace","widows","width","wordSpacing","zIndex"].sort();
|
655 |
|
|
var view = document.defaultView?document.defaultView.getComputedStyle(node,null):node.currentStyle;
|
656 |
|
|
for(var i=0; i<property.length; i++){
|
657 |
|
|
var item = property[i];
|
658 |
|
|
if(!view[item])continue;
|
659 |
|
|
str+="<div class='CSSItem'><div class='CSSProperty'>"+item+"</div><div class='CSSValue'>"+d.highlight(view[item])+"</div></div>";
|
660 |
|
|
}
|
661 |
|
|
el.right.html.content.update(str);
|
662 |
|
|
break;
|
663 |
|
|
case "dom":
|
664 |
|
|
d.dom.open(node,el.right.html.content,pi.env.ie);
|
665 |
|
|
break;
|
666 |
|
|
}
|
667 |
|
|
}
|
668 |
|
|
}
|
669 |
|
|
},
|
670 |
|
|
inspector:{
|
671 |
|
|
enabled:false,
|
672 |
|
|
el:null,
|
673 |
|
|
inspect:function(_element,_bgInspector){
|
674 |
|
|
var el = _element, top = el.offsetTop, left = el.offsetLeft, parent = _element.offsetParent;
|
675 |
|
|
while(Boolean(parent)&&parent!=document.firstChild){
|
676 |
|
|
top += parent.offsetTop;
|
677 |
|
|
left += parent.offsetLeft;
|
678 |
|
|
parent = parent.offsetParent;
|
679 |
|
|
if(parent==document.body)break;
|
680 |
|
|
};
|
681 |
|
|
|
682 |
|
|
with(firebug){
|
683 |
|
|
el[_bgInspector?"bgInspector":"borderInspector"].environment.addStyle({
|
684 |
|
|
"width":_element.offsetWidth+"px", "height":_element.offsetHeight+"px",
|
685 |
|
|
"top":top-(_bgInspector?0:2)+"px", "left":left-(_bgInspector?0:2)+"px",
|
686 |
|
|
"display":"block"
|
687 |
|
|
});
|
688 |
|
|
|
689 |
|
|
if(!_bgInspector){
|
690 |
|
|
d.inspector.el = _element;
|
691 |
|
|
}
|
692 |
|
|
};
|
693 |
|
|
},
|
694 |
|
|
toggle:function(){
|
695 |
|
|
with (firebug) {
|
696 |
|
|
d.inspector.enabled = !d.inspector.enabled;
|
697 |
|
|
el.button.inspect.attribute[(d.inspector.enabled ? "add" : "remove") + "Class"]("Enabled");
|
698 |
|
|
if(d.inspector.enabled==false){
|
699 |
|
|
el.borderInspector.environment.addStyle({ "display":"none" });
|
700 |
|
|
d.inspector.el = null;
|
701 |
|
|
} else if(pi.env.dIndex!="html") {
|
702 |
|
|
d.navigate("html");
|
703 |
|
|
}
|
704 |
|
|
}
|
705 |
|
|
}
|
706 |
|
|
},
|
707 |
|
|
scripts:{
|
708 |
|
|
index:-1,
|
709 |
|
|
lineNumbers:false,
|
710 |
|
|
open:function(_index){
|
711 |
|
|
with(firebug){
|
712 |
|
|
d.scripts.index = _index;
|
713 |
|
|
el.left.scripts.container.update("");
|
714 |
|
|
var script = document.getElementsByTagName("script")[_index],uri = script.src||document.location.href,source;
|
715 |
|
|
|
716 |
|
|
if(uri.indexOf("http:\/\/")>-1&&getDomain(uri)!=document.domain){
|
717 |
|
|
el.left.scripts.container.update("<em>Access to restricted URI denied</em>");
|
718 |
|
|
return;
|
719 |
|
|
}
|
720 |
|
|
|
721 |
|
|
if(uri!=document.location.href){
|
722 |
|
|
source = env.cache[uri]||pi.xhr.get(uri).responseText;
|
723 |
|
|
env.cache[uri] = source;
|
724 |
|
|
} else
|
725 |
|
|
source = script.innerHTML;
|
726 |
|
|
source = source.replace(/\n|\t|<|>/g,function(_ch){
|
727 |
|
|
return ({"<":"<",">":">","\t":" ","\n":"<br />"})[_ch];
|
728 |
|
|
});
|
729 |
|
|
|
730 |
|
|
if (!d.scripts.lineNumbers)
|
731 |
|
|
el.left.scripts.container.child.add(
|
732 |
|
|
new pi.element("DIV").attribute.addClass("CodeContainer").update(source)
|
733 |
|
|
);
|
734 |
|
|
else {
|
735 |
|
|
source = source.split("<br />");
|
736 |
|
|
for (var i = 0; i < source.length; i++) {
|
737 |
|
|
el.left.scripts.container.child.add(new pi.element("DIV").child.add(new pi.element("DIV").attribute.addClass("LineNumber").update(i + 1), new pi.element("DIV").attribute.addClass("Code").update(" " + source[i]), new pi.element("DIV").environment.addStyle({
|
738 |
|
|
"clear": "both"
|
739 |
|
|
})));
|
740 |
|
|
};
|
741 |
|
|
};
|
742 |
|
|
}
|
743 |
|
|
},
|
744 |
|
|
toggleLineNumbers:function(){
|
745 |
|
|
with(firebug){
|
746 |
|
|
d.scripts.lineNumbers = !d.scripts.lineNumbers;
|
747 |
|
|
el.button.scripts.lineNumbers.attribute[(d.scripts.lineNumbers ? "add" : "remove") + "Class"]("Enabled");
|
748 |
|
|
d.scripts.open( d.scripts.index );
|
749 |
|
|
|
750 |
|
|
}
|
751 |
|
|
},
|
752 |
|
|
refresh:function(){
|
753 |
|
|
with(firebug){
|
754 |
|
|
el.button.scripts.selectbox.clean();
|
755 |
|
|
var collection = document.getElementsByTagName("script");
|
756 |
|
|
for(var i=0; i<collection.length; i++){
|
757 |
|
|
var item = collection[i];
|
758 |
|
|
d.scripts.index=d.scripts.index<0?i:d.scripts.index;
|
759 |
|
|
el.button.scripts.selectbox.child.add(
|
760 |
|
|
new pi.element("OPTION").attribute.set("value",i).update(item.src||item.baseURI||"..")
|
761 |
|
|
);
|
762 |
|
|
}
|
763 |
|
|
d.scripts.open( d.scripts.index );
|
764 |
|
|
}
|
765 |
|
|
}
|
766 |
|
|
},
|
767 |
|
|
str: {
|
768 |
|
|
open:function(_str){
|
769 |
|
|
with(firebug){
|
770 |
|
|
d.navigate("str");
|
771 |
|
|
el.left.str.container.update(_str.replace(/\n/g,"<br />"))
|
772 |
|
|
}
|
773 |
|
|
}
|
774 |
|
|
},
|
775 |
|
|
xhr:{
|
776 |
|
|
objects:[],
|
777 |
|
|
addObject:function(){
|
778 |
|
|
with(firebug){
|
779 |
|
|
for(var i=0; i<arguments.length; i++){
|
780 |
|
|
try {
|
781 |
|
|
var item = arguments[i];
|
782 |
|
|
var val = eval(item);
|
783 |
|
|
d.xhr.objects.push([
|
784 |
|
|
item, val
|
785 |
|
|
]);
|
786 |
|
|
} catch(e){
|
787 |
|
|
continue;
|
788 |
|
|
}
|
789 |
|
|
}
|
790 |
|
|
}
|
791 |
|
|
},
|
792 |
|
|
open:function(){
|
793 |
|
|
with(firebug){
|
794 |
|
|
el.left.xhr.container.update("");
|
795 |
|
|
el.left.xhr.name = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"20%" }).insert(el.left.xhr.container));
|
796 |
|
|
el.left.xhr.nameTitle = new pi.element("STRONG").update("Object Name:").insert(el.left.xhr.name);
|
797 |
|
|
el.left.xhr.nameContent = new pi.element("DIV").insert(el.left.xhr.name);
|
798 |
|
|
el.left.xhr.status = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"10%" }).insert(el.left.xhr.container));
|
799 |
|
|
el.left.xhr.statusTitle = new pi.element("STRONG").update("Status:").insert(el.left.xhr.status);
|
800 |
|
|
el.left.xhr.statusContent = new pi.element("DIV").insert(el.left.xhr.status);
|
801 |
|
|
el.left.xhr.readystate = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").environment.addStyle({ "width":"15%" }).attribute.addClass("Block").insert(el.left.xhr.container));
|
802 |
|
|
el.left.xhr.readystateTitle =el.left.xhr.nameTitle = new pi.element("STRONG").update("Ready State:").insert(el.left.xhr.readystate);
|
803 |
|
|
el.left.xhr.readystateContent = new pi.element("DIV").insert(el.left.xhr.readystate);
|
804 |
|
|
el.left.xhr.response = new pi.element("DIV").attribute.addClass("BlockContent").insert(new pi.element("DIV").environment.addStyle({ "width":(pi.env.ie?"50":"55")+"%" }).attribute.addClass("Block").insert(el.left.xhr.container));
|
805 |
|
|
el.left.xhr.responseTitle = new pi.element("STRONG").update("Response:").insert(el.left.xhr.response);
|
806 |
|
|
el.left.xhr.responseContent = new pi.element("DIV").insert(el.left.xhr.response);
|
807 |
|
|
setTimeout(d.xhr.refresh,500);
|
808 |
|
|
}
|
809 |
|
|
},
|
810 |
|
|
refresh:function(){
|
811 |
|
|
with(firebug){
|
812 |
|
|
el.left.xhr.nameContent.update("");
|
813 |
|
|
el.left.xhr.statusContent.update("");
|
814 |
|
|
el.left.xhr.readystateContent.update("");
|
815 |
|
|
el.left.xhr.responseContent.update("");
|
816 |
|
|
for(var i=0; i<d.xhr.objects.length; i++){
|
817 |
|
|
var item = d.xhr.objects[i];
|
818 |
|
|
var response = item[1].responseText;
|
819 |
|
|
if(Boolean(item[1])==false)continue;
|
820 |
|
|
el.left.xhr.nameContent.child.add(new pi.element("span").update(item[0]));
|
821 |
|
|
try {
|
822 |
|
|
el.left.xhr.statusContent.child.add(new pi.element("span").update(item[1].status));
|
823 |
|
|
} catch(e){ el.left.xhr.statusContent.child.add(new pi.element("span").update(" ")); }
|
824 |
|
|
el.left.xhr.readystateContent.child.add(new pi.element("span").update(item[1].readyState));
|
825 |
|
|
|
826 |
|
|
el.left.xhr.responseContent.child.add(new pi.element("span").child.add(
|
827 |
|
|
new pi.element("A").event.addListener("click",d.str.open.curry(window,response)).update(" "+response.substring(0,50))
|
828 |
|
|
));
|
829 |
|
|
};
|
830 |
|
|
if(env.dIndex=="xhr")
|
831 |
|
|
setTimeout(d.xhr.refresh,500);
|
832 |
|
|
}
|
833 |
|
|
}
|
834 |
|
|
},
|
835 |
|
|
navigateRightColumn:function(_index,_open){
|
836 |
|
|
with(firebug){
|
837 |
|
|
el.left.container.environment.addStyle({ "width":_open?"70%":"100%" });
|
838 |
|
|
el.right.container.environment.addStyle({ "display":_open?"block":"none" });
|
839 |
|
|
}
|
840 |
|
|
},
|
841 |
|
|
navigate:function(_index){
|
842 |
|
|
with(firebug){
|
843 |
|
|
|
844 |
|
|
var open = _index, close = env.dIndex;
|
845 |
|
|
env.dIndex = open;
|
846 |
|
|
|
847 |
|
|
el.button[close].container.environment.addStyle({ "display":"none" });
|
848 |
|
|
el.left[close].container.environment.addStyle({ "display":"none" });
|
849 |
|
|
el.right[close].container.environment.addStyle({ "display":"none" });
|
850 |
|
|
|
851 |
|
|
el.button[open].container.environment.addStyle({ "display":"inline" });
|
852 |
|
|
el.left[open].container.environment.addStyle({ "display":"block" });
|
853 |
|
|
el.right[open].container.environment.addStyle({ "display":"block" });
|
854 |
|
|
|
855 |
|
|
if(el.nav[close])
|
856 |
|
|
el.nav[close].attribute.removeClass("Selected");
|
857 |
|
|
if(el.nav[open])
|
858 |
|
|
el.nav[open].attribute.addClass("Selected");
|
859 |
|
|
|
860 |
|
|
switch(open){
|
861 |
|
|
case "console":
|
862 |
|
|
d.navigateRightColumn(_index);
|
863 |
|
|
break;
|
864 |
|
|
case "html":
|
865 |
|
|
d.navigateRightColumn(_index,true);
|
866 |
|
|
d.html.openHtmlTree();
|
867 |
|
|
break;
|
868 |
|
|
case "css":
|
869 |
|
|
d.navigateRightColumn(_index,true);
|
870 |
|
|
d.css.refresh();
|
871 |
|
|
break;
|
872 |
|
|
case "scripts":
|
873 |
|
|
d.navigateRightColumn(_index);
|
874 |
|
|
d.scripts.refresh();
|
875 |
|
|
break;
|
876 |
|
|
case "dom":
|
877 |
|
|
d.navigateRightColumn(_index);
|
878 |
|
|
if(el.left.dom.container.environment.getElement().innerHTML=="")
|
879 |
|
|
d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
|
880 |
|
|
break;
|
881 |
|
|
case "xhr":
|
882 |
|
|
d.navigateRightColumn(_index);
|
883 |
|
|
d.xhr.open();
|
884 |
|
|
break;
|
885 |
|
|
}
|
886 |
|
|
|
887 |
|
|
}
|
888 |
|
|
},
|
889 |
|
|
refreshSize:function(){
|
890 |
|
|
with(firebug){
|
891 |
|
|
el.main.environment.addStyle({ "width":pi.util.GetWindowSize().width+"px"});
|
892 |
|
|
if(pi.env.ie6)
|
893 |
|
|
el.main.environment.addStyle({ "top":pi.util.GetWindowSize().height-el.main.environment.getSize().offsetHeight+"px" });
|
894 |
|
|
}
|
895 |
|
|
}
|
896 |
|
|
},
|
897 |
|
|
getDomain:function(_url){
|
898 |
|
|
return _url.match(/http:\/\/(www.)?([\.\w]+)/)[2];
|
899 |
|
|
},
|
900 |
|
|
listen: {
|
901 |
|
|
addXhrObject:function(){
|
902 |
|
|
with(firebug){
|
903 |
|
|
d.xhr.addObject.apply(window, el.button.xhr.textbox.environment.getElement().value.split(","));
|
904 |
|
|
}
|
905 |
|
|
},
|
906 |
|
|
consoleTextbox:function(_event){
|
907 |
|
|
with(firebug){
|
908 |
|
|
if(_event.keyCode==13&&(env.multilinemode==false||_event.shiftKey==false)){
|
909 |
|
|
d.console.historyIndex = d.console.history.length;
|
910 |
|
|
d.console.run(el.left.console.input.environment.getElement().value);
|
911 |
|
|
return false;
|
912 |
|
|
}
|
913 |
|
|
if([13,38,40].indexOf(_event.keyCode)==-1)
|
914 |
|
|
return;
|
915 |
|
|
d.console.historyIndex+=_event.keyCode!=40?0:d.console.historyIndex==d.console.history.length?0:1;
|
916 |
|
|
d.console.historyIndex-=_event.keyCode!=38?0:d.console.historyIndex==0?0:1;
|
917 |
|
|
el.left.console.input.update(
|
918 |
|
|
d.console.history.length > d.console.historyIndex ?
|
919 |
|
|
d.console.history[d.console.historyIndex] :
|
920 |
|
|
""
|
921 |
|
|
);
|
922 |
|
|
}
|
923 |
|
|
},
|
924 |
|
|
cssSelectbox:function(){
|
925 |
|
|
with(firebug){
|
926 |
|
|
d.css.open(el.button.css.selectbox.environment.getElement().selectedIndex);
|
927 |
|
|
}
|
928 |
|
|
},
|
929 |
|
|
domTextbox:function(_event){
|
930 |
|
|
with(firebug){
|
931 |
|
|
if(_event.keyCode==13){
|
932 |
|
|
d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
|
933 |
|
|
}
|
934 |
|
|
}
|
935 |
|
|
},
|
936 |
|
|
inspector:function(){
|
937 |
|
|
with(firebug){
|
938 |
|
|
d.html.inspect(d.inspector.el);
|
939 |
|
|
}
|
940 |
|
|
},
|
941 |
|
|
keyboard:function(_event){
|
942 |
|
|
with(firebug){
|
943 |
|
|
if(_event.keyCode==27&&d.inspector.enabled)
|
944 |
|
|
d.inspector.toggle();
|
945 |
|
|
}
|
946 |
|
|
},
|
947 |
|
|
mouse:function(_event){
|
948 |
|
|
with(firebug){
|
949 |
|
|
var target = _event[pi.env.ie?"srcElement":"target"];
|
950 |
|
|
if(
|
951 |
|
|
d.inspector.enabled&&
|
952 |
|
|
target!=document.body&&
|
953 |
|
|
target!=document.firstChild&&
|
954 |
|
|
target!=document.childNodes[1]&&
|
955 |
|
|
target!=el.borderInspector.environment.getElement()&&
|
956 |
|
|
target!=el.main.environment.getElement()&&
|
957 |
|
|
target.offsetParent!=el.main.environment.getElement()
|
958 |
|
|
)
|
959 |
|
|
d.inspector.inspect(target);
|
960 |
|
|
}
|
961 |
|
|
},
|
962 |
|
|
runMultiline:function(){
|
963 |
|
|
with(firebug){
|
964 |
|
|
d.console.run.call(window,el.right.console.input.environment.getElement().value);
|
965 |
|
|
}
|
966 |
|
|
},
|
967 |
|
|
runCSS:function(){
|
968 |
|
|
with(firebug){
|
969 |
|
|
var source = el.right.css.input.environment.getElement().value.replace(/\n|\t/g,"").split("}");
|
970 |
|
|
for(var i=0; i<source.length; i++){
|
971 |
|
|
var item = source[i]+"}", rule = !pi.env.ie?item:item.split(/{|}/), collection = document.getElementsByTagName("style"),
|
972 |
|
|
style = collection.length>0?collection[0]:document.body.appendChild( document.createElement("style") );
|
973 |
|
|
if(!item.match(/.+\{.+\}/))continue;
|
974 |
|
|
if(pi.env.ie)
|
975 |
|
|
style.styleSheet.addRule(rule[0],rule[1]);
|
976 |
|
|
else
|
977 |
|
|
style.sheet.insertRule( rule, style.sheet.cssRules.length );
|
978 |
|
|
}
|
979 |
|
|
}
|
980 |
|
|
},
|
981 |
|
|
scriptsSelectbox:function(){
|
982 |
|
|
with(firebug){
|
983 |
|
|
d.scripts.open(parseInt(el.button.scripts.selectbox.environment.getElement().value));
|
984 |
|
|
}
|
985 |
|
|
},
|
986 |
|
|
xhrTextbox:function(_event){
|
987 |
|
|
with(firebug){
|
988 |
|
|
if(_event.keyCode==13){
|
989 |
|
|
d.xhr.addObject.apply(window, el.button.xhr.textbox.environment.getElement().value.split(","));
|
990 |
|
|
}
|
991 |
|
|
}
|
992 |
|
|
}
|
993 |
|
|
}
|
994 |
|
|
};
|
995 |
|
|
|
996 |
|
|
window.console = firebug.d.console;
|
997 |
|
|
pi.util.AddEvent(window,"resize",firebug.d.refreshSize);
|
998 |
|
|
pi.util.AddEvent(document,"mousemove",firebug.listen.mouse);
|
999 |
|
|
pi.util.AddEvent(document,"keydown",firebug.listen.keyboard);
|
1000 |
|
|
pi.util.DOMContentLoaded.push(firebug.init);
|