1
/* See license.txt for terms of usage */
2
function _FirebugConsole()
4
this.log = function() { window._firebug.notifyFirebug(arguments, 'log', 'firebugAppendConsole'); }
5
this.debug = function() { window._firebug.notifyFirebug(arguments, 'debug', 'firebugAppendConsole'); }
6
this.info = function() { window._firebug.notifyFirebug(arguments, 'info', 'firebugAppendConsole'); }
7
this.warn = function() { window._firebug.notifyFirebug(arguments, 'warn', 'firebugAppendConsole'); }
8
this.error = function() { window._firebug.notifyFirebug(arguments, 'error', 'firebugAppendConsole'); }
9
this.exception = function() { window._firebug.notifyFirebug(arguments, 'exception', 'firebugAppendConsole'); }
10
this.assert = function() { window._firebug.notifyFirebug(arguments, 'assert', 'firebugAppendConsole'); }
11
this.dir = function() { window._firebug.notifyFirebug(arguments, 'dir', 'firebugAppendConsole'); }
12
this.dirxml = function() { window._firebug.notifyFirebug(arguments, 'dirxml', 'firebugAppendConsole'); }
13
this.trace = function firebugDebuggerTracer() { debugger; }
14
this.group = function() { window._firebug.notifyFirebug(arguments, 'group', 'firebugAppendConsole'); }
15
this.groupEnd = function() { window._firebug.notifyFirebug(arguments, 'groupEnd', 'firebugAppendConsole'); }
16
this.groupCollapsed = function() { window._firebug.notifyFirebug(arguments, 'groupCollapsed', 'firebugAppendConsole'); }
17
this.time = function() { window._firebug.notifyFirebug(arguments, 'time', 'firebugAppendConsole'); }
18
this.timeEnd = function() { window._firebug.notifyFirebug(arguments, 'timeEnd', 'firebugAppendConsole'); }
19
this.profile = function() { window._firebug.notifyFirebug(arguments, 'profile', 'firebugAppendConsole'); }
20
this.profileEnd = function() { window._firebug.notifyFirebug(arguments, 'profileEnd', 'firebugAppendConsole'); }
21
this.count = function() { window._firebug.notifyFirebug(arguments, 'count', 'firebugAppendConsole'); }
22
this.clear = function() { window._firebug.notifyFirebug(arguments, 'clear', 'firebugAppendConsole'); }
24
// DBG this.uid = Math.random();
26
this.notifyFirebug = function(objs, methodName, eventID)
28
var element = this.getFirebugElement();
30
var event = document.createEvent("Events");
31
event.initEvent(eventID, true, false);
33
window._firebug.userObjects = [];
34
for (var i=0; i<objs.length; i++)
35
window._firebug.userObjects.push(objs[i]);
37
var length = window._firebug.userObjects.length;
38
element.setAttribute("methodName", methodName);
40
// DBG element.setAttribute("uid", this.uid);
42
// DBG if (length > 0)
43
// DBG element.setAttribute("checkUserObjects", this.userObjects[0].toString());
45
// DBG element.setAttribute("checkUserObjects", "no userObjects");
47
// DBG dump("FirebugConsole("+this.uid+") dispatching event "+methodName+" via "+eventID+" with "+length+ " user objects, [0]:"+this.userObjects[0]+"\n");
50
element.dispatchEvent(event);
52
// DBG dump("FirebugConsole dispatched event "+methodName+" via "+eventID+" with "+length+ " user objects, [0]:"+this.userObjects[0]+"\n");
55
if (element.getAttribute("retValueType") == "array")
58
if (!result && this.userObjects.length == length+1)
59
return this.userObjects[length];
61
for (var i=length; i<this.userObjects.length && result; i++)
62
result.push(this.userObjects[i]);
67
this.getFirebugElement = function()
70
this.element = window._getFirebugConsoleElement();
74
// ***********************************************************************
77
this.__defineGetter__("firebug", function(){
78
return this.getFirebugElement().getAttribute("FirebugVersion");
82
window._getFirebugConsoleElement = function() // could this be done in extension code? but only after load....
84
var element = document.getElementById("_firebugConsole");
87
if (document.documentElement.nodeName == document.documentElement.nodeName.toUpperCase())
88
element = document.createElement("div");
90
element = document.createElementNS("http://www.w3.org/1999/xhtml","html:div"); // NS for XML/svg
92
element.setAttribute("id", "_firebugConsole");
93
element.firebugIgnore = true;
94
element.setAttribute("style", "display:none");
96
var body = document.body ? document.body : document.getElementsByTagName("body")[0];
98
body = document.documentElement; // For non-HTML docs
100
body.appendChild(element);