Bug 760951 - Add a filter box to the error console. r=jaws

This commit is contained in:
Tom Schuster 2012-06-07 17:22:34 +02:00
Родитель 8f33d48265
Коммит 518498d657
5 изменённых файлов: 72 добавлений и 2 удалений

Просмотреть файл

@ -60,6 +60,10 @@
display: none;
}
.filtered-by-string {
display: none;
}
/* If line number is 0, hide the line number section */
.lineNumberRow[line="0"] {
display: none;

Просмотреть файл

@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
var gConsole, gConsoleBundle, gTextBoxEval, gEvaluator, gCodeToEvaluate;
var gFilter;
/* :::::::: Console Initialization ::::::::::::::: */
@ -13,6 +14,7 @@ window.onload = function()
gConsoleBundle = document.getElementById("ConsoleBundle");
gTextBoxEval = document.getElementById("TextboxEval")
gEvaluator = document.getElementById("Evaluator");
gFilter = document.getElementById("Filter");
updateSortCommand(gConsole.sortOrder);
updateModeCommand(gConsole.mode);
@ -22,6 +24,13 @@ window.onload = function()
/* :::::::: Console UI Functions ::::::::::::::: */
function changeFilter()
{
gConsole.filter = gFilter.value;
document.persist("ConsoleBox", "filter")
}
function changeMode(aMode)
{
switch (aMode) {

Просмотреть файл

@ -77,6 +77,11 @@
<toolbarseparator/>
<toolbarbutton id="Console:clear" oncommand="clearConsole();"
label="&clear.label;" accesskey="&clear.accesskey;"/>
<vbox valign="middle" align="end" flex="1">
<textbox placeholder="&filter.label;" accesskey="&filter.accesskey;" type="search" id="Filter"
oncommand="changeFilter()" oninput="changeFilter()"/>
</vbox>
</toolbar>
<toolbar class="chromeclass-toolbar" id="ToolbarEval" align="center" nowindowdrag="true">

Просмотреть файл

@ -56,7 +56,18 @@
return val;
]]></setter>
</property>
<property name="filter">
<setter><![CDATA[
val = val.toLowerCase();
if (this.mFilter != val) {
this.mFilter = val;
setTimeout(this.applyFilter.bind(this), 0);
}
return val;
]]></setter>
</property>
<property name="sortOrder">
<getter>return this.getAttribute("sortOrder");</getter>
<setter>this.setAttribute("sortOrder", val); return val;</setter>
@ -107,6 +118,7 @@
}
this.mMode = this.getAttribute("mode") || "All";
this.mFilter = "";
this.appendInitialItems();
window.controllers.insertControllerAt(0, this._controller);
@ -205,6 +217,7 @@
} else {
row.setAttribute("hideCode", "true");
}
this.appendConsoleRow(row);
]]></body>
</method>
@ -267,6 +280,7 @@
<method name="appendConsoleRow">
<parameter name="aRow"/>
<body><![CDATA[
this.filterElement(aRow);
this.mConsoleRowBox.appendChild(aRow);
if (++this.mCount > this.limit) this.deleteFirst();
]]></body>
@ -292,7 +306,27 @@
this.selectedItem = null;
]]></body>
</method>
<method name="filterElement">
<parameter name="aRow" />
<body><![CDATA[
if (this.stringMatchesFilters(aRow.getAttribute("msg"), this.mFilter)) {
aRow.classList.remove("filtered-by-string")
} else {
aRow.classList.add("filtered-by-string")
}
]]></body>
</method>
<method name="applyFilter">
<parameter name="aFilter" />
<body><![CDATA[
for (let aRow of this.mConsoleRowBox.children) {
this.filterElement(aRow);
}
]]></body>
</method>
<!-- UTILITY FUNCTIONS -->
<method name="repeatChar">
@ -308,6 +342,22 @@
return aChar + aChar.slice(0, aCol - aChar.length);
]]></body>
</method>
<method name="stringMatchesFilters">
<parameter name="aString"/>
<parameter name="aFilter"/>
<body><![CDATA[
if (!aString || !aFilter) {
return true;
}
let searchStr = aString.toLowerCase();
let filterStrings = aFilter.split(/\s+/);
return !filterStrings.some(function (f) {
return searchStr.indexOf(f) == -1;
});
]]></body>
</method>
<constructor> this.init(); </constructor>
<destructor> this.destroy(); </destructor>

Просмотреть файл

@ -22,6 +22,8 @@
<!ENTITY codeEval.accesskey "o">
<!ENTITY evaluate.label "Evaluate">
<!ENTITY evaluate.accesskey "v">
<!ENTITY filter.label "Filter">
<!ENTITY filter.accesskey "F">
<!ENTITY copyCmd.label "Copy">
<!ENTITY copyCmd.accesskey "C">