зеркало из https://github.com/mozilla/pjs.git
Forking jsconsole.
This commit is contained in:
Родитель
88f1ddada1
Коммит
047f15593a
|
@ -2412,7 +2412,7 @@ function toDownloadManager()
|
|||
|
||||
function toJavaScriptConsole()
|
||||
{
|
||||
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
|
||||
toOpenWindowByType("global:console", "chrome://browser/content/console/console.xul");
|
||||
}
|
||||
|
||||
function javaItemEnabling()
|
||||
|
@ -2480,10 +2480,8 @@ function OpenTaskURL( inURL )
|
|||
window.open( inURL );
|
||||
}
|
||||
|
||||
function goAboutDialog()
|
||||
function openAboutDialog()
|
||||
{
|
||||
// XXXBlake -- the about dialog should be modal, but then clicking the link in it just opens
|
||||
// a blank browser window (the page isn't loaded).
|
||||
window.openDialog("chrome://browser/content/aboutDialog.xul", "About", "modal,centerscreen,chrome,resizable=no");
|
||||
}
|
||||
|
||||
|
|
|
@ -671,12 +671,9 @@ Contributor(s):
|
|||
label="&releaseCmd.label;"
|
||||
oncommand="openTopWin('&releaseURL;');"/>
|
||||
<menuseparator/>
|
||||
<menuitem accesskey="&aboutCommPluginsCmd.accesskey;"
|
||||
label="&aboutCommPluginsCmd.label;"
|
||||
oncommand="openTopWin('about:plugins')"/>
|
||||
<menuitem accesskey="&aboutCmd.accesskey;"
|
||||
label="&aboutCmd.label;"
|
||||
oncommand="goAboutDialog();"/>
|
||||
oncommand="openAboutDialog();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
|
|
@ -155,11 +155,9 @@
|
|||
<!ENTITY helpMenu.accesskey "H">
|
||||
|
||||
<!ENTITY releaseCmd.label "Release Notes">
|
||||
<!ENTITY releaseCmd.accesskey "r">
|
||||
<!ENTITY releaseCmd.accesskey "R">
|
||||
<!ENTITY aboutCmd.label "About &brandShortName;">
|
||||
<!ENTITY aboutCmd.accesskey "A">
|
||||
<!ENTITY aboutCommPluginsCmd.label "About Plug-ins">
|
||||
<!ENTITY aboutCommPluginsCmd.accesskey "P">
|
||||
|
||||
<!ENTITY openCmd.commandkey "l">
|
||||
|
||||
|
|
|
@ -42,6 +42,6 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = prefwindow history bookmarks
|
||||
DIRS = prefwindow history bookmarks console
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
.console-box {
|
||||
-moz-binding: url("chrome://global/content/consoleBindings.xml#console-box");
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.console-rows {
|
||||
-moz-user-focus: normal;
|
||||
}
|
||||
|
||||
.console-row[type="error"],
|
||||
.console-row[type="warning"] {
|
||||
-moz-binding: url("chrome://global/content/consoleBindings.xml#error");
|
||||
}
|
||||
|
||||
.console-row[type="message"] {
|
||||
-moz-binding: url("chrome://global/content/consoleBindings.xml#message");
|
||||
}
|
||||
|
||||
.console-error-msg {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.console-msg-text {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.console-error-source {
|
||||
-moz-binding: url("chrome://global/content/consoleBindings.xml#console-error-source");
|
||||
}
|
||||
|
||||
/* :::::::::: hiding and showing of rows for each mode :::::::::: */
|
||||
|
||||
.console-box[mode="Warnings"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="error"],
|
||||
.console-box[mode="Messages"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="error"]
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.console-box[mode="Errors"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="warning"],
|
||||
.console-box[mode="Messages"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="warning"]
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.console-box[mode="Errors"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="message"],
|
||||
.console-box[mode="Warnings"] > .console-box-internal > .console-rows
|
||||
> .console-row[type="message"]
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var gConsole, gConsoleBundle;
|
||||
|
||||
/* :::::::: Console Initialization ::::::::::::::: */
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
gConsole = document.getElementById("ConsoleBox");
|
||||
gConsoleBundle = document.getElementById("ConsoleBundle");
|
||||
|
||||
top.controllers.insertControllerAt(0, ConsoleController);
|
||||
|
||||
updateSortCommand(gConsole.sortOrder);
|
||||
updateModeCommand(gConsole.mode);
|
||||
|
||||
var iframe = document.getElementById("Evaluator");
|
||||
iframe.addEventListener("load", displayResult, true);
|
||||
}
|
||||
|
||||
/* :::::::: Console UI Functions ::::::::::::::: */
|
||||
|
||||
function changeMode(aMode)
|
||||
{
|
||||
switch (aMode) {
|
||||
case "Errors":
|
||||
case "Warnings":
|
||||
case "Messages":
|
||||
gConsole.mode = aMode;
|
||||
break;
|
||||
case "All":
|
||||
gConsole.mode = null;
|
||||
}
|
||||
|
||||
document.persist("ConsoleBox", "mode");
|
||||
}
|
||||
|
||||
function clearConsole()
|
||||
{
|
||||
gConsole.clear();
|
||||
}
|
||||
|
||||
function changeSortOrder(aOrder)
|
||||
{
|
||||
updateSortCommand(gConsole.sortOrder = aOrder);
|
||||
}
|
||||
|
||||
function updateSortCommand(aOrder)
|
||||
{
|
||||
var orderString = aOrder == 'reverse' ? "Descend" : "Ascend";
|
||||
var bc = document.getElementById("Console:sort"+orderString);
|
||||
bc.setAttribute("checked", true);
|
||||
|
||||
orderString = aOrder == 'reverse' ? "Ascend" : "Descend";
|
||||
bc = document.getElementById("Console:sort"+orderString);
|
||||
bc.setAttribute("checked", false);
|
||||
}
|
||||
|
||||
function updateModeCommand(aMode)
|
||||
{
|
||||
var bc = document.getElementById("Console:mode" + aMode);
|
||||
bc.setAttribute("checked", true);
|
||||
}
|
||||
|
||||
function toggleToolbar(aEl)
|
||||
{
|
||||
var bc = document.getElementById(aEl.getAttribute("observes"));
|
||||
var truth = bc.getAttribute("checked");
|
||||
bc.setAttribute("checked", truth != "true");
|
||||
var toolbar = document.getElementById(bc.getAttribute("_toolbar"));
|
||||
toolbar.setAttribute("hidden", truth);
|
||||
|
||||
document.persist(toolbar.id, "hidden");
|
||||
document.persist(bc.id, "checked");
|
||||
}
|
||||
|
||||
function copyItemToClipboard()
|
||||
{
|
||||
gConsole.copySelectedItem();
|
||||
}
|
||||
|
||||
function isItemSelected()
|
||||
{
|
||||
return gConsole.selectedItem != null;
|
||||
}
|
||||
|
||||
function UpdateCopyMenu()
|
||||
{
|
||||
goUpdateCommand("cmd_copy");
|
||||
}
|
||||
|
||||
function onEvalKeyPress(aEvent)
|
||||
{
|
||||
if (aEvent.keyCode == 13)
|
||||
evaluateTypein();
|
||||
}
|
||||
|
||||
function evaluateTypein()
|
||||
{
|
||||
var code = document.getElementById("TextboxEval").value;
|
||||
var iframe = document.getElementById("Evaluator");
|
||||
iframe.setAttribute("src", "javascript: " + code);
|
||||
}
|
||||
|
||||
function displayResult()
|
||||
{
|
||||
var result = Evaluator.document.documentElement.lastChild.firstChild;
|
||||
if (result && result.data)
|
||||
gConsole.mCService.logStringMessage(result.data);
|
||||
// or could use appendMessage which doesn't persist
|
||||
}
|
||||
|
||||
/* :::::::: Command Controller for the Window ::::::::::::::: */
|
||||
|
||||
var ConsoleController =
|
||||
{
|
||||
isCommandEnabled: function (aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_copy":
|
||||
return isItemSelected();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
supportsCommand: function (aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_copy":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function (aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_copy":
|
||||
copyItemToClipboard();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function (aEvent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// XXX DEBUG
|
||||
|
||||
function debug(aText)
|
||||
{
|
||||
var csClass = Components.classes['@mozilla.org/consoleservice;1'];
|
||||
var cs = csClass.getService(Components.interfaces.nsIConsoleService);
|
||||
cs.logStringMessage(aText);
|
||||
}
|
||||
|
||||
function getStackTrace()
|
||||
{
|
||||
var frame = Components.stack.caller;
|
||||
var str = "";
|
||||
while (frame) {
|
||||
if (frame.filename)
|
||||
str += frame.filename + ", Line " + frame.lineNumber;
|
||||
else
|
||||
str += "[" + gConsoleBundle.getString("noFile") + "]";
|
||||
|
||||
str += " --> ";
|
||||
|
||||
if (frame.functionName)
|
||||
str += frame.functionName;
|
||||
else
|
||||
str += "[" + gConsoleBundle.getString("noFunction") + "]";
|
||||
|
||||
str += "\n";
|
||||
|
||||
frame = frame.caller;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function openAboutDialog()
|
||||
{
|
||||
window.openDialog("chrome://browser/content/aboutDialog.xul", "About", "modal,centerscreen,chrome,resizable=no");
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
<?xml version="1.0"?> <!-- -*- tab-width: 4; indent-tabs-mode: nil -*- -->
|
||||
|
||||
<!-- The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
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 Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s): Joe Hewitt <hewitt@netscape.com>
|
||||
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/console.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://global/content/console.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % console SYSTEM "chrome://global/locale/console.dtd"> %console;
|
||||
<!ENTITY % util SYSTEM "chrome://communicator/locale/utilityOverlay.dtd"> %util;
|
||||
<!ENTITY % globalRegionDTD SYSTEM "chrome://global-region/locale/region.dtd"> %globalRegionDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" > %brandDTD;
|
||||
]>
|
||||
|
||||
<window id="JSConsoleWindow"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&console.title;"
|
||||
windowtype="global:console"
|
||||
width="640" height="480"
|
||||
screenX="10" screenY="10"
|
||||
persist="screenX screenY width height">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/console/console.js"/>
|
||||
|
||||
<stringbundle id="ConsoleBundle" src="chrome://global/locale/console.properties"/>
|
||||
<command id="cmd_copy" oncommand="copyItemToClipboard()"/>
|
||||
<command id="cmd_close" oncommand="window.close()"/>
|
||||
|
||||
<broadcaster id="Console:clear" label="&clear.label;" oncommand="clearConsole();"/>
|
||||
|
||||
<broadcaster id="Console:sortAscend" label="&sortFirst.label;"
|
||||
accesskey="&sortFirst.accesskey;"
|
||||
oncommand="changeSortOrder('forward');"/>
|
||||
<broadcaster id="Console:sortDescend" label="&sortLast.label;"
|
||||
accesskey="&sortLast.accesskey;"
|
||||
oncommand="changeSortOrder('reverse');"/>
|
||||
|
||||
<broadcaster id="Console:toggleToolbarMode" label="&toolbarMode.label;"
|
||||
oncommand="toggleToolbar(this);" checked="true"
|
||||
_toolbar="ToolbarMode"/>
|
||||
<broadcaster id="Console:toggleToolbarEval" label="&toolbarEval.label;"
|
||||
oncommand="toggleToolbar(this);" checked="true"
|
||||
_toolbar="ToolbarEval"/>
|
||||
|
||||
<broadcasterset id="ModeBroadcasters">
|
||||
<broadcaster id="Console:modeAll" label="&all.label;"
|
||||
oncommand="changeMode('All');"/>
|
||||
<broadcaster id="Console:modeErrors" label="&errors.label;"
|
||||
oncommand="changeMode('Errors');"/>
|
||||
<broadcaster id="Console:modeWarnings" label="&warnings.label;"
|
||||
oncommand="changeMode('Warnings');"/>
|
||||
<broadcaster id="Console:modeMessages" label="&messages.label;"
|
||||
oncommand="changeMode('Messages');"/>
|
||||
</broadcasterset>
|
||||
|
||||
<keyset>
|
||||
<key id="key_copy"/>
|
||||
<key id="key_close"/>
|
||||
</keyset>
|
||||
|
||||
<popupset id="ContextMenus">
|
||||
<popup id="ConsoleContext" onpopupshowing="UpdateCopyMenu()">
|
||||
<menuitem type="radio" observes="Console:sortAscend"/>
|
||||
<menuitem type="radio" observes="Console:sortDescend"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_copy_cm" observes="cmd_copy" label="©Cmd.label;" accesskey="©Cmd.accesskey;"/>
|
||||
</popup>
|
||||
</popupset>
|
||||
|
||||
<toolbox>
|
||||
<menubar id="main-menubar" class="chromeclass-menubar" grippytooltiptext="&menuBar.tooltip;">
|
||||
<menu label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem id="menu_close"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="menu_Edit">
|
||||
<menupopup onpopupshowing="UpdateCopyMenu()">
|
||||
<menuitem id="menu_copy"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu id="menu_View">
|
||||
<menupopup>
|
||||
<menu label="&toolbarsCmd.label;" accesskey="&toolbarsCmd.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem type="checkbox" observes="Console:toggleToolbarMode"/>
|
||||
<menuitem type="checkbox" observes="Console:toggleToolbarEval"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem type="radio" observes="Console:sortAscend"/>
|
||||
<menuitem type="radio" observes="Console:sortDescend"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu label="&helpMenu.label;"
|
||||
accesskey="&helpMenu.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem accesskey="&releaseCmd.accesskey;"
|
||||
label="&releaseCmd.label;"
|
||||
oncommand="openTopWin('&releaseURL;');"/>
|
||||
<menuseparator/>
|
||||
<menuitem accesskey="&aboutCmd.accesskey;"
|
||||
label="&aboutCmd.label;"
|
||||
oncommand="openAboutDialog();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
||||
<toolbar class="chromeclass-toolbar" id="ToolbarMode" grippytooltiptext="&modeToolbar.tooltip;">
|
||||
<toolbarbutton type="radio" group="mode" observes="Console:modeAll"/>
|
||||
<toolbarbutton type="radio" group="mode" observes="Console:modeErrors"/>
|
||||
<toolbarbutton type="radio" group="mode" observes="Console:modeWarnings"/>
|
||||
<toolbarbutton type="radio" group="mode" observes="Console:modeMessages"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton observes="Console:clear"/>
|
||||
</toolbar>
|
||||
|
||||
<toolbar class="chromeclass-toolbar" id="ToolbarEval" grippytooltiptext="&entryToolbar.tooltip;">
|
||||
<textbox id="TextboxEval" class="toolbar" value="" onkeypress="onEvalKeyPress(event)" flex="1"/>
|
||||
<toolbarbutton id="ButtonEval" label="&evaluate.label;" oncommand="evaluateTypein()"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<vbox id="ConsoleBox" class="console-box" flex="1" context="ConsoleContext" persist="sortOrder"/>
|
||||
|
||||
<iframe name="Evaluator" id="Evaluator" collapsed="true"/>
|
||||
|
||||
</window>
|
||||
|
||||
|
|
@ -0,0 +1,419 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://global/locale/console.dtd">
|
||||
|
||||
<bindings id="consoleBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="console-box" extends="xul:box">
|
||||
<content>
|
||||
<xul:stringbundle src="chrome://global/locale/console.properties" role="string-bundle"/>
|
||||
<xul:vbox class="console-box-internal">
|
||||
<xul:vbox class="console-rows" role="console-rows" xbl:inherits="dir=sortOrder"/>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<field name="limit" readonly="true">
|
||||
250
|
||||
</field>
|
||||
<field name="_showChromeErrors">-1</field>
|
||||
|
||||
<property name="showChromeErrors">
|
||||
<getter><![CDATA[
|
||||
if (this._showChromeErrors != -1)
|
||||
return this._showChromeErrors;
|
||||
var pref = Components.classes['@mozilla.org/preferences-service;1'].getService();
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
try {
|
||||
return this._showChromeErrors = pref.getBoolPref("javascript.options.showInConsole");
|
||||
}
|
||||
catch(ex) {
|
||||
return this._showChromeErrors = false;
|
||||
}
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="count" readonly="true">
|
||||
<getter>return this.mCount</getter>
|
||||
</property>
|
||||
|
||||
<property name="mode">
|
||||
<getter>return this.mMode;</getter>
|
||||
<setter><![CDATA[
|
||||
this.mMode = val || "All";
|
||||
this.setAttribute("mode", this.mMode);
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<property name="sortOrder">
|
||||
<getter>return this.getAttribute("sortOrder");</getter>
|
||||
<setter>this.setAttribute("sortOrder", val); return val;</setter>
|
||||
</property>
|
||||
<field name="mSelectedItem">null</field>
|
||||
<property name="selectedItem">
|
||||
<getter>return this.mSelectedItem</getter>
|
||||
<setter><![CDATA[
|
||||
if (this.mSelectedItem)
|
||||
this.mSelectedItem.removeAttribute("selected");
|
||||
|
||||
this.mSelectedItem = val;
|
||||
val.setAttribute("selected", "true");
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<method name="init">
|
||||
<body><![CDATA[
|
||||
this.mCount = 0;
|
||||
|
||||
this.mConsoleListener = {
|
||||
console: this,
|
||||
observe : function(aObject) { this.console.appendItem(aObject); }
|
||||
};
|
||||
|
||||
this.mConsoleRowBox = this.getAnonElByAttr("role", "console-rows");
|
||||
this.mStrBundle = this.getAnonElByAttr("role", "string-bundle");
|
||||
|
||||
try {
|
||||
var isupports = Components.classes['@mozilla.org/consoleservice;1'].getService();
|
||||
this.mCService = isupports.QueryInterface(Components.interfaces.nsIConsoleService);
|
||||
this.mCService.registerListener(this.mConsoleListener);
|
||||
} catch (ex) {
|
||||
appendItem(
|
||||
"Unable to display errors - couldn't get Console Service component. " +
|
||||
"(Missing @mozilla.org/consoleservice;1)");
|
||||
return;
|
||||
}
|
||||
|
||||
this.mMode = this.getAttribute("mode") || "All";
|
||||
|
||||
this.appendInitialItems();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="destroy">
|
||||
<body><![CDATA[
|
||||
this.mCService.unregisterListener(this.mConsoleListener);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendInitialItems">
|
||||
<body><![CDATA[
|
||||
var out = {}; // Throwaway references to support 'out' parameters.
|
||||
this.mCService.getMessageArray(out, {});
|
||||
var messages = out.value;
|
||||
|
||||
// In case getMessageArray returns 0-length array as null
|
||||
if (!messages)
|
||||
messages = [];
|
||||
|
||||
var limit = messages.length - this.limit;
|
||||
if (limit < 0) limit = 0;
|
||||
|
||||
// Checks if console ever been cleared
|
||||
for (var i = messages.length - 1; i >= limit; --i)
|
||||
if (!messages[i].message)
|
||||
break;
|
||||
|
||||
// Populate with messages after latest "clear"
|
||||
while (++i < messages.length)
|
||||
this.appendItem(messages[i]);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendItem">
|
||||
<parameter name="aObject"/>
|
||||
<body><![CDATA[
|
||||
if (!aObject.message) return;
|
||||
|
||||
try {
|
||||
// Try to QI it to a script error to get more info
|
||||
var scriptError = aObject.QueryInterface(Components.interfaces.nsIScriptError);
|
||||
|
||||
// filter chrome urls
|
||||
if (!this.showChromeErrors && scriptError.sourceName.substr(0, 9) == "chrome://")
|
||||
return;
|
||||
|
||||
this.appendError(scriptError);
|
||||
} catch (ex) {
|
||||
try {
|
||||
// Try to QI it to a console message
|
||||
var msg = aObject.QueryInterface(Components.interfaces.nsIConsoleMessage);
|
||||
this.appendMessage(msg.message);
|
||||
} catch (ex2) {
|
||||
// Give up and append the object itself as a string
|
||||
this.appendMessage(aObject);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendError">
|
||||
<parameter name="aObject"/>
|
||||
<body><![CDATA[
|
||||
var row = this.createConsoleRow();
|
||||
var nsIScriptError = Components.interfaces.nsIScriptError;
|
||||
|
||||
// Is this error actually just a non-fatal warning?
|
||||
var warning = aObject.flags & nsIScriptError.warningFlag != 0;
|
||||
|
||||
var typetext = warning ? "typeWarning" : "typeError";
|
||||
row.setAttribute("typetext", this.mStrBundle.getString(typetext));
|
||||
row.setAttribute("type", warning ? "warning" : "error");
|
||||
row.setAttribute("msg", aObject.message);
|
||||
if (aObject.lineNumber || aObject.sourceName) {
|
||||
row.setAttribute("url", aObject.sourceName);
|
||||
row.setAttribute("line", aObject.lineNumber);
|
||||
} else {
|
||||
row.setAttribute("hideSource", "true");
|
||||
}
|
||||
if (aObject.sourceLine) {
|
||||
row.setAttribute("code", aObject.sourceLine.replace("\n", "", "g"));
|
||||
if (aObject.columnNumber) {
|
||||
row.setAttribute("col", aObject.columnNumber);
|
||||
row.setAttribute("errorDots", this.repeatChar(" ", aObject.columnNumber));
|
||||
row.setAttribute("errorCaret", " ");
|
||||
} else {
|
||||
row.setAttribute("hideCaret", "true");
|
||||
}
|
||||
} else {
|
||||
row.setAttribute("hideCode", "true");
|
||||
}
|
||||
this.appendConsoleRow(row);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendMessage">
|
||||
<parameter name="aMessage"/>
|
||||
<parameter name="aType"/>
|
||||
<body><![CDATA[
|
||||
var row = this.createConsoleRow();
|
||||
row.setAttribute("type", aType || "message");
|
||||
row.setAttribute("msg", aMessage);
|
||||
this.appendConsoleRow(row);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="clear">
|
||||
<body><![CDATA[
|
||||
this.mCService.logStringMessage(null);
|
||||
this.mCount = 0;
|
||||
|
||||
var newRows = this.mConsoleRowBox.cloneNode(false);
|
||||
this.mConsoleRowBox.parentNode.replaceChild(newRows, this.mConsoleRowBox);
|
||||
this.mConsoleRowBox = newRows;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="copySelectedItem">
|
||||
<body><![CDATA[
|
||||
if (this.mSelectedItem)
|
||||
this.copyString(this.mSelectedItem.toString());
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="createConsoleRow">
|
||||
<body><![CDATA[
|
||||
var row = document.createElement("box");
|
||||
row.setAttribute("class", "console-row");
|
||||
row._IsConsoleRow = true;
|
||||
row._ConsoleBox = this;
|
||||
return row;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendConsoleRow">
|
||||
<parameter name="aRow"/>
|
||||
<body><![CDATA[
|
||||
this.mConsoleRowBox.appendChild(aRow);
|
||||
if (++this.mCount > this.limit) this.deleteFirst();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="deleteFirst">
|
||||
<body><![CDATA[
|
||||
var node = this.mConsoleRowBox.firstChild;
|
||||
this.mConsoleRowBox.removeChild(node);
|
||||
--this.mCount;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- UTILITY FUNCTIONS -->
|
||||
|
||||
<!-- We need this method only because document.getAnonymousElementByAttribute
|
||||
is crashing (as of 2/26/2001) -->
|
||||
<method name="getAnonElByAttr">
|
||||
<parameter name="aAttr"/>
|
||||
<parameter name="aVal"/>
|
||||
<body><![CDATA[
|
||||
var kids = document.getAnonymousNodes(this);
|
||||
for (var i = 0; i < kids.length; ++i) {
|
||||
if (kids[i].getAttribute(aAttr) == aVal)
|
||||
return kids[i];
|
||||
var kids2 = kids[i].getElementsByAttribute(aAttr, aVal);
|
||||
if (kids2.length > 0)
|
||||
return kids2[0];
|
||||
}
|
||||
return null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="repeatChar">
|
||||
<parameter name="aChar"/>
|
||||
<parameter name="aCol"/>
|
||||
<body><![CDATA[
|
||||
var str = "";
|
||||
if (aCol)
|
||||
for (var i = 1; i < aCol; ++i)
|
||||
str += aChar;
|
||||
|
||||
return str;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="copyString">
|
||||
<parameter name="aString"/>
|
||||
<body><![CDATA[
|
||||
try {
|
||||
const clipURI = "@mozilla.org/widget/clipboard;1";
|
||||
const clipI = Components.interfaces.nsIClipboard;
|
||||
var clipboard = Components.classes[clipURI].getService(clipI);
|
||||
|
||||
const transURI = "@mozilla.org/widget/transferable;1";
|
||||
var transferable = Components.classes[transURI].createInstance(Components.interfaces.nsITransferable);
|
||||
|
||||
transferable.addDataFlavor("text/unicode");
|
||||
|
||||
const strURI = "@mozilla.org/supports-string;1";
|
||||
var wstring = Components.classes[strURI].createInstance(Components.interfaces.nsISupportsString);
|
||||
|
||||
wstring.data = aString;
|
||||
transferable.setTransferData("text/unicode", wstring, aString.length * 2);
|
||||
clipboard.setData(transferable, null, clipI.kGlobalClipboard);
|
||||
} catch (ex) {
|
||||
// Unable to copy anything, die quietly
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<constructor> this.init(); </constructor>
|
||||
<destructor> this.destroy(); </destructor>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="mousedown"><![CDATA[
|
||||
if (event.button == 0 || event.button == 2) {
|
||||
var target = event.originalTarget;
|
||||
|
||||
while (target && !("_IsConsoleRow" in target))
|
||||
target = target.parentNode;
|
||||
|
||||
if (target)
|
||||
this.selectedItem = target;
|
||||
}
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="error" extends="xul:box">
|
||||
<content>
|
||||
<xul:box class="console-row-internal-box" flex="1">
|
||||
<xul:box class="console-row-icon" align="center" xbl:inherits="selected">
|
||||
<xul:image class="console-icon" xbl:inherits="src,type"/>
|
||||
</xul:box>
|
||||
<xul:vbox class="console-row-content" xbl:inherits="selected" flex="1">
|
||||
<xul:box class="console-row-msg" align="start">
|
||||
<xul:label class="label" xbl:inherits="value=typetext"/>
|
||||
<xul:description class="console-error-msg" xbl:inherits="value=msg" flex="1"/>
|
||||
</xul:box>
|
||||
<xul:box class="console-row-file" xbl:inherits="hidden=hideSource">
|
||||
<xul:label class="label" value="&errFile.label;"/>
|
||||
<xul:box class="console-error-source" xbl:inherits="url"/>
|
||||
<spacer flex="1"/>
|
||||
<xul:label class="label" value="&errLine.label;"/>
|
||||
<xul:label class="label" xbl:inherits="value=line" flex="1"/>
|
||||
</xul:box>
|
||||
<xul:vbox class="console-row-code" xbl:inherits="selected,hidden=hideCode">
|
||||
<xul:label class="monospace console-code" xbl:inherits="value=code"/>
|
||||
<xul:box xbl:inherits="hidden=hideCaret">
|
||||
<xul:label class="monospace console-dots" xbl:inherits="value=errorDots"/>
|
||||
<xul:label class="monospace console-caret" xbl:inherits="value=errorCaret"/>
|
||||
<xul:spacer flex="1"/>
|
||||
</xul:box>
|
||||
</xul:vbox>
|
||||
</xul:vbox>
|
||||
</xul:box>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
|
||||
<method name="toString">
|
||||
<body><![CDATA[
|
||||
var msg = this.getAttribute("typetext") + " " + this.getAttribute("msg");
|
||||
|
||||
var strBundle = this._ConsoleBox.mStrBundle;
|
||||
|
||||
if (this.hasAttribute("line") && this.hasAttribute("url")) {
|
||||
msg += "\n" + strBundle.getFormattedString("errFile",
|
||||
[this.getAttribute("url")]) + "\n";
|
||||
if (this.hasAttribute("col")) {
|
||||
msg += strBundle.getFormattedString("errLineCol",
|
||||
[this.getAttribute("line"), this.getAttribute("col")]);
|
||||
} else
|
||||
msg += strBundle.getFormattedString("errLine", [this.getAttribute("line")]);
|
||||
}
|
||||
|
||||
if (this.hasAttribute("code"))
|
||||
msg += "\n" + strBundle.getString("errCode") + "\n" + this.getAttribute("code");
|
||||
|
||||
return msg;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
</binding>
|
||||
|
||||
<binding id="message" extends="xul:box">
|
||||
<content>
|
||||
<xul:box class="console-internal-box" flex="1">
|
||||
<xul:box class="console-row-icon" align="center">
|
||||
<xul:image class="console-icon" xbl:inherits="src,type"/>
|
||||
</xul:box>
|
||||
<xul:vbox class="console-row-content" xbl:inherits="selected" flex="1">
|
||||
<xul:vbox class="console-row-msg" flex="1">
|
||||
<xul:description class="console-msg-text" xbl:inherits="value=msg" flex="1"/>
|
||||
</xul:vbox>
|
||||
</xul:vbox>
|
||||
</xul:box>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<method name="toString">
|
||||
<body><![CDATA[
|
||||
return this.getAttribute("msg");
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="console-error-source" extends="xul:box">
|
||||
<content>
|
||||
<xul:label class="text-link" xbl:inherits="value=url" crop="right"/>
|
||||
</content>
|
||||
|
||||
<handlers>
|
||||
<handler event="click"><![CDATA[
|
||||
window.openDialog(
|
||||
"chrome://navigator/content/viewSource.xul", "_blank",
|
||||
"scrollbars,resizable,chrome,dialog=no", this.getAttribute("url"));
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
browser.jar:
|
||||
content/browser/console/console.js (content/console.js)
|
||||
content/browser/console/console.xul (content/console.xul)
|
||||
content/browser/console/console.css (content/console.css)
|
||||
content/browser/console/consoleBindings.xml (content/consoleBindings.xml)
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/browser/console/console.dtd (locale/console.dtd)
|
||||
locale/en-US/browser/console/console.properties (locale/console.properties)
|
|
@ -0,0 +1,54 @@
|
|||
<!-- The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
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 Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________. -->
|
||||
|
||||
<!ENTITY console.title "JavaScript Console">
|
||||
|
||||
<!ENTITY menuBar.tooltip "Menu Bar">
|
||||
<!ENTITY modeToolbar.tooltip "Mode Toolbar">
|
||||
<!ENTITY entryToolbar.tooltip "Javascript Entry Toolbar">
|
||||
<!ENTITY errFile.label "Source File:">
|
||||
<!ENTITY errLine.label "Line:">
|
||||
<!ENTITY errColumn.label "Column:">
|
||||
|
||||
<!ENTITY all.label "All">
|
||||
<!ENTITY errors.label "Errors">
|
||||
<!ENTITY warnings.label "Warnings">
|
||||
<!ENTITY messages.label "Messages">
|
||||
<!ENTITY clear.label "Clear">
|
||||
<!ENTITY evaluate.label "Evaluate">
|
||||
|
||||
<!ENTITY sortFirst.label "First > Last Sort Order">
|
||||
<!ENTITY sortFirst.accesskey "f">
|
||||
<!ENTITY sortLast.label "Last > First Sort Order">
|
||||
<!ENTITY sortLast.accesskey "l">
|
||||
|
||||
<!ENTITY toolbarsCmd.label "Show/Hide">
|
||||
<!ENTITY toolbarsCmd.accesskey "w">
|
||||
<!ENTITY toolbarMode.label "Mode">
|
||||
<!ENTITY toolbarEval.label "JavaScript Entry">
|
||||
|
||||
<!ENTITY helpMenu.label "Help">
|
||||
<!ENTITY helpMenu.accesskey "H">
|
||||
<!ENTITY releaseCmd.label "Release Notes">
|
||||
<!ENTITY releaseCmd.accesskey "R">
|
||||
<!ENTITY aboutCmd.label "About &brandShortName;">
|
||||
<!ENTITY aboutCmd.accesskey "A">
|
||||
<!ENTITY fileMenu.label "File">
|
||||
<!ENTITY fileMenu.accesskey "F">
|
Загрузка…
Ссылка в новой задаче