зеркало из https://github.com/mozilla/pjs.git
Bug 378696 - Remove dead search code (step 2). r=timeless, sr=neil
This commit is contained in:
Родитель
6ea8bd9413
Коммит
c4570f822b
|
@ -11,11 +11,9 @@ inspector.jar:
|
|||
% overlay chrome://messenger/content/mailWindowOverlay.xul chrome://inspector/content/tasksOverlay-tb.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
% overlay chrome://inspector/content/commandOverlay.xul chrome://inspector/content/viewers/dom/commandOverlay.xul
|
||||
% overlay chrome://inspector/content/commandOverlay.xul chrome://inspector/content/viewers/styleRules/commandOverlay.xul
|
||||
% overlay chrome://inspector/content/commandOverlay.xul chrome://inspector/content/search/modules/commandOverlay.xul
|
||||
% overlay chrome://inspector/content/keysetOverlay.xul chrome://inspector/content/viewers/dom/keysetOverlay.xul
|
||||
% overlay chrome://inspector/content/popupOverlay.xul chrome://inspector/content/viewers/dom/popupOverlay.xul
|
||||
% overlay chrome://inspector/content/popupOverlay.xul chrome://inspector/content/viewers/styleRules/popupOverlay.xul
|
||||
% overlay chrome://inspector/content/popupOverlay.xul chrome://inspector/content/search/modules/popupOverlay.xul
|
||||
content/inspector/inspector.xul (resources/content/inspector.xul)
|
||||
content/inspector/inspector.js (resources/content/inspector.js)
|
||||
content/inspector/inspector.css (resources/content/inspector.css)
|
||||
|
@ -65,18 +63,6 @@ inspector.jar:
|
|||
content/inspector/prefs/pref-inspector.xul (resources/content/prefs/pref-inspector.xul)
|
||||
content/inspector/prefs/prefsOverlay.xul (resources/content/prefs/prefsOverlay.xul)
|
||||
content/inspector/prefs/pref-sidebar.js (resources/content/prefs/pref-sidebar.js)
|
||||
content/inspector/search/inSearchModule.js (resources/content/search/inSearchModule.js)
|
||||
content/inspector/search/inSearchService.js (resources/content/search/inSearchService.js)
|
||||
content/inspector/search/inSearchTreeBuilder.js (resources/content/search/inSearchTreeBuilder.js)
|
||||
content/inspector/search/inSearchUtils.js (resources/content/search/inSearchUtils.js)
|
||||
content/inspector/search/modules/commandOverlay.xul (resources/content/search/modules/commandOverlay.xul)
|
||||
content/inspector/search/modules/popupOverlay.xul (resources/content/search/modules/popupOverlay.xul)
|
||||
content/inspector/search/modules/findFiles/dialog.js (resources/content/search/modules/findFiles/dialog.js)
|
||||
content/inspector/search/modules/findFiles/dialog.xul (resources/content/search/modules/findFiles/dialog.xul)
|
||||
content/inspector/search/modules/findFiles/findFiles.xml (resources/content/search/modules/findFiles/findFiles.xml)
|
||||
content/inspector/search/modules/junkImgs/dialog.js (resources/content/search/modules/junkImgs/dialog.js)
|
||||
content/inspector/search/modules/junkImgs/dialog.xul (resources/content/search/modules/junkImgs/dialog.xul)
|
||||
content/inspector/search/modules/junkImgs/junkImgs.xml (resources/content/search/modules/junkImgs/junkImgs.xml)
|
||||
content/inspector/tests/allskin.xul (resources/content/tests/allskin.xul)
|
||||
content/inspector/viewers/accessibleObject/accessibleObject.js (resources/content/viewers/accessibleObject/accessibleObject.js)
|
||||
content/inspector/viewers/accessibleObject/accessibleObject.xul (resources/content/viewers/accessibleObject/accessibleObject.xul)
|
||||
|
|
|
@ -1,530 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/***************************************************************
|
||||
* inSearchModule -----------------------------------------------
|
||||
* Encapsulates an ISML module and exposes it to inSearchService.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
* chrome://inspector/content/jsutil/xpcom/XPCU.js
|
||||
* chrome://inspector/content/jsutil/rdf/RDFU.js
|
||||
* chrome://inspector/content/jsutil/rdf/RDFArray.js
|
||||
* chrome://inspector/content/jsutil/xul/inFormManager.js
|
||||
* chrome://inspector/content/search/xul/inSearchUtils.js
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class inSearchModule
|
||||
|
||||
function inSearchModule(aBaseURL)
|
||||
{
|
||||
this.mObservers = [];
|
||||
this.mBaseURL = aBaseURL;
|
||||
}
|
||||
|
||||
inSearchModule.prototype =
|
||||
{
|
||||
mTitle: null,
|
||||
mBaseURL: null,
|
||||
mImpl: null,
|
||||
mDialogElementIds: null,
|
||||
mDialogURL: null,
|
||||
mContextMenuItems: null,
|
||||
mColumns: null,
|
||||
mColDelimiter: null,
|
||||
mNameSpace: null,
|
||||
|
||||
mRDFArray: null,
|
||||
mResult: null,
|
||||
mObservers: null,
|
||||
|
||||
mStartTime: null,
|
||||
mElapsed: 0,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Properties
|
||||
|
||||
get searchService() { return this.mSearchService},
|
||||
set searchService(aVal) { this.mSearchService = aVal },
|
||||
|
||||
get title() { return this.mTitle },
|
||||
get baseURL() { return this.mBaseURL },
|
||||
get defaultIconURL() { return this.mDefaultIconURL },
|
||||
|
||||
get datasource() { return this.mRDFArray.datasource },
|
||||
get resultCount() { return this.mRDFArray.length },
|
||||
get progressPercent() { return this.mImpl.progressPercent },
|
||||
get progressText() { return this.mImp.progressText },
|
||||
get isPastMilestone() { return this.mImpl.isPastMilestone },
|
||||
get elapsed() { return this.mElapsed },
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Initialization
|
||||
|
||||
initFromElement: function(aSearchEl)
|
||||
{
|
||||
this.parseSearch(aSearchEl);
|
||||
|
||||
if (this.mImpl.constructor)
|
||||
this.mImpl.constructor();
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Parser
|
||||
|
||||
parseSearch: function(aSearchEl)
|
||||
{
|
||||
// get the title
|
||||
this.mTitle = aSearchEl.getAttribute("title");
|
||||
// get the default icon url
|
||||
this.mDefaultIconURL = aSearchEl.getAttribute("defaultIcon");
|
||||
// get the namespace
|
||||
var ns = aSearchEl.getAttribute("namespace")
|
||||
this.mNameSpace = ns ? ns : kInspectorNSURI;
|
||||
|
||||
this.parseDialog(aSearchEl);
|
||||
this.parseContextMenu(aSearchEl);
|
||||
this.parseColumns(aSearchEl);
|
||||
this.parseImplementation(aSearchEl);
|
||||
},
|
||||
|
||||
parseDialog: function(aSearchEl)
|
||||
{
|
||||
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "dialog");
|
||||
if (els.length > 0) {
|
||||
var dialogEl = els[0];
|
||||
|
||||
// get the array of dialog element ids
|
||||
var ids = dialogEl.getAttribute("elements");
|
||||
if (ids)
|
||||
this.mDialogElementIds = ids.split(",");
|
||||
|
||||
// get the dialog url
|
||||
this.setDialogURL(dialogEl.getAttribute("href"));
|
||||
// get the dialog parameters
|
||||
this.mDialogResizable = (dialogEl.getAttribute("resizable") == "true") ? true : false;
|
||||
}
|
||||
},
|
||||
|
||||
parseContextMenu: function(aSearchEl)
|
||||
{
|
||||
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "contextmenu");
|
||||
if (els.length > 0) {
|
||||
var kids = els[0].childNodes;
|
||||
this.mContextMenu = [];
|
||||
for (var i = 0; i < kids.length; ++i) {
|
||||
this.mContextMenu[i] = kids[i].cloneNode(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseColumns: function(aSearchEl)
|
||||
{
|
||||
// get the result columns
|
||||
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "columns");
|
||||
if (els.length > 0) {
|
||||
this.mColumns = [];
|
||||
var cols = els[0];
|
||||
this.mColDelimiter = cols.getAttribute("delimiter");
|
||||
|
||||
var kids = cols.childNodes;
|
||||
var col, data;
|
||||
for (var i= 0; i < kids.length; ++i) {
|
||||
col = kids[i];
|
||||
if (col.nodeType == Node.ELEMENT_NODE) { // ignore non-element nodes
|
||||
data = {
|
||||
name: col.getAttribute("name"),
|
||||
title: col.getAttribute("title"),
|
||||
flex: col.getAttribute("flex"),
|
||||
className: col.getAttribute("class"),
|
||||
copy: col.getAttribute("copy") == "true"
|
||||
};
|
||||
this.mColumns.push(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseImplementation: function(aSearchEl)
|
||||
{
|
||||
this.mImpl = this.getDefaultImplementation();
|
||||
|
||||
// get the implementation object
|
||||
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "implementation");
|
||||
if (els.length > 0) {
|
||||
var kids = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "*");
|
||||
for (var i = 0; i < kids.length; i++) {
|
||||
if (kids[i].localName == "property")
|
||||
this.parseProperty(kids[i]);
|
||||
if (kids[i].localName == "method")
|
||||
this.parseMethod(kids[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseProperty: function(aPropEl)
|
||||
{
|
||||
var name = aPropEl.getAttribute("name");
|
||||
var fn = null;
|
||||
|
||||
// look for a getter
|
||||
try {
|
||||
fn = this.getCodeTagFunction(aPropEl, "getter", null);
|
||||
if (fn)
|
||||
this.mImpl.__defineGetter__(name, fn);
|
||||
} catch (ex) {
|
||||
throw "### SYNTAX ERROR IN ISML GETTER \"" + name + "\" ###\n" + ex;
|
||||
}
|
||||
|
||||
// look for a setter
|
||||
try {
|
||||
fn = this.getCodeTagFunction(aPropEl, "setter", ["val"]);
|
||||
if (fn)
|
||||
this.mImpl.__defineSetter__(name, fn);
|
||||
} catch (ex) {
|
||||
throw "### SYNTAX ERROR IN ISML SETTER \"" + name + "\" ###\n" + ex;
|
||||
}
|
||||
},
|
||||
|
||||
parseMethod: function(aMethodEl)
|
||||
{
|
||||
var name = aMethodEl.getAttribute("name");
|
||||
var def = aMethodEl.getAttribute("defaultCommand") == "true";
|
||||
|
||||
// get all the parameters
|
||||
var els = aMethodEl.getElementsByTagNameNS(kISMLNSURI, "parameter");
|
||||
var params = [];
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
params[i] = els[i].getAttribute("name");
|
||||
}
|
||||
|
||||
// get the body javascript and create the function
|
||||
try {
|
||||
var fn = this.getCodeTagFunction(aMethodEl, "body", params);
|
||||
this.mImpl[name] = fn;
|
||||
if (def)
|
||||
this.mImpl.__DefaultCmd__ = fn;
|
||||
} catch (ex) {
|
||||
throw "### SYNTAX ERROR IN ISML METHOD \"" + name + "\" ###\n" + ex;
|
||||
}
|
||||
},
|
||||
|
||||
getCodeTagFunction: function(aParent, aLocalName, aParams)
|
||||
{
|
||||
var els = aParent.getElementsByTagNameNS(kISMLNSURI, aLocalName);
|
||||
if (els.length) {
|
||||
var body = els[0];
|
||||
// try to determine where the code is located
|
||||
var node = body.childNodes.length > 0 ? body.firstChild : body;
|
||||
return this.getJSFunction(aParams, node.nodeValue);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getJSFunction: function(aParams, aCode)
|
||||
{
|
||||
var params = "";
|
||||
if (aParams) {
|
||||
for (var i = 0; i < aParams.length; i++) {
|
||||
params += aParams[i];
|
||||
if (i < aParams.length-1) params += ",";
|
||||
}
|
||||
}
|
||||
|
||||
var js = "function(" + params + ") " +
|
||||
"{" +
|
||||
(aCode ? aCode : "") +
|
||||
"}";
|
||||
|
||||
var fn;
|
||||
eval("fn = " + js);
|
||||
return fn;
|
||||
},
|
||||
|
||||
getDefaultImplementation: function()
|
||||
{
|
||||
return { module: this };
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Dialog box
|
||||
|
||||
openDialog: function()
|
||||
{
|
||||
window.openDialog(this.mDialogURL, "inSearchModule_dialog",
|
||||
"chrome,modal,resizable="+this.mDialogResizable, this);
|
||||
},
|
||||
|
||||
processDialog: function(aWindow)
|
||||
{
|
||||
var map = inFormManager.readWindow(aWindow, this.mDialogElementIds);
|
||||
this.implStartSearch(map);
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Searching
|
||||
|
||||
startSearch: function()
|
||||
{
|
||||
if (this.mDialogURL) {
|
||||
this.openDialog();
|
||||
} else
|
||||
this.implStartSearch(null);
|
||||
},
|
||||
|
||||
implStartSearch: function(aMap)
|
||||
{
|
||||
this.mStartTime = new Date();
|
||||
this.mElapsed = 0;
|
||||
|
||||
this.notifySearchStart();
|
||||
this.initDataSource();
|
||||
this.prepareForResult();
|
||||
this.mImpl.searchStart(aMap);
|
||||
},
|
||||
|
||||
stopSearch: function()
|
||||
{
|
||||
this.searchEnd();
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Result Returns
|
||||
|
||||
setResultProperty: function(aAttr, aValue)
|
||||
{
|
||||
this.mResult[aAttr] = aValue;
|
||||
},
|
||||
|
||||
searchResultReady: function()
|
||||
{
|
||||
this.mRDFArray.add(this.mResult);
|
||||
this.notifySearchResult();
|
||||
this.prepareForResult();
|
||||
},
|
||||
|
||||
searchError: function(aMsg)
|
||||
{
|
||||
},
|
||||
|
||||
searchEnd: function()
|
||||
{
|
||||
this.mElapsed = new Date() - this.mStartTime;
|
||||
this.notifySearchEnd();
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Columns
|
||||
|
||||
get columnCount() { return this.mColumns.length },
|
||||
|
||||
getColumn: function(aIndex) { return this.mColumns[aIndex] },
|
||||
getColumnName: function(aIndex) { return this.mColumns[aIndex].name },
|
||||
getColumnTitle: function(aIndex) { return this.mColumns[aIndex].title },
|
||||
getColumnClassName: function(aIndex) { return this.mColumns[aIndex].className },
|
||||
getColumnFlex: function(aIndex) { return this.mColumns[aIndex].flex },
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// RDF Datasource
|
||||
|
||||
initDataSource: function()
|
||||
{
|
||||
this.mRDFArray = new RDFArray(this.mNameSpace, "inspector:searchResults", "results");
|
||||
this.mRDFArray.initialize();
|
||||
},
|
||||
|
||||
getResultPropertyAt: function(aIndex, aProp)
|
||||
{
|
||||
return this.mRDFArray.get(aIndex, aProp);
|
||||
},
|
||||
|
||||
getItemText: function(aIndex)
|
||||
{
|
||||
var cols = this.mColumns;
|
||||
var text = [];
|
||||
for (var i = 0; i < cols.length; ++i) {
|
||||
if (cols[i].copy) {
|
||||
text.push(this.getResultPropertyAt(aIndex, cols[i].name));
|
||||
}
|
||||
}
|
||||
return text.join(this.mColDelimiter);
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Context Menu
|
||||
|
||||
installContextMenu: function(aMenu, aInsertionPoint, aDir)
|
||||
{
|
||||
if (this.mContextMenu) {
|
||||
aMenu._searchModule = this;
|
||||
var item;
|
||||
this.mMenuItems = [];
|
||||
if (this.mContextMenu.length == 0)
|
||||
aInsertionPoint.setAttribute("hide", "true");
|
||||
for (var i = 0; i < this.mContextMenu.length; ++i) {
|
||||
item = this.mContextMenu[i];
|
||||
this.mMenuItems.push(item);
|
||||
this.installSearchReference(item);
|
||||
if (aDir == inSearchService.INSERT_BEFORE)
|
||||
aMenu.insertBefore(item, aInsertionPoint);
|
||||
else {
|
||||
// NOT YET IMPLEMENTED
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
uninstallContextMenu: function(aMenu, aInsertionPoint, aDir)
|
||||
{
|
||||
if (this.mContextMenu) {
|
||||
if (this.mContextMenu.length == 0)
|
||||
aInsertionPoint.removeAttribute("hide");
|
||||
// remove the menu items
|
||||
for (var i = 0; i < this.mContextMenu.length; ++i)
|
||||
aMenu.removeChild(this.mMenuItems[i]);
|
||||
}
|
||||
},
|
||||
|
||||
installSearchReference: function(aItem)
|
||||
{
|
||||
if (aItem.nodeType == Node.ELEMENT_NODE) {
|
||||
if (aItem.localName == "menuitem") {
|
||||
aItem.search = this.mImpl;
|
||||
for (var i = 0; i < aItem.childNodes.length; ++i)
|
||||
this.installSearchReference(aItem.childNodes[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Event Notification
|
||||
|
||||
// NOTE TO SELF - this code could be cut down to nothing if you write a module
|
||||
// called "ObserverManager" to do the work for you
|
||||
|
||||
addSearchObserver: function(aObserver)
|
||||
{
|
||||
this.mObservers.push(aObserver);
|
||||
},
|
||||
|
||||
removeSearchObserver: function(aObserver)
|
||||
{
|
||||
var o;
|
||||
var obs = this.mObservers;
|
||||
for (var i = 0; i < obs.length; i++) {
|
||||
o = obs[i];
|
||||
if (o == aObserver) {
|
||||
obs.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
notifySearchStart: function()
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchStart(this);
|
||||
},
|
||||
|
||||
notifySearchResult: function()
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchResult(this);
|
||||
},
|
||||
|
||||
notifySearchEnd: function(aResult)
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchEnd(this, aResult);
|
||||
},
|
||||
|
||||
notifySearchError: function(aMsg)
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchError(this, aMsg);
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Uncategorized
|
||||
|
||||
callDefaultCommand: function()
|
||||
{
|
||||
if (this.mImpl.__DefaultCmd__)
|
||||
this.mImpl.__DefaultCmd__();
|
||||
},
|
||||
|
||||
prepareForResult: function()
|
||||
{
|
||||
this.mResult = { _icon: this.mDefaultIconURL };
|
||||
},
|
||||
|
||||
setDialogURL: function(aURL)
|
||||
{
|
||||
this.mDialogURL = aURL;
|
||||
// This block below doesn't work for now because none of the local file implementations
|
||||
// implement SetURL. So, for now, the url in the search file MUST be absolute :(
|
||||
/* this.mDialogURL = aURL;
|
||||
var baseFile = inSearchUtils.createLocalFile(this.mBaseURL);
|
||||
try {
|
||||
baseFile.append(aURL);
|
||||
} catch (ex) {
|
||||
basefile = inSearchUtils.createLocalFile(aURL);
|
||||
}
|
||||
|
||||
var file = XPCU.QI(file, "nsIFile");
|
||||
|
||||
var ioService = XPCU.getService("@mozilla.org/network/io-service;1", "nsIIOService");
|
||||
var fileHandler = XPCU.QI(ioService.getProtocolHandler("file"), "nsIFileProtocolHandler");
|
||||
|
||||
this.mDialogURL = fileHandler.getURLSpecFromFile(basefile);
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Event Listeners
|
||||
|
|
@ -1,417 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/***************************************************************
|
||||
* inSearchService -----------------------------------------------
|
||||
* The centry registry where information about all installed
|
||||
* search modules is kept.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* Until Bug 54237 is fixed, there be some ugly hacks in this
|
||||
* file. We'll need to load search modules via a XUL document
|
||||
* within an iframe, instead of using the xml loader for now.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
* chrome://inspector/content/jsutil/xpcom/XPCU.js
|
||||
* chrome://inspector/content/search/inSearchTreeBuilder.js
|
||||
* chrome://inspector/content/search/inSearchModule.js
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
var kSearchURLPrefix = "chrome://inspector/content/search/";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class inSearchService
|
||||
|
||||
function inSearchService()
|
||||
{
|
||||
this.mInstances = {};
|
||||
this.mObservers = [];
|
||||
|
||||
// the browser and webnav are a hack. We should be able to use
|
||||
// the xmlextras facility for loading xml, but it's broken, so
|
||||
// we use a browser for onw
|
||||
var browser = document.getElementById("inSearchServiceLoader");
|
||||
browser.addEventListener("pageshow", inSearchService_LoadListener, true);
|
||||
this.mWebNav = browser.webNavigation;
|
||||
}
|
||||
|
||||
// constants
|
||||
inSearchService.INSERT_BEFORE = 1;
|
||||
inSearchService.INSERT_AFTER = 2;
|
||||
|
||||
inSearchService.prototype =
|
||||
{
|
||||
mInstances: null,
|
||||
mObservers: null,
|
||||
mCurrentModule: null,
|
||||
|
||||
mTree: null,
|
||||
mContextMenu: null,
|
||||
mCMInsertPt: null,
|
||||
mCMInsert: inSearchService.INSERT_BEFORE,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Properties
|
||||
|
||||
get currentModule() { return this.mCurrentModule },
|
||||
|
||||
get resultsTree() { return this.mTree },
|
||||
set resultsTree(aTree) {
|
||||
// XX this condition could be fixed with a little bit of effort
|
||||
if (this.mTree) throw "inSearchService.tree should only be set once"
|
||||
|
||||
this.mTree = aTree;
|
||||
aTree._searchService = this;
|
||||
|
||||
this.mTreeBuilder = new inSearchTreeBuilder(aTree, kInspectorNSURI, "results");
|
||||
this.mTreeBuilder.isIconic = true;
|
||||
|
||||
// XX HACKERY AT IT'S FINEST - the click event won't fire when I add it to the tree -- go figure
|
||||
// in the mean time I'll add it to the parentNode, which seems to work. FIX ME!
|
||||
var parent = aTree.parentNode;
|
||||
parent._tempTreeYuckyHack = aTree;
|
||||
parent.addEventListener("click", inSearchService_TreeClickListener, false);
|
||||
},
|
||||
|
||||
get contextMenu() { return this.mContextMenu },
|
||||
set contextMenu(aVal)
|
||||
{
|
||||
this.mContextMenu = aVal;
|
||||
aVal._searchService = this;
|
||||
},
|
||||
|
||||
get contextMenuInsertPt() { return this.mCMInsertPt },
|
||||
set contextMenuInsertPt(aVal) { this.mCMInsertPt = aVal },
|
||||
|
||||
get contextMenuInsert() { return this.mCMInsert },
|
||||
set contextMenuInsert(aVal) { this.mCMInsert = aVal },
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Running Modules
|
||||
|
||||
startModule: function(aURL)
|
||||
{
|
||||
var instance = this.mInstances[aURL];
|
||||
if (instance)
|
||||
this.doStartModule(instance);
|
||||
else
|
||||
this.loadModule(aURL);
|
||||
},
|
||||
|
||||
doStartModule: function(aModule)
|
||||
{
|
||||
aModule.startSearch();
|
||||
},
|
||||
|
||||
startSearch: function(aModule)
|
||||
{
|
||||
this.mCurrentModule = aModule;
|
||||
|
||||
// build up the context menu
|
||||
this.installContextMenu();
|
||||
|
||||
// build up the search results tree
|
||||
this.mTreeBuilder.module = aModule;
|
||||
},
|
||||
|
||||
clearSearch: function()
|
||||
{
|
||||
var mod = this.mCurrentModule;
|
||||
if (mod) {
|
||||
// clear datasource from search tree
|
||||
this.mTreeBuilder.module = null;
|
||||
this.mTreeBuilder.buildContent();
|
||||
|
||||
// clear context menu
|
||||
this.uninstallContextMenu();
|
||||
}
|
||||
|
||||
this.mCurrentModule = null;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Loading Modules
|
||||
|
||||
loadModule: function(aURL)
|
||||
{
|
||||
this.mWebNav.loadURI(aURL, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
||||
this.mLoadingURL = aURL;
|
||||
/*
|
||||
// This method of loading the xml doesn't work, but it should. See bug 54237...
|
||||
var doc = document.implementation.createDocument("", "", null);
|
||||
doc.addEventListener("load", SearchFileLoadListener, false);
|
||||
doc.load(aURL, "application/xml");
|
||||
*/
|
||||
},
|
||||
|
||||
searchFileLoaded: function()
|
||||
{
|
||||
var mod = this.createModule(this.mWebNav.document);
|
||||
mod.addSearchObserver(this);
|
||||
this.mInstances[this.mLoadingURL] = mod;
|
||||
this.doStartModule(mod);
|
||||
},
|
||||
|
||||
createModule: function(aDocument)
|
||||
{
|
||||
var mod = new inSearchModule(aDocument.location);
|
||||
mod.searchService = this;
|
||||
mod.initFromElement(aDocument.documentElement);
|
||||
|
||||
return mod;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// interface inISearchObserver
|
||||
|
||||
onSearchStart: function(aModule)
|
||||
{
|
||||
this.startSearch(aModule);
|
||||
this.notifySearchStart();
|
||||
},
|
||||
|
||||
onSearchResult: function(aModule)
|
||||
{
|
||||
this.notifySearchResult();
|
||||
},
|
||||
|
||||
onSearchEnd: function(aModule, aResult)
|
||||
{
|
||||
this.notifySearchEnd(aResult);
|
||||
},
|
||||
|
||||
onSearchError: function(aModule, aMessage)
|
||||
{
|
||||
this.notifySearchError(aMessage);
|
||||
this.clearSearch();
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Results Tree
|
||||
|
||||
get selectedItemCount()
|
||||
{
|
||||
return this.mTree ? this.mTree.selectedItems.length : null;
|
||||
},
|
||||
|
||||
getSelectedIndex: function(aIdx)
|
||||
{
|
||||
if (this.mTree) {
|
||||
var items = this.mTree.selectedItems;
|
||||
return this.mTree.getIndexOfItem(items[aIdx]);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
onTreeDblClick: function()
|
||||
{
|
||||
this.mCurrentModule.callDefaultCommand();
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// ContextMenu
|
||||
|
||||
installContextMenu: function()
|
||||
{
|
||||
var mod = this.mCurrentModule;
|
||||
if (mod) {
|
||||
var menu = this.mContextMenu;
|
||||
menu.addEventListener("popupshowing", inSearchService_onCreatePopup, true);
|
||||
mod.installContextMenu(menu, this.mCMInsertPt, this.mCMInsert);
|
||||
}
|
||||
},
|
||||
|
||||
uninstallContextMenu: function()
|
||||
{
|
||||
var mod = this.mCurrentModule;
|
||||
if (mod) {
|
||||
// remove the createion listener
|
||||
var menu = this.mContextMenu;
|
||||
menu.removeEventListener("popupshowing", inSearchService_onCreatePopup, true);
|
||||
mod.uninstallContextMenu(menu, this.mCMInsertPt, this.mCMInsert);
|
||||
}
|
||||
},
|
||||
|
||||
onCreatePopup: function(aMenu)
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//// Event Notification
|
||||
|
||||
// NOTE TO SELF - this code could be cut down to nothing if you write a module
|
||||
// called "ObserverManager" to do the work for you
|
||||
|
||||
addSearchObserver: function(aObserver)
|
||||
{
|
||||
this.mObservers.push(aObserver);
|
||||
},
|
||||
|
||||
removeSearchObserver: function(aObserver)
|
||||
{
|
||||
var o;
|
||||
var obs = this.mObservers;
|
||||
for (var i = 0; i < obs.length; i++) {
|
||||
o = obs[i];
|
||||
if (o == aObserver) {
|
||||
obs.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
notifySearchStart: function()
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchStart(this.mCurrentModule);
|
||||
},
|
||||
|
||||
notifySearchResult: function()
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchResult(this.mCurrentModule);
|
||||
},
|
||||
|
||||
notifySearchEnd: function(aResult)
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchEnd(this.mCurrentModule, aResult);
|
||||
},
|
||||
|
||||
notifySearchError: function(aMsg)
|
||||
{
|
||||
var o = this.mObservers;
|
||||
for (var i = 0; i < o.length; i++)
|
||||
o[i].onSearchError(this.mCurrentModule, aMsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Event Listeners
|
||||
|
||||
function inSearchService_LoadListener(aEvent)
|
||||
{
|
||||
inspector.searchRegistry.searchFileLoaded();
|
||||
}
|
||||
|
||||
function inSearchService_TreeClickListener(aEvent)
|
||||
{
|
||||
if (aEvent.detail == 2) {
|
||||
var tree = this._tempTreeYuckyHack;
|
||||
tree._searchService.onTreeDblClick();
|
||||
}
|
||||
}
|
||||
|
||||
function inSearchService_onCreatePopup(aEvent)
|
||||
{
|
||||
// event.target is returning null for this event - I should file a bug
|
||||
// in the mean time I'll just back off this feature for now...
|
||||
|
||||
/* var menu = aEvent.target;
|
||||
var svc = menu._searchService;
|
||||
svc.onCreatePopup(menu);
|
||||
*/
|
||||
}
|
||||
|
||||
// This code is from when there was an RDF "search registry"... I might want to bring that back,
|
||||
// so I'll keep this code sitting here for a little while...
|
||||
|
||||
/*
|
||||
function inSearchServiceLoadObserver(aTarget)
|
||||
{
|
||||
this.mTarget = aTarget;
|
||||
}
|
||||
|
||||
inSearchServiceLoadObserver.prototype = {
|
||||
mTarget: null,
|
||||
|
||||
onError: function(aErrorMsg)
|
||||
{
|
||||
this.mTarget.onLoadError(aErrorMsg);
|
||||
},
|
||||
|
||||
onDataSourceReady: function(aDS)
|
||||
{
|
||||
this.mTarget.onLoad(aDS);
|
||||
}
|
||||
};
|
||||
|
||||
load: function(aURL, aObserver)
|
||||
{
|
||||
this.mURL = aURL;
|
||||
this.mObserver = aObserver;
|
||||
RDFU.loadDataSource(aURL, new inSearchServiceLoadObserver(this));
|
||||
},
|
||||
|
||||
onLoad: function(aDS)
|
||||
{
|
||||
this.mDS = aDS;
|
||||
this.prepareRegistry();
|
||||
this.mObserver.oninSearchServiceLoad();
|
||||
},
|
||||
|
||||
onLoadError: function(aErrorMsg)
|
||||
{
|
||||
this.mObserver.oninSearchServiceLoadError(aErrorMsg);
|
||||
},
|
||||
|
||||
prepareRegistry: function()
|
||||
{
|
||||
this.mModuleSeq = RDFU.findSeq(this.mDS, "inspector:search");
|
||||
|
||||
var el, uid, fnName, factory;
|
||||
var els = this.mModuleSeq.GetElements();
|
||||
while (els.hasMoreElements()) {
|
||||
el = els.getNext();
|
||||
uid = RDFU.readAttribute(this.mDS, el, kInspectorNSURI+"uid");
|
||||
fnName = RDFU.readAttribute(this.mDS, el, kInspectorNSURI+"factory");
|
||||
factory = eval(fnName);
|
||||
if (factory)
|
||||
this.mFactories[uid] = factory;
|
||||
}
|
||||
|
||||
},
|
||||
*/
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/***************************************************************
|
||||
* inSearchTreeBuilder ------------------------------------------
|
||||
* Utility for automatically building an rdf template and xul
|
||||
* tree structure from a tabular data set.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
* chrome://inspector/content/jsutil/inTreeBuilder.js
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class inSearchTreeBuilder
|
||||
|
||||
function inSearchTreeBuilder(aTree, aNameSpace, aArcName)
|
||||
{
|
||||
this.mBuilder = new inTreeTableBuilder(aTree, aNameSpace, aArcName);
|
||||
aTree.setAttribute("ref", "inspector:searchResults");
|
||||
this.mBuilder.initialize();
|
||||
}
|
||||
|
||||
inSearchTreeBuilder.prototype =
|
||||
{
|
||||
mCommited: false,
|
||||
mBuilder: null,
|
||||
mModule: null,
|
||||
mCommitted: false,
|
||||
|
||||
get tree() { return this.mBuilder.tree },
|
||||
set tree(aVal) { this.mBuilder.tree = aVal },
|
||||
|
||||
get isIconic() { return this.mBuilder.isIconic },
|
||||
set isIconic(aVal) { this.mBuilder.isIconic = aVal },
|
||||
|
||||
get module() { return this.mModule },
|
||||
|
||||
set module(aModule)
|
||||
{
|
||||
if (aModule != this.mModule) {
|
||||
if (this.mModule) {
|
||||
if (this.mCommitted)
|
||||
this.mBuilder.tree.database.RemoveDataSource(this.mModule.datasource);
|
||||
this.mCommitted = false;
|
||||
|
||||
this.mModule.removeSearchObserver(this);
|
||||
this.mBuilder.reset();
|
||||
}
|
||||
|
||||
this.mModule = aModule;
|
||||
|
||||
if (aModule) {
|
||||
aModule.addSearchObserver(this);
|
||||
|
||||
this.isIconic = aModule.defaultIconURL ? true : false;
|
||||
|
||||
for (var i = 0; i < aModule.columnCount; i++)
|
||||
this.mBuilder.addColumn(aModule.getColumn(i));
|
||||
|
||||
this.mBuilder.build();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getSelectedSearchIndex: function()
|
||||
{
|
||||
var tItem = this.mSearchTree.selectedItems[0];
|
||||
return this.mSearchTree.getIndexOfItem(tItem);
|
||||
},
|
||||
|
||||
onSearchStart: function(aProcess)
|
||||
{
|
||||
if (this.mCommitted)
|
||||
this.mBuilder.tree.database.RemoveDataSource(this.mModule.datasource);
|
||||
},
|
||||
|
||||
onSearchResult: function(aProcess)
|
||||
{
|
||||
},
|
||||
|
||||
onSearchEnd: function(aProcess, aResult)
|
||||
{
|
||||
this.mBuilder.tree.database.AddDataSource(this.mModule.datasource);
|
||||
this.mBuilder.buildContent();
|
||||
this.mCommitted = true;
|
||||
},
|
||||
|
||||
onSearchError: function(aProcess, aMessage)
|
||||
{
|
||||
},
|
||||
|
||||
reset: function()
|
||||
{
|
||||
this.mBuilder.reset();
|
||||
},
|
||||
|
||||
buildContent: function()
|
||||
{
|
||||
this.mBuilder.buildContent();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt <hewitt@netscape.com> (original author)
|
||||
*
|
||||
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/***************************************************************
|
||||
* inSearchUtils -------------------------------------------------
|
||||
* Utilities for helping search modules accomplish common tasks.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
var kSearchLookup = {
|
||||
cssvalue: "inICSSValueSearch"
|
||||
};
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
const kISMLNSURI = "http://www.mozilla.org/inspector/isml";
|
||||
|
||||
const kSearchHelperCIDPrefix = "@mozilla.org/inspector/search;1?type=";
|
||||
const kFileSearchCID = "@mozilla.org/inspector/search;1?type=file";
|
||||
const kCSSValueSearchCID = "@mozilla.org/inspector/search;1?type=cssvalue";
|
||||
const kLocalFileCID = "@mozilla.org/file/local;1";
|
||||
const kInMemoryDataSourceCID = "@mozilla.org/rdf/datasource;1?name=in-memory-datasource";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class inSearchUtils
|
||||
|
||||
var inSearchUtils =
|
||||
{
|
||||
// nsISupports
|
||||
createSearchHelper: function(aName)
|
||||
{
|
||||
var cid = kSearchHelperCIDPrefix + aName;
|
||||
var iid = kSearchLookup[aName];
|
||||
return XPCU.createInstance(cid, iid);
|
||||
},
|
||||
|
||||
// nsIFile
|
||||
createLocalFile: function(aPath)
|
||||
{
|
||||
var file = XPCU.createInstance(kLocalFileCID, "nsILocalFile");
|
||||
|
||||
if (aPath) {
|
||||
try {
|
||||
file.initWithPath(aPath);
|
||||
} catch (ex) {
|
||||
debug("Invalid path in nsILocalFile::initWithPath\n" + ex);
|
||||
}
|
||||
}
|
||||
|
||||
return XPCU.QI(file, "nsIFile");
|
||||
},
|
||||
|
||||
// inISearchObserver
|
||||
createSearchObserver: function(aTarget, aLabel)
|
||||
{
|
||||
var observer = {
|
||||
mTarget: aTarget,
|
||||
onSearchStart: new Function("aModule", "this.mTarget.on"+aLabel+"SearchStart(aModule)"),
|
||||
onSearchEnd: new Function("aModule", "aResult", "this.mTarget.on"+aLabel+"SearchEnd(aModule, aResult)"),
|
||||
onSearchError: new Function("aModule", "aMsg", "this.mTarget.on"+aLabel+"SearchError(aModule, aMsg)"),
|
||||
onSearchResult: new Function("aModule", "this.mTarget.on"+aLabel+"SearchResult(aModule)")
|
||||
};
|
||||
|
||||
return observer;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/***************************************************************
|
||||
* FindFilesDialog ---------------------------------------
|
||||
* Controller for dialog.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
var dialog;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
window.addEventListener("load", FindFilesDialog_initialize, false);
|
||||
|
||||
function FindFilesDialog_initialize()
|
||||
{
|
||||
dialog = new FindFilesDialog();
|
||||
doSetOKCancel(gDoOKFunc);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class FindFilesDialog
|
||||
|
||||
function FindFilesDialog()
|
||||
{
|
||||
}
|
||||
|
||||
FindFilesDialog.prototype =
|
||||
{
|
||||
browse: function()
|
||||
{
|
||||
var txf = document.getElementById("txfSearchPath");
|
||||
var defaultPath = txf.getAttribute("value");
|
||||
var file = FilePickerUtils.pickDir("Select Search Path", defaultPath);
|
||||
if (file) {
|
||||
txf.setAttribute("value", file.path);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// dialogOverlay stuff
|
||||
|
||||
function gDoOKFunc() {
|
||||
window.close();
|
||||
window.arguments[0].processDialog(window);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://inspector/locale/search/findFiles.dtd">
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
<?xml-stylesheet href="chrome://inspector/skin/"?>
|
||||
|
||||
<window id="winJunkImgs" class="dialog"
|
||||
title="&findFiles.title;"
|
||||
persist="screenX screenY"
|
||||
orient="vertical"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/search/modules/findFiles/dialog.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
|
||||
|
||||
<vbox>
|
||||
<hbox align="center">
|
||||
<label id="txSearchFor" value="&txSearchFor.label;"/>
|
||||
<textbox id="txfSearchFor" style="width: 25em;" persist="true"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<label id="txSearchPath" value="&txSearchPath.label;"/>
|
||||
<textbox id="txfSearchPath" style="width: 25em;" persist="true"/>
|
||||
<button id="btnSearchPathBrowser" label="Browse" onclick="dialog.browse()" persist="true"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<checkbox id="cbRecurse" label="&cbRecurse.label;"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<hbox id="okCancelButtonsRight"/>
|
||||
</window>
|
|
@ -1,50 +0,0 @@
|
|||
/***************************************************************
|
||||
* JunkImgsDialog -------------------------------------------------
|
||||
* Controller for dialog.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
var dialog;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
window.addEventListener("load", JunkImgsDialog_initialize, false);
|
||||
|
||||
function JunkImgsDialog_initialize()
|
||||
{
|
||||
dialog = new JunkImgsDialog();
|
||||
doSetOKCancel(gDoOKFunc);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class JunkImgsDialog
|
||||
|
||||
function JunkImgsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
JunkImgsDialog.prototype =
|
||||
{
|
||||
browse: function()
|
||||
{
|
||||
var txf = document.getElementById("txfSearchPath");
|
||||
var defaultPath = txf.getAttribute("value");
|
||||
var file = FilePickerUtils.pickDir("Select Search Path", defaultPath);
|
||||
if (file)
|
||||
txf.setAttribute("value", file.path);
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// dialogOverlay stuff
|
||||
|
||||
function gDoOKFunc() {
|
||||
window.close();
|
||||
window.arguments[0].processDialog(window);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://inspector/locale/search/junkImgs.dtd">
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
<?xml-stylesheet href="chrome://inspector/skin/"?>
|
||||
|
||||
<window id="winJunkImgs" class="dialog"
|
||||
title="&junkImgs.title;"
|
||||
persist="screenX screenY"
|
||||
orient="vertical"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/search/modules/junkImgs/dialog.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
|
||||
|
||||
<vbox>
|
||||
<description style="width: 400px">&junkImgsDescription;</description>
|
||||
<hbox align="center">
|
||||
<label id="txSearchPath" value="Search Path:"/>
|
||||
<textbox id="txfSearchPath" flex="1" style="width: 25em;" persist="true"/>
|
||||
<button id="btnSearchPathBrowser" value="Browse" onclick="dialog.browse()"/>
|
||||
</hbox>
|
||||
<!--
|
||||
<hbox align="center">
|
||||
<label id="txRemotePath" value="Target URL:"/>
|
||||
<textbox id="txfRemotePath" flex="1" persist="true"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<checkbox id="cbIsSkin" label="Target is a Skin" checked="true" persist="true"/>
|
||||
</hbox>
|
||||
-->
|
||||
</vbox>
|
||||
|
||||
<hbox id="okCancelButtonsRight"/>
|
||||
</window>
|
|
@ -1,176 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<search
|
||||
title="Find Unused Images in Current Theme"
|
||||
defaultIcon="chrome://inspector/skin/ImageSearchItem.gif"
|
||||
xmlns="http://www.mozilla.org/inspector/isml"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<dialog elements="txfSearchPath" resizable="true"
|
||||
href="chrome://inspector/content/search/modules/junkImgs/dialog.xul"/>
|
||||
|
||||
<columns delimiter="">
|
||||
<column title="Path" name="path" flex="1" copy="true"/>
|
||||
</columns>
|
||||
|
||||
<contextmenu>
|
||||
<xul:menuitem label="View..." oncommand="this.search.cmdViewItem()" isEnabled="return true"/>
|
||||
<xul:menuitem label="Delete File" oncommand="this.search.cmdDeleteItems()" isEnabled="return true"/>
|
||||
</contextmenu>
|
||||
|
||||
<implementation>
|
||||
|
||||
<method name="constructor">
|
||||
<body><![CDATA[
|
||||
mHashTable = null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="progressPercent">
|
||||
<getter><![CDATA[
|
||||
return (100 * (this.mFileSearch.directoriesSearched+1)) / this.mDirDepth
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="progressText">
|
||||
<getter><![CDATA[
|
||||
return "blah"
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="isPastMilestone">
|
||||
<getter><![CDATA[
|
||||
var search = this.mFileSearch.directoriesSearched;
|
||||
var is = search > this.mDirsSearched;
|
||||
if (is)
|
||||
this.mDirsSearched = search;
|
||||
return is;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<method name="searchStart">
|
||||
<parameter name="aMap"/>
|
||||
<body><![CDATA[
|
||||
this.mParams = aMap;
|
||||
this.mDirsSearched = 0;
|
||||
|
||||
// hash every image url in the css tree
|
||||
this.buildCSSImageURLHash();
|
||||
|
||||
var fsearch = inSearchUtils.createSearchHelper("file");
|
||||
this.mFileSearch = fsearch;
|
||||
|
||||
var root = inSearchUtils.createLocalFile(aMap.txfSearchPath);
|
||||
|
||||
fsearch.searchPath = root;
|
||||
fsearch.filenameCriteria = "*.gif,*.png,*.jpg";
|
||||
fsearch.holdResults = false;
|
||||
fsearch.basePath = aMap.txfSearchPath;
|
||||
fsearch.returnRelativePaths = true;
|
||||
|
||||
this.mDirDepth = fsearch.getDirectoryDepth(root);
|
||||
|
||||
var observer = inSearchUtils.createSearchObserver(this, "File");
|
||||
fsearch.searchAsync(observer);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="searchStop">
|
||||
<body><![CDATA[
|
||||
if (this.mFileSearch)
|
||||
this.mFileSearch.searchStop();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="buildCSSImageURLHash">
|
||||
<body><![CDATA[
|
||||
var cssSearch = inSearchUtils.createSearchHelper("cssvalue");
|
||||
cssSearch.returnRelativeURLs = true;
|
||||
cssSearch.normalizeChromeURLs = true; //this.mParams.cbIsSkin;
|
||||
cssSearch.addPropertyCriteria("background-image");
|
||||
cssSearch.addPropertyCriteria("list-style-image");
|
||||
cssSearch.document = inspector.document;
|
||||
|
||||
cssSearch.searchSync(this);
|
||||
var count = cssSearch.resultCount;
|
||||
var hash = {};
|
||||
for (var i = 0; i < count; i++) {
|
||||
//debug(cssSearch.getStringResultAt(i)+"\n");
|
||||
hash[cssSearch.getStringResultAt(i)] = 1;
|
||||
}
|
||||
|
||||
this.mHashTable = hash;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="returnSearchResult">
|
||||
<parameter name="aFile"/>
|
||||
<body><![CDATA[
|
||||
this.module.setResultProperty("path", aFile.path);
|
||||
this.module.searchResultReady();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- context menu commands -->
|
||||
|
||||
<method name="cmdDeleteItems">
|
||||
<body><![CDATA[
|
||||
var mod = this.module;
|
||||
var svc = mod.searchService;
|
||||
var count = svc.selectedItemCount;
|
||||
var idx, path, file;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
idx = svc.getSelectedIndex(i);
|
||||
path = mod.getResultPropertyAt(idx, "path");
|
||||
file = inSearchUtils.createLocalFile(path);
|
||||
if (file) {
|
||||
file.remove(false);
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="cmdViewItem" defaultCommand="true">
|
||||
<body><![CDATA[
|
||||
alert("view");
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- FileSearch observer -->
|
||||
|
||||
<method name="onFileSearchStart">
|
||||
<parameter name="aProcess"/>
|
||||
<body/>
|
||||
</method>
|
||||
|
||||
<method name="onFileSearchResult">
|
||||
<parameter name="aProcess"/>
|
||||
<body><![CDATA[
|
||||
var fs = this.mFileSearch;
|
||||
var idx = fs.resultCount-1;
|
||||
// get the relative-ized path for the file
|
||||
var path = fs.getStringResultAt(idx);
|
||||
|
||||
// check if this path is in the css value hash
|
||||
if (!this.mHashTable[path])
|
||||
this.returnSearchResult(fs.getFileResultAt(idx));
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onFileSearchEnd">
|
||||
<parameter name="aProcess"/>
|
||||
<parameter name="aResult"/>
|
||||
<body><![CDATA[
|
||||
this.module.searchEnd();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onFileSearchError">
|
||||
<parameter name="aProcess"/>
|
||||
<parameter name="aMsg"/>
|
||||
<body/>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
</search>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/search/junkImgs.dtd"> %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://inspector/locale/search/findFiles.dtd"> %dtd2;
|
||||
]>
|
||||
|
||||
<overlay id="ovJunkImgsPopup"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<menupopup id="mppSearchPlugins" onpopupshowing="inspector.initPopup(this);">
|
||||
|
||||
<menuitem id="item:startFindFiles" position="1"
|
||||
label="&findFiles.title;"
|
||||
observes="cmd:startFindFiles"/>
|
||||
|
||||
<menuitem id="item:startJunkImgs" position="2"
|
||||
label="&junkImgs.title;"
|
||||
isDisabled="return !inspector.isViewingContent"
|
||||
observes="cmd:startJunkImgs"/>
|
||||
|
||||
<menuseparator position="3"/>
|
||||
|
||||
</menupopup>
|
||||
|
||||
</overlay>
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче