server/src/main/resources/_firebug/firebug.js.uncompressed.js
author ymh <ymh.work@gmail.com>
Mon, 20 Aug 2012 16:07:15 +0200
changeset 22 948283342245
permissions -rw-r--r--
Session moderator + test in model
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
define("dojo/_firebug/firebug", [
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
	"../_base/kernel",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
	"require",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
	"../_base/html",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
	"../sniff",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
	"../_base/array",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
	"../_base/lang",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
	"../_base/event",
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
	"../_base/unload"], function(dojo, require, html, has){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
	// module:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
	//		dojo/_firebug/firebug
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	//		Firebug Lite, the baby brother to Joe Hewitt's Firebug for Mozilla Firefox
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
	// description:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	//		Opens a console for logging, debugging, and error messages.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	//		Contains partial functionality to Firebug. See function list below.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	//
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	//		NOTE:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	//		Firebug is a Firefox extension created by Joe Hewitt (see license). You do not need Dojo to run Firebug.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
	//		Firebug Lite is included in Dojo by permission from Joe Hewitt
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	//		If you are new to Firebug, or used to the Dojo 0.4 dojo.debug, you can learn Firebug
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	//		functionality by reading the function comments below or visiting http://www.getfirebug.com/docs.html
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	//
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	//		NOTE:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	//		To test Firebug Lite in Firefox:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	//
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	//		- FF2: set "console = null" before loading dojo and set djConfig.isDebug=true
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
	//		- FF3: disable Firebug and set djConfig.isDebug=true
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	//
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	// example:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	//		Supports inline objects in object inspector window (only simple trace of dom nodes, however)
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	//	|	console.log("my object", {foo:"bar"})
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	// example:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	//		Option for console to open in popup window
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	//	|	var djConfig = {isDebug: true, popup:true };
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	// example:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	//		Option for console height (ignored for popup)
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	//	|	var djConfig = {isDebug: true, debugHeight:100 }
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	var isNewIE = (/Trident/.test(window.navigator.userAgent));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	if(isNewIE){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
		// Fixing IE's console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		// IE doesn't insert space between arguments. How annoying.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		var calls = ["log", "info", "debug", "warn", "error"];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		for(var i=0;i<calls.length;i++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			var m = calls[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
			if(!console[m] ||console[m]._fake){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
				// IE9 doesn't have console.debug method, a fake one is added later
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
				continue;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
			var n = "_"+calls[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			console[n] = console[m];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			console[m] = (function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
				var type = n;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
				return function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
					console[type](Array.prototype.join.call(arguments, " "));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
				};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
			})();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		// clear the console on load. This is more than a convenience - too many logs crashes it.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
		// If closed it throws an error
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		try{ console.clear(); }catch(e){}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	if(
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		has("ff") ||								// Firefox has Firebug
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		has("chrome") ||							// Chrome 3+ has a console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
		has("safari") ||							// Safari 4 has a console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
		isNewIE ||									// Has the new IE console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
		window.firebug ||							// Testing for mozilla firebug lite
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		(typeof console != "undefined" && console.firebug) || //The firebug console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		dojo.config.useCustomLogger ||				// Allow custom loggers
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		has("air")									// isDebug triggers AIRInsector, not Firebug
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
	){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	// don't build firebug in iframes
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	try{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		if(window != window.parent){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
			// but if we've got a parent logger, connect to it
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			if(window.parent["console"]){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
				window.console = window.parent.console;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
			return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	}catch(e){/*squelch*/}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	// Placing these variables before the functions that use them to avoid a
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	// shrinksafe bug where variable renaming does not happen correctly otherwise.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
	// most of the objects in this script are run anonomously
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
	var _firebugDoc = document;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	var _firebugWin = window;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	var __consoleAnchorId__ = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	var consoleFrame = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
	var consoleBody = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
	var consoleObjectInspector = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
	var fireBugTabs = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
	var commandLine = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	var consoleToolbar = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	var frameVisible = false;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
	var messageQueue = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	var groupStack = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
	var timeMap = {};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
	var countMap = {};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
	var consoleDomInspector = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
	var _inspectionMoveConnection;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
	var _inspectionClickConnection;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
	var _inspectionEnabled = false;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	var _inspectionTimer = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	var _inspectTempNode = document.createElement("div");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
	var _inspectCurrentNode;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
	var _restoreBorderStyle;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
	window.console = {
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		_connects: [],
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
		log: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
			//		Sends arguments to console.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
			logFormatted(arguments, "");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		debug: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
			//		Sends arguments to console. Missing finctionality to show script line of trace.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
			logFormatted(arguments, "debug");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
		info: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			//		Sends arguments to console, highlighted with (I) icon.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			logFormatted(arguments, "info");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
		warn: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
			//		Sends warning arguments to console, highlighted with (!) icon and blue style.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
			logFormatted(arguments, "warning");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
		error: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
			//		Sends error arguments (object) to console, highlighted with (X) icon and yellow style
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
			//		NEW: error object now displays in object inspector
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
			logFormatted(arguments, "error");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
		assert: function(truth, message){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
			//		Tests for true. Throws exception if false.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
			if(!truth){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
				var args = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
				for(var i = 1; i < arguments.length; ++i){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
					args.push(arguments[i]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
				logFormatted(args.length ? args : ["Assertion Failure"], "error");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
				throw message ? message : "Assertion Failure";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		dir: function(obj){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
			var str = printObject( obj );
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
			str = str.replace(/\n/g, "<br />");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
			str = str.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
			logRow([str], "dir");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		dirxml: function(node){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
			var html = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
			appendNode(node, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
			logRow(html, "dirxml");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
		group: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
			//		collects log messages into a group, starting with this call and ending with
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
			//		groupEnd(). Missing collapse functionality
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
			logRow(arguments, "group", pushGroup);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		groupEnd: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			//		Closes group. See above
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
			logRow(arguments, "", popGroup);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		time: function(name){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
			//		Starts timers assigned to name given in argument. Timer stops and displays on timeEnd(title);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
			// example:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
			//	|	console.time("load");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
			//	|	console.time("myFunction");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
			//	|	console.timeEnd("load");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
			//	|	console.timeEnd("myFunction");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
			timeMap[name] = new Date().getTime();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		timeEnd: function(name){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
			//		See above.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
			if(name in timeMap){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
				var delta = (new Date()).getTime() - timeMap[name];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
				logFormatted([name+ ":", delta+"ms"]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
				delete timeMap[name];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		count: function(name){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
			//		Not supported
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			if(!countMap[name]) countMap[name] = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
			countMap[name]++;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
			logFormatted([name+": "+countMap[name]]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
		trace: function(_value){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			var stackAmt = _value || 3;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
			var f = console.trace.caller; //function that called trace
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
			console.log(">>> console.trace(stack)");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
			for(var i=0;i<stackAmt;i++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
				var func = f.toString();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
				var args=[];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
				for (var a = 0; a < f.arguments.length; a++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
					args.push(f.arguments[a]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
				if(f.arguments.length){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
					console.dir({"function":func, "arguments":args});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
				}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
					console.dir({"function":func});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
				f = f.caller;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		profile: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
			//		Not supported
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			this.warn(["profile() not supported."]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
		profileEnd: function(){ },
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
		clear: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
			//		Clears message console. Do not call this directly
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
			if(consoleBody){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
				while(consoleBody.childNodes.length){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
					dojo.destroy(consoleBody.firstChild);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
			dojo.forEach(this._connects,dojo.disconnect);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
		open: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
			//		Opens message console. Do not call this directly
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
			toggleConsole(true);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
		close: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			//		Closes message console. Do not call this directly
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
			if(frameVisible){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
				toggleConsole();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
		_restoreBorder: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
			if(_inspectCurrentNode){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
				_inspectCurrentNode.style.border = _restoreBorderStyle;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		openDomInspector: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
			_inspectionEnabled = true;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
			consoleBody.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
			consoleDomInspector.style.display = "block";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
			consoleObjectInspector.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
			document.body.style.cursor = "pointer";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
			_inspectionMoveConnection = dojo.connect(document, "mousemove", function(evt){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
				if(!_inspectionEnabled){ return; }
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
				if(!_inspectionTimer){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
					_inspectionTimer = setTimeout(function(){ _inspectionTimer = null; }, 50);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
				}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
					return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
				var node = evt.target;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
				if(node && (_inspectCurrentNode !== node)){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
					var parent = true;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
					console._restoreBorder();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
					var html = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
					appendNode(node, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
					consoleDomInspector.innerHTML = html.join("");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
					_inspectCurrentNode = node;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
					_restoreBorderStyle = _inspectCurrentNode.style.border;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
					_inspectCurrentNode.style.border = "#0000FF 1px solid";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
			});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
			setTimeout(function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
				_inspectionClickConnection = dojo.connect(document, "click", function(evt){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
					document.body.style.cursor = "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
					_inspectionEnabled = !_inspectionEnabled;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
					dojo.disconnect(_inspectionClickConnection);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
					// console._restoreBorder();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
				});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
			}, 30);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
		_closeDomInspector: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
			document.body.style.cursor = "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
			dojo.disconnect(_inspectionMoveConnection);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
			dojo.disconnect(_inspectionClickConnection);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
			_inspectionEnabled = false;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
			console._restoreBorder();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
		openConsole:function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
			// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
			//		Closes object inspector and opens message console. Do not call this directly
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
			consoleBody.style.display = "block";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
			consoleDomInspector.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
			consoleObjectInspector.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
			console._closeDomInspector();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
		openObjectInspector:function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
			consoleBody.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
			consoleDomInspector.style.display = "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
			consoleObjectInspector.style.display = "block";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
			console._closeDomInspector();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
		},
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
		recss: function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
			// this is placed in dojo since the console is most likely
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
			// in another window and dojo is easilly accessible
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
			var i,a,s;a=document.getElementsByTagName('link');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
			for(i=0;i<a.length;i++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
				s=a[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
				if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
					var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
					s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+new Date().valueOf();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
	};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
	function toggleConsole(forceOpen){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		frameVisible = forceOpen || !frameVisible;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
		if(consoleFrame){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
			consoleFrame.style.display = frameVisible ? "block" : "none";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
	function focusCommandLine(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
		toggleConsole(true);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
		if(commandLine){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
			commandLine.focus();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	function openWin(x,y,w,h){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		var win = window.open("","_firebug","status=0,menubar=0,resizable=1,top="+y+",left="+x+",width="+w+",height="+h+",scrollbars=1,addressbar=0");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
		if(!win){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
			var msg = "Firebug Lite could not open a pop-up window, most likely because of a blocker.\n" +
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
				"Either enable pop-ups for this domain, or change the djConfig to popup=false.";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
			alert(msg);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		createResizeHandler(win);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		var newDoc=win.document;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		//Safari needs an HTML height
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
		var HTMLstring=	'<html style="height:100%;"><head><title>Firebug Lite</title></head>\n' +
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
					'<body bgColor="#ccc" style="height:97%;" onresize="opener.onFirebugResize()">\n' +
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
					'<div id="fb"></div>' +
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
					'</body></html>';
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
		newDoc.write(HTMLstring);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
		newDoc.close();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
		return win;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
	function createResizeHandler(wn){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
		// summary:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
		//		Creates handle for onresize window. Called from script in popup's body tag (so that it will work with IE).
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
		//
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
		var d = new Date();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
			d.setTime(d.getTime()+(60*24*60*60*1000)); // 60 days
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
			d = d.toUTCString();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
			var dc = wn.document,
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
				getViewport;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
			if (wn.innerWidth){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
				getViewport = function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
					return{w:wn.innerWidth, h:wn.innerHeight};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
				};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
			}else if (dc.documentElement && dc.documentElement.clientWidth){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
				getViewport = function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
					return{w:dc.documentElement.clientWidth, h:dc.documentElement.clientHeight};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
				};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
			}else if (dc.body){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
				getViewport = function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
					return{w:dc.body.clientWidth, h:dc.body.clientHeight};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
				};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
		window.onFirebugResize = function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
			//resize the height of the console log body
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
			layout(getViewport().h);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
			clearInterval(wn._firebugWin_resize);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
			wn._firebugWin_resize = setTimeout(function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
				var x = wn.screenLeft,
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
					y = wn.screenTop,
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
					w = wn.outerWidth  || wn.document.body.offsetWidth,
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
					h = wn.outerHeight || wn.document.body.offsetHeight;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
				document.cookie = "_firebugPosition=" + [x,y,w,h].join(",") + "; expires="+d+"; path=/";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
			 }, 5000); //can't capture window.onMove - long timeout gives better chance of capturing a resize, then the move
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
		};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
	/*****************************************************************************/
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
	function createFrame(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
		if(consoleFrame){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
			return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
		toggleConsole(true);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
		if(dojo.config.popup){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
			var containerHeight = "100%";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
			var cookieMatch = document.cookie.match(/(?:^|; )_firebugPosition=([^;]*)/);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
			var p = cookieMatch ? cookieMatch[1].split(",") : [2,2,320,480];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
			_firebugWin = openWin(p[0],p[1],p[2],p[3]);	// global
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
			_firebugDoc = _firebugWin.document;			// global
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
			dojo.config.debugContainerId = 'fb';
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
			// connecting popup
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
			_firebugWin.console = window.console;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
			_firebugWin.dojo = window.dojo;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
			_firebugDoc = document;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
			containerHeight = (dojo.config.debugHeight || 300) + "px";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
		var styleElement = _firebugDoc.createElement("link");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
		styleElement.href = require.toUrl("./firebug.css");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
		styleElement.rel = "stylesheet";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
		styleElement.type = "text/css";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
		var styleParent = _firebugDoc.getElementsByTagName("head");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
		if(styleParent){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
			styleParent = styleParent[0];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
		if(!styleParent){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
			styleParent = _firebugDoc.getElementsByTagName("html")[0];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
		if(has("ie")){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
			window.setTimeout(function(){ styleParent.appendChild(styleElement); }, 0);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
			styleParent.appendChild(styleElement);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
		if(dojo.config.debugContainerId){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
			consoleFrame = _firebugDoc.getElementById(dojo.config.debugContainerId);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
		if(!consoleFrame){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
			consoleFrame = _firebugDoc.createElement("div");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
			_firebugDoc.body.appendChild(consoleFrame);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
		consoleFrame.className += " firebug";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
		consoleFrame.id = "firebug";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
		consoleFrame.style.height = containerHeight;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
		consoleFrame.style.display = (frameVisible ? "block" : "none");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
		var buildLink = function(label, title, method, _class){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
			return '<li class="'+_class+'"><a href="javascript:void(0);" onclick="console.'+ method +'(); return false;" title="'+title+'">'+label+'</a></li>';
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
		};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
		consoleFrame.innerHTML =
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
			  '<div id="firebugToolbar">'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
			+ '  <ul id="fireBugTabs" class="tabs">'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
			+ buildLink("Clear", "Remove All Console Logs", "clear", "")
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
			+ buildLink("ReCSS", "Refresh CSS without reloading page", "recss", "")
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
			+ buildLink("Console", "Show Console Logs", "openConsole", "gap")
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
			+ buildLink("DOM", "Show DOM Inspector", "openDomInspector", "")
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
			+ buildLink("Object", "Show Object Inspector", "openObjectInspector", "")
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
			+ ((dojo.config.popup) ? "" : buildLink("Close", "Close the console", "close", "gap"))
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
			+ '	</ul>'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
			+ '</div>'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
			+ '<input type="text" id="firebugCommandLine" />'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
			+ '<div id="firebugLog"></div>'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
			+ '<div id="objectLog" style="display:none;">Click on an object in the Log display</div>'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
			+ '<div id="domInspect" style="display:none;">Hover over HTML elements in the main page. Click to hold selection.</div>';
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
		consoleToolbar = _firebugDoc.getElementById("firebugToolbar");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
		commandLine = _firebugDoc.getElementById("firebugCommandLine");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
		addEvent(commandLine, "keydown", onCommandLineKeyDown);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
		addEvent(_firebugDoc, has("ie") || has("safari") ? "keydown" : "keypress", onKeyDown);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
		consoleBody = _firebugDoc.getElementById("firebugLog");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
		consoleObjectInspector = _firebugDoc.getElementById("objectLog");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
		consoleDomInspector = _firebugDoc.getElementById("domInspect");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
		fireBugTabs = _firebugDoc.getElementById("fireBugTabs");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
		layout();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
		flush();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	dojo.addOnLoad(createFrame);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
	function clearFrame(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
		_firebugDoc = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		if(_firebugWin.console){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
			_firebugWin.console.clear();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
		_firebugWin = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
		consoleFrame = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
		consoleBody = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
		consoleObjectInspector = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
		consoleDomInspector = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
		commandLine = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		messageQueue = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
		groupStack = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
		timeMap = {};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	function evalCommandLine(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
		var text = commandLine.value;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
		commandLine.value = "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
		logRow([">  ", text], "command");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
		var value;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
		try{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
			value = eval(text);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
		}catch(e){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
			console.debug(e); // put exception on the console
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
		console.log(value);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
	function layout(h){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
		var tHeight = 25; //consoleToolbar.offsetHeight; // tab style not ready on load - throws off layout
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
		var height = h ?
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
			h  - (tHeight + commandLine.offsetHeight +25 + (h*.01)) + "px" :
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
			(consoleFrame.offsetHeight - tHeight - commandLine.offsetHeight) + "px";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
		consoleBody.style.top = tHeight + "px";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
		consoleBody.style.height = height;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
		consoleObjectInspector.style.height = height;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
		consoleObjectInspector.style.top = tHeight + "px";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
		consoleDomInspector.style.height = height;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
		consoleDomInspector.style.top = tHeight + "px";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
		commandLine.style.bottom = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
		dojo.addOnWindowUnload(clearFrame);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
	function logRow(message, className, handler){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
		if(consoleBody){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
			writeMessage(message, className, handler);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
			messageQueue.push([message, className, handler]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
	function flush(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
		var queue = messageQueue;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
		messageQueue = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
		for(var i = 0; i < queue.length; ++i){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
			writeMessage(queue[i][0], queue[i][1], queue[i][2]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
	function writeMessage(message, className, handler){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
		var isScrolledToBottom =
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
			consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
		handler = handler||writeRow;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
		handler(message, className);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
		if(isScrolledToBottom){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
			consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
	function appendRow(row){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
		var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
		container.appendChild(row);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
	function writeRow(message, className){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
		var row = consoleBody.ownerDocument.createElement("div");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
		row.className = "logRow" + (className ? " logRow-"+className : "");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
		row.innerHTML = message.join("");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
		appendRow(row);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
	function pushGroup(message, className){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
		logFormatted(message, className);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
		//var groupRow = consoleBody.ownerDocument.createElement("div");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
		//groupRow.className = "logGroup";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
		var groupRowBox = consoleBody.ownerDocument.createElement("div");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
		groupRowBox.className = "logGroupBox";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
		//groupRow.appendChild(groupRowBox);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
		appendRow(groupRowBox);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
		groupStack.push(groupRowBox);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
	function popGroup(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
		groupStack.pop();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
	function logFormatted(objects, className){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
		var html = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
		var format = objects[0];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
		var objIndex = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
		if(typeof(format) != "string"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
			format = "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
			objIndex = -1;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
		var parts = parseFormat(format);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
		for(var i = 0; i < parts.length; ++i){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
			var part = parts[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
			if(part && typeof part == "object"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
				part.appender(objects[++objIndex], html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
				appendText(part, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
		var ids = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
		var obs = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
		for(i = objIndex+1; i < objects.length; ++i){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
			appendText(" ", html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
			var object = objects[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
			if(object === undefined || object === null ){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
				appendNull(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
			}else if(typeof(object) == "string"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
				appendText(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
			}else if(object instanceof Date){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
				appendText(object.toString(), html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
			}else if(object.nodeType == 9){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
				appendText("[ XmlDoc ]", html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
				// Create link for object inspector
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
				// need to create an ID for this link, since it is currently text
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
				var id = "_a" + __consoleAnchorId__++;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
				ids.push(id);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
				// need to save the object, so the arrays line up
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
				obs.push(object);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
				var str = '<a id="'+id+'" href="javascript:void(0);">'+getObjectAbbr(object)+'</a>';
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
				appendLink( str , html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
		logRow(html, className);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
		// Now that the row is inserted in the DOM, loop through all of the links that were just created
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
		for(i=0; i<ids.length; i++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
			var btn = _firebugDoc.getElementById(ids[i]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
			if(!btn){ continue; }
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
			// store the object in the dom btn for reference later
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
			// avoid parsing these objects unless necessary
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
			btn.obj = obs[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
			_firebugWin.console._connects.push(dojo.connect(btn, "onclick", function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
				console.openObjectInspector();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
				try{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
					printObject(this.obj);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
				}catch(e){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
					this.obj = e;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
				consoleObjectInspector.innerHTML = "<pre>" + printObject( this.obj ) + "</pre>";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
			}));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
	function parseFormat(format){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
		var parts = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
		var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
		var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat};
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
		for(var m = reg.exec(format); m; m = reg.exec(format)){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
			var type = m[8] ? m[8] : m[5];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
			var appender = type in appenderMap ? appenderMap[type] : appendObject;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
			var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
			parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
			parts.push({appender: appender, precision: precision});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
			format = format.substr(m.index+m[0].length);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
		parts.push(format);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
		return parts;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
	function escapeHTML(value){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
		function replaceChars(ch){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
			switch(ch){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
				case "<":
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
					return "&lt;";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
				case ">":
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
					return "&gt;";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
				case "&":
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
					return "&amp;";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
				case "'":
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
					return "&#39;";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
				case '"':
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
					return "&quot;";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
			return "?";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
		return String(value).replace(/[<>&"']/g, replaceChars);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
	function objectToString(object){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
		try{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
			return object+"";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
		}catch(e){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
			return null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
	function appendLink(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
		// needed for object links - no HTML escaping
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
		html.push( objectToString(object) );
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	function appendText(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
		html.push(escapeHTML(objectToString(object)));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
	function appendNull(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
		html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
	function appendString(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
		html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)),
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
			'&quot;</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
	function appendInteger(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
		html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
	function appendFloat(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
		html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
	function appendFunction(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
		html.push('<span class="objectBox-function">', getObjectAbbr(object), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
	function appendObject(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
		try{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
			if(object === undefined){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
				appendNull("undefined", html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
			}else if(object === null){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
				appendNull("null", html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
			}else if(typeof object == "string"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
				appendString(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
			}else if(typeof object == "number"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
				appendInteger(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
			}else if(typeof object == "function"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
				appendFunction(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
			}else if(object.nodeType == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
				appendSelector(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
			}else if(typeof object == "object"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
				appendObjectFormatted(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
				appendText(object, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
		}catch(e){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
			/* squelch */
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
	function appendObjectFormatted(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
		var text = objectToString(object);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
		var reObject = /\[object (.*?)\]/;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   832
		var m = reObject.exec(text);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
		html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   834
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
	function appendSelector(object, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
		html.push('<span class="objectBox-selector">');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   838
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
		html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
		if(object.id){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
			html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
		if(object.className){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
			html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
		html.push('</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
	function appendNode(node, html){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
		if(node.nodeType == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
			html.push(
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
				'<div class="objectBox-element">',
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
					'&lt;<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
			for(var i = 0; i < node.attributes.length; ++i){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
				var attr = node.attributes[i];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
				if(!attr.specified){ continue; }
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
				html.push('&nbsp;<span class="nodeName">', attr.nodeName.toLowerCase(),
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
					'</span>=&quot;<span class="nodeValue">', escapeHTML(attr.nodeValue),
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
					'</span>&quot;');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
			if(node.firstChild){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
				html.push('&gt;</div><div class="nodeChildren">');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
				for(var child = node.firstChild; child; child = child.nextSibling){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
					appendNode(child, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
				html.push('</div><div class="objectBox-element">&lt;/<span class="nodeTag">',
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
					node.nodeName.toLowerCase(), '&gt;</span></div>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
				html.push('/&gt;</div>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
		}else if (node.nodeType == 3){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
			html.push('<div class="nodeText">', escapeHTML(node.nodeValue),
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
				'</div>');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
	// ***************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
	function addEvent(object, name, handler){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
		if(document.all){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   887
			object.attachEvent("on"+name, handler);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
			object.addEventListener(name, handler, false);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   892
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
	function removeEvent(object, name, handler){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
		if(document.all){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
			object.detachEvent("on"+name, handler);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   896
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   897
			object.removeEventListener(name, handler, false);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
	function cancelEvent(event){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
		if(document.all){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
			event.cancelBubble = true;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
			event.stopPropagation();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
	function onError(msg, href, lineNo){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
		var lastSlash = href.lastIndexOf("/");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
		var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   913
		var html = [
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
			'<span class="errorMessage">', msg, '</span>',
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
			'<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>'
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
		];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
		logRow(html, "error");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
	//After converting to div instead of iframe, now getting two keydowns right away in IE 6.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
	//Make sure there is a little bit of delay.
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
	var onKeyDownTime = new Date().getTime();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
	function onKeyDown(event){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
		var timestamp = (new Date()).getTime();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
		if(timestamp > onKeyDownTime + 200){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
			event = dojo.fixEvent(event);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
			var keys = dojo.keys;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
			var ekc = event.keyCode;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
			onKeyDownTime = timestamp;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
			if(ekc == keys.F12){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
				toggleConsole();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
			}else if(
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
				(ekc == keys.NUMPAD_ENTER || ekc == 76) &&
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
				event.shiftKey &&
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
				(event.metaKey || event.ctrlKey)
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
			){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
				focusCommandLine();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
				return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
			cancelEvent(event);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
	function onCommandLineKeyDown(e){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
		var dk = dojo.keys;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
		if(e.keyCode == 13 && commandLine.value){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
			addToHistory(commandLine.value);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
			evalCommandLine();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
		}else if(e.keyCode == 27){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
			commandLine.value = "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
		}else if(e.keyCode == dk.UP_ARROW || e.charCode == dk.UP_ARROW){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
			navigateHistory("older");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
		}else if(e.keyCode == dk.DOWN_ARROW || e.charCode == dk.DOWN_ARROW){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
			navigateHistory("newer");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
		}else if(e.keyCode == dk.HOME || e.charCode == dk.HOME){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
			historyPosition = 1;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
			navigateHistory("older");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
		}else if(e.keyCode == dk.END || e.charCode == dk.END){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
			historyPosition = 999999;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
			navigateHistory("newer");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
	var historyPosition = -1;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
	var historyCommandLine = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
	function addToHistory(value){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
		var history = cookie("firebug_history");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
		history = (history) ? dojo.fromJson(history) : [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
		var pos = dojo.indexOf(history, value);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
		if (pos != -1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
			history.splice(pos, 1);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
		history.push(value);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
		cookie("firebug_history", dojo.toJson(history), 30);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
		while(history.length && !cookie("firebug_history")){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
			history.shift();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
			cookie("firebug_history", dojo.toJson(history), 30);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
		historyCommandLine = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
		historyPosition = -1;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
	function navigateHistory(direction){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
		var history = cookie("firebug_history");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
		history = (history) ? dojo.fromJson(history) : [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
		if(!history.length){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
			return;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
		if(historyCommandLine === null){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
			historyCommandLine = commandLine.value;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
		if(historyPosition == -1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
			historyPosition = history.length;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
		if(direction == "older"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
			--historyPosition;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
			if(historyPosition < 0){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
				historyPosition = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
		}else if(direction == "newer"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
			++historyPosition;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
			if(historyPosition > history.length){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
				historyPosition = history.length;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
		if(historyPosition == history.length){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
			commandLine.value = historyCommandLine;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
			historyCommandLine = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
			commandLine.value = history[historyPosition];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
	function cookie(name, value){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
		var c = document.cookie;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
		if(arguments.length == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
			var matches = c.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
			return matches ? decodeURIComponent(matches[1]) : undefined; // String or undefined
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
			var d = new Date();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
			d.setMonth(d.getMonth()+1);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
			document.cookie = name + "=" + encodeURIComponent(value) + ((d.toUtcString) ? "; expires=" + d.toUTCString() : "");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
	function isArray(it){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
		return it && it instanceof Array || typeof it == "array";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
	//***************************************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
	// Print Object Helpers
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
	function objectLength(o){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
		var cnt = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
		for(var nm in o){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
			cnt++;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
		return cnt;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
	function printObject(o, i, txt, used){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
		// Recursively trace object, indenting to represent depth for display in object inspector
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
		var ind = " \t";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
		txt = txt || "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
		i = i || ind;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
		used = used || [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
		var opnCls;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
		if(o && o.nodeType == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
			var html = [];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
			appendNode(o, html);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
			return html.join("");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
		var br=",\n", cnt = 0, length = objectLength(o);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
		if(o instanceof Date){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
			return i + o.toString() + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
		looking:
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
		for(var nm in o){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
			cnt++;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
			if(cnt==length){br = "\n";}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
			if(o[nm] === window || o[nm] === document){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
				// do nothing
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
			}else if(o[nm] === null){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
				txt += i+nm + " : NULL" + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
			}else if(o[nm] && o[nm].nodeType){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
				if(o[nm].nodeType == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
					//txt += i+nm + " : < "+o[nm].tagName+" id=\""+ o[nm].id+"\" />" + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
				}else if(o[nm].nodeType == 3){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
					txt += i+nm + " : [ TextNode "+o[nm].data + " ]" + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
			}else if(typeof o[nm] == "object" && (o[nm] instanceof String || o[nm] instanceof Number || o[nm] instanceof Boolean)){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
				txt += i+nm + " : " + o[nm] + "," + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
			}else if(o[nm] instanceof Date){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
				txt += i+nm + " : " + o[nm].toString() + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
			}else if(typeof(o[nm]) == "object" && o[nm]){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
				for(var j = 0, seen; seen = used[j]; j++){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
					if(o[nm] === seen){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
						txt += i+nm + " : RECURSION" + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
						continue looking;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
					}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
				used.push(o[nm]);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
				opnCls = (isArray(o[nm]))?["[","]"]:["{","}"];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
				txt += i+nm +" : " + opnCls[0] + "\n";//non-standard break, (no comma)
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
				txt += printObject(o[nm], i+ind, "", used);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
				txt += i + opnCls[1] + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
			}else if(typeof o[nm] == "undefined"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
				txt += i+nm + " : undefined" + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
			}else if(nm == "toString" && typeof o[nm] == "function"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
				var toString = o[nm]();
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
				if(typeof toString == "string" && toString.match(/function ?(.*?)\(/)){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
					toString = escapeHTML(getObjectAbbr(o[nm]));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
				txt += i+nm +" : " + toString + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
				txt += i+nm +" : "+ escapeHTML(getObjectAbbr(o[nm])) + br;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
		return txt;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
	function getObjectAbbr(obj){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
		// Gets an abbreviation of an object for display in log
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
		// X items in object, including id
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
		// X items in an array
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
		// TODO: Firebug Sr. actually goes by char count
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
		var isError = (obj instanceof Error);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
		if(obj.nodeType == 1){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
			return escapeHTML('< '+obj.tagName.toLowerCase()+' id=\"'+ obj.id+ '\" />');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
		if(obj.nodeType == 3){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
			return escapeHTML('[TextNode: "'+obj.nodeValue+'"]');
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
		var nm = (obj && (obj.id || obj.name || obj.ObjectID || obj.widgetId));
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
		if(!isError && nm){ return "{"+nm+"}";	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
		var obCnt = 2;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
		var arCnt = 4;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
		var cnt = 0;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
		if(isError){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
			nm = "[ Error: "+(obj.message || obj.description || obj)+" ]";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
		}else if(isArray(obj)){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
			nm = "[" + obj.slice(0,arCnt).join(",");
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
			if(obj.length > arCnt){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
				nm += " ... ("+obj.length+" items)";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
			nm += "]";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
		}else if(typeof obj == "function"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
			nm = obj + "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
			var reg = /function\s*([^\(]*)(\([^\)]*\))[^\{]*\{/;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
			var m = reg.exec(nm);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
			if(m){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
				if(!m[1]){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
					m[1] = "function";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
				}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
				nm = m[1] + m[2];
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
			}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
				nm = "function()";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
		}else if(typeof obj != "object" || typeof obj == "string"){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
			nm = obj + "";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
		}else{
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
			nm = "{";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
			for(var i in obj){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
				cnt++;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
				if(cnt > obCnt){ break; }
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
				nm += i+":"+escapeHTML(obj[i])+"  ";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
			}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
			nm+="}";
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
		}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
		return nm;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
	//*************************************************************************************
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
	//window.onerror = onError;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
	addEvent(document, has("ie") || has("safari") ? "keydown" : "keypress", onKeyDown);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
	if(	(document.documentElement.getAttribute("debug") == "true")||
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
		(dojo.config.isDebug)
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
	){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
		toggleConsole(true);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
	}
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
	dojo.addOnWindowUnload(function(){
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
		// Erase the globals and event handlers I created, to prevent spurious leak warnings
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
		removeEvent(document, has("ie") || has("safari") ? "keydown" : "keypress", onKeyDown);
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
		window.onFirebugResize = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1188
		window.console = null;
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
	});
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
948283342245 Session moderator + test in model
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
});