debug.xul

Summary

Formats and displays all of the debugging messages stored in the mozileDebugList of the document which opens this file.

Version: 0.7.0

Author: James A. Overton


<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="widgets.css" type="text/css"?>

<!--
/* ***** BEGIN LICENSE BLOCK *****
 * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * Full Terms at http://mozile.mozdev.org/license.html
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Playsophy code (www.playsophy.com).
 *
 * The Initial Developer of the Original Code is Playsophy
 * Portions created by the Initial Developer are Copyright (C) 2002-2003
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *	James A. Overton <james@overton.ca>
 *
 * ***** END LICENSE BLOCK ***** */


/** Mozile Debug Dialog
 * @fileoverview Formats and displays all of the debugging messages stored in the mozileDebugList of the document which opens this file.
 * 
 * @link http://mozile.mozdev.org 
 * @author James A. Overton <james@overton.ca>
 * @version 0.7.0
 */

-->

<window xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        id="mozile-debuggingDialog"
        buttons="accept"
        title="debug:Mozile"
        onload="mozileDebugInit(event);">

	<script type="application/x-javascript">
	
	
/** Mozile Debug - Init -
 * Initializes the debugging dialog.
 *
 * @param event The event object which triggers the initialization.
 * @return Always true.
 */
function mozileDebugInit(event) {
	if (event.target != document) return;
	document.getElementById('version').value=opener.mozile.version;
	mozileDebugReset(event);
}

	
/** Mozile Debug - Reset -
 * Clears the filter and rebuilds the bug list.
 *
 * @param event The event object which triggers the initialization.
 * @return Always true.
 */
function mozileDebugReset(event) {
	var mozileDebugList = opener.mozileDebugList;
	var vbox = document.getElementById("bugs");
	mozileDebugRemoveChildren(vbox);
	for(var i=0; i &lt; mozileDebugList.length; i++) {
		var bug = mozileDebugList[i];

		var hbox = document.createElement("hbox");
		hbox.setAttribute("class", "level"+bug[2]);
		
		var datestamp = document.createElement("description");
		datestamp.setAttribute("class","datestamp");
		datestamp.setAttribute("value",bug[0]);
		hbox.appendChild(datestamp);
		
		var functions = document.createElement("description");
		functions.setAttribute("class","functions");
		functions.setAttribute("value", "["+ bug[1] +"]");
		hbox.appendChild(functions);
		
		var message = document.createElement("description");
		message.setAttribute("class","message");
		message.setAttribute("value",bug[3]);
		hbox.appendChild(message);
		
		vbox.appendChild(hbox);
	}
	document.getElementById('filterText').value = "";
	document.getElementById('filterLevel').selectedIndex=3;
	document.getElementById('messageCount').value="Showing "+mozileDebugList.length+" of "+mozileDebugList.length+" Messages";
}

	
/** Mozile Debug - Clear -
 * Clears the list and empties the mozileDebugArray.
 *
 * @param event The event object which triggers the initialization.
 * @return Always true.
 */
function mozileDebugClear(event) {
	opener.mozileDebugList = new Array();
	mozileDebugReset(event);
}

	
/** Mozile Debug - Filter -
 * Rebuilds the bug list, filtering based on the content of the filterText input field.
 *
 * @return Always true.
 */
function mozileDebugFilter() {
	//alert("Filtering Level: "+node.value);	
	
	var selected = document.getElementById('filterLevel').value;		// get the value of the Filter Level menu
	var text = document.getElementById('filterText').value;		// get the Filter Text
	var mozileDebugList = opener.mozileDebugList;
	var vbox = document.getElementById("bugs");
	var count = 0;
	mozileDebugRemoveChildren(vbox);
	for(var i=0; i &lt; mozileDebugList.length; i++) {
		var bug = mozileDebugList[i];

		if(selected &lt;= bug[2]) continue;			// if the selected level is lower, ignore this entry
			// search each of the field, and keep a total
		var search = bug[0].search(text) + bug[1][0].search(text) + bug[1][1].search(text) + bug[3].search(text);
			// if all the results were "-1", then skip this entry
		if( search == -4 ) continue;
		
		count++;
		
			// Build the entry
		var hbox = document.createElement("hbox");
		hbox.setAttribute("class", "level"+bug[2]);
		
		var datestamp = document.createElement("description");
		datestamp.setAttribute("class","datestamp");
		datestamp.setAttribute("value",bug[0]);
		hbox.appendChild(datestamp);
		
		var functions = document.createElement("description");
		functions.setAttribute("class","functions");
		functions.setAttribute("value", "["+ bug[1] +"]");
		hbox.appendChild(functions);
		
		var message = document.createElement("description");
		message.setAttribute("class","message");
		message.setAttribute("value",bug[3]);
		hbox.appendChild(message);
		
		vbox.appendChild(hbox);
	}
	document.getElementById('messageCount').value="Showing "+count+" of "+mozileDebugList.length+" Messages";

}

	
/** Mozile Debug - Remove Children -
 * Removes all children of the given node.
 *
 * @param node The node to be cleaned up.
 * @return The empty node.
 */
function mozileDebugRemoveChildren(node) {	
	while(node.childNodes.length) {
		node.parentNode.removeChild(node.firstChild);
	}
	return node;
}
	
	</script>

	<hbox class="header">
		<label value="debug:Mozile" />
		<spacer flex="1"/>
		<label id="version" value="version?" />
	</hbox>

	<vbox id="bugs" onclick="this.focus()" flex="1">
	</vbox>
	
	<hbox class="filters" align="center">
		<textbox id="filterText" oninput="mozileDebugFilter()" flex="1"/>
		<button label="Reset" onclick="mozileDebugReset()"/>
		<menulist id="filterLevel" oncommand="mozileDebugFilter()">
            <menupopup>
                <menuitem label="Critical Messages" value="1"/>
                <menuitem label="Serious Messages" value="2"/>
                <menuitem label="Significant Messages" value="3"/>
                <menuitem label="All Messages" value="4" selected="true"/>
            </menupopup>
		</menulist>
	</hbox>
	<hbox pack="start" align="center">
		<label id="messageCount" value="Showing 0 Messages"/>
		<spacer flex="1"/>
		<button label="Refresh" onclick="mozileDebugFilter()"/>
		<button label="Clear" onclick="mozileDebugClear(this)"/>
		<button label="Close" onclick="window.close()"/>
	</hbox>

</window>



Documentation generated by JSDoc on Wed Jun 29 22:15:33 2005