зеркало из https://github.com/mozilla/gecko-dev.git
Adding advanced query builder for places.
bug=317831 r=beng
This commit is contained in:
Родитель
1a433a3e88
Коммит
39c67440c7
|
@ -5,7 +5,8 @@
|
||||||
<command id="placesCmd_export" label="&cmd.export.label;" accesskey="&cmd.export.accesskey;"/>
|
<command id="placesCmd_export" label="&cmd.export.label;" accesskey="&cmd.export.accesskey;"/>
|
||||||
<command id="placesCmd_import"/>
|
<command id="placesCmd_import"/>
|
||||||
<command id="placesCmd_search:save"/>
|
<command id="placesCmd_search:save"/>
|
||||||
<command id="placesCmd_search:moreCriteria"/>
|
<command id="placesCmd_search:moreCriteria"
|
||||||
|
oncommand="PlacesQueryBuilder.toggle();"/>
|
||||||
<command id="placesCmd_select:all"
|
<command id="placesCmd_select:all"
|
||||||
label="&cmd.select_all.label;" accesskey="&cmd.select_all.accesskey;"
|
label="&cmd.select_all.label;" accesskey="&cmd.select_all.accesskey;"
|
||||||
oncommand="PlacesController.selectAll();"/>
|
oncommand="PlacesController.selectAll();"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#historyCalendar {
|
.history-calendar {
|
||||||
-moz-binding: url("chrome://browser/content/places/places.xml#calendar");
|
-moz-binding: url("chrome://browser/content/places/places.xml#calendar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,16 @@ var PlacesPage = {
|
||||||
_content: null,
|
_content: null,
|
||||||
_places: null,
|
_places: null,
|
||||||
|
|
||||||
|
// the NavHistory service
|
||||||
|
__hist: null,
|
||||||
|
get _hist() {
|
||||||
|
if (!this.__hist) {
|
||||||
|
this.__hist =
|
||||||
|
Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
|
||||||
|
}
|
||||||
|
return this.__hist;
|
||||||
|
},
|
||||||
|
|
||||||
init: function PP_init() {
|
init: function PP_init() {
|
||||||
// Attach the Command Controller to the Places Views.
|
// Attach the Command Controller to the Places Views.
|
||||||
this._places = document.getElementById("placesList");
|
this._places = document.getElementById("placesList");
|
||||||
|
@ -204,6 +214,9 @@ var PlacesPage = {
|
||||||
|
|
||||||
// Set up the search UI.
|
// Set up the search UI.
|
||||||
PlacesSearchBox.init();
|
PlacesSearchBox.init();
|
||||||
|
|
||||||
|
// Set up the advanced query builder UI
|
||||||
|
PlacesQueryBuilder.init();
|
||||||
},
|
},
|
||||||
|
|
||||||
uninit: function PP_uninit() {
|
uninit: function PP_uninit() {
|
||||||
|
@ -241,9 +254,23 @@ var PlacesPage = {
|
||||||
/**
|
/**
|
||||||
* Fill the header with information about what view is being displayed.
|
* Fill the header with information about what view is being displayed.
|
||||||
*/
|
*/
|
||||||
_setHeader: function(isSearch, text) {
|
_setHeader: function(type, text) {
|
||||||
var bundle = document.getElementById("placeBundle");
|
var bundle = document.getElementById("placeBundle");
|
||||||
var key = isSearch ? "headerTextResultsFor" : "headerTextShowing";
|
var key = null;
|
||||||
|
var isSearch = false;
|
||||||
|
switch(type) {
|
||||||
|
case "showing":
|
||||||
|
key = "headerTextShowing";
|
||||||
|
break;
|
||||||
|
case "results":
|
||||||
|
isSearch = true;
|
||||||
|
key = "headerTextResultsFor";
|
||||||
|
break;
|
||||||
|
case "advanced":
|
||||||
|
isSearch = true;
|
||||||
|
key = "headerTextAdvancedSearch";
|
||||||
|
break;
|
||||||
|
}
|
||||||
var showingPrefix = document.getElementById("showingPrefix");
|
var showingPrefix = document.getElementById("showingPrefix");
|
||||||
showingPrefix.setAttribute("value", bundle.getString(key));
|
showingPrefix.setAttribute("value", bundle.getString(key));
|
||||||
|
|
||||||
|
@ -266,11 +293,11 @@ var PlacesPage = {
|
||||||
case "collection":
|
case "collection":
|
||||||
var folder = this._content.getResult().folderId;
|
var folder = this._content.getResult().folderId;
|
||||||
this._content.applyFilter(filterString, true, folder);
|
this._content.applyFilter(filterString, true, folder);
|
||||||
this._setHeader(true, filterString);
|
this._setHeader("results", filterString);
|
||||||
break;
|
break;
|
||||||
case "all":
|
case "all":
|
||||||
this._content.filterString = filterString;
|
this._content.filterString = filterString;
|
||||||
this._setHeader(true, filterString);
|
this._setHeader("results", filterString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -299,7 +326,7 @@ var PlacesPage = {
|
||||||
newOptions.setGroupingMode(groupings, groupings.length);
|
newOptions.setGroupingMode(groupings, groupings.length);
|
||||||
this._content.load(newQueries, newOptions);
|
this._content.load(newQueries, newOptions);
|
||||||
|
|
||||||
this._setHeader(false, node.title);
|
this._setHeader("showing", node.title);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -428,3 +455,422 @@ var PlacesSearchBox = {
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions and data for advanced query builder
|
||||||
|
*/
|
||||||
|
var PlacesQueryBuilder = {
|
||||||
|
|
||||||
|
_numRows: 1,
|
||||||
|
_maxRows: 4,
|
||||||
|
|
||||||
|
_keywordSearch: {
|
||||||
|
advancedSearch_N_Subject: "advancedSearch_N_SubjectKeyword",
|
||||||
|
advancedSearch_N_HostMenulist: false,
|
||||||
|
advancedSearch_N_KeywordLabel: true,
|
||||||
|
advancedSearch_N_UriMenulist: false,
|
||||||
|
advancedSearch_N_TimeMenulist: false,
|
||||||
|
advancedSearch_N_Textbox: "",
|
||||||
|
advancedSearch_N_TimePicker: false,
|
||||||
|
advancedSearch_N_TimeMenulist2: false,
|
||||||
|
},
|
||||||
|
_hostSearch: {
|
||||||
|
advancedSearch_N_Subject: "advancedSearch_N_SubjectHost",
|
||||||
|
advancedSearch_N_HostMenulist: "advancedSearch_N_HostMenuSelected",
|
||||||
|
advancedSearch_N_KeywordLabel: false,
|
||||||
|
advancedSearch_N_UriMenulist: false,
|
||||||
|
advancedSearch_N_TimeMenulist: false,
|
||||||
|
advancedSearch_N_Textbox: "",
|
||||||
|
advancedSearch_N_TimePicker: false,
|
||||||
|
advancedSearch_N_TimeMenulist2: false,
|
||||||
|
},
|
||||||
|
_uriSearch: {
|
||||||
|
advancedSearch_N_Subject: "advancedSearch_N_SubjectUri",
|
||||||
|
advancedSearch_N_HostMenulist: false,
|
||||||
|
advancedSearch_N_KeywordLabel: false,
|
||||||
|
advancedSearch_N_UriMenulist: "advancedSearch_N_UriMenuSelected",
|
||||||
|
advancedSearch_N_TimeMenulist: false,
|
||||||
|
advancedSearch_N_Textbox: "http://",
|
||||||
|
advancedSearch_N_TimePicker: false,
|
||||||
|
advancedSearch_N_TimeMenulist2: false,
|
||||||
|
},
|
||||||
|
_timeSearch: {
|
||||||
|
advancedSearch_N_Subject: "advancedSearch_N_SubjectVisited",
|
||||||
|
advancedSearch_N_HostMenulist: false,
|
||||||
|
advancedSearch_N_KeywordLabel: false,
|
||||||
|
advancedSearch_N_UriMenulist: false,
|
||||||
|
advancedSearch_N_TimeMenulist: true,
|
||||||
|
advancedSearch_N_Textbox: false,
|
||||||
|
advancedSearch_N_TimePicker: "date",
|
||||||
|
advancedSearch_N_TimeMenulist2: false,
|
||||||
|
},
|
||||||
|
_timeInLastSearch: {
|
||||||
|
advancedSearch_N_Subject: "advancedSearch_N_SubjectVisited",
|
||||||
|
advancedSearch_N_HostMenulist: false,
|
||||||
|
advancedSearch_N_KeywordLabel: false,
|
||||||
|
advancedSearch_N_UriMenulist: false,
|
||||||
|
advancedSearch_N_TimeMenulist: true,
|
||||||
|
advancedSearch_N_Textbox: "7",
|
||||||
|
advancedSearch_N_TimePicker: false,
|
||||||
|
advancedSearch_N_TimeMenulist2: true,
|
||||||
|
},
|
||||||
|
_nextSearch: null,
|
||||||
|
_queryBuilders: null,
|
||||||
|
|
||||||
|
init: function PQB_init() {
|
||||||
|
// Initialize advanced search
|
||||||
|
this._nextSearch = {
|
||||||
|
"keyword": this._timeSearch,
|
||||||
|
"visited": this._hostSearch,
|
||||||
|
"host": this._uriSearch,
|
||||||
|
"uri": this._keywordSearch,
|
||||||
|
};
|
||||||
|
|
||||||
|
this._queryBuilders = {
|
||||||
|
"keyword": this.setKeywordQuery,
|
||||||
|
"visited": this.setVisitedQuery,
|
||||||
|
"host": this.setHostQuery,
|
||||||
|
"uri": this.setUriQuery,
|
||||||
|
};
|
||||||
|
|
||||||
|
this._dateService = Cc["@mozilla.org/intl/scriptabledateformat;1"].
|
||||||
|
getService(Ci.nsIScriptableDateFormat);
|
||||||
|
},
|
||||||
|
|
||||||
|
toggle: function PQB_toggle() {
|
||||||
|
var advancedSearch = document.getElementById("advancedSearch");
|
||||||
|
if (advancedSearch.collapsed) {
|
||||||
|
// Need to expand the advanced search box and initialize it.
|
||||||
|
|
||||||
|
// Should have one row, containing a keyword search with
|
||||||
|
// the keyword from the basic search box pre-filled.
|
||||||
|
while (this._numRows > 1)
|
||||||
|
this.removeRow();
|
||||||
|
this.showSearch(1, this._keywordSearch);
|
||||||
|
var searchbox = document.getElementById("searchFilter");
|
||||||
|
var keywordbox = document.getElementById("advancedSearch1Textbox");
|
||||||
|
keywordbox.value = searchbox.value;
|
||||||
|
advancedSearch.collapsed = false;
|
||||||
|
|
||||||
|
// Update the +/- button and the header.
|
||||||
|
var button = document.getElementById("moreCriteria");
|
||||||
|
var placeBundle = document.getElementById("placeBundle");
|
||||||
|
button.label = placeBundle.getString("lessCriteria.label");
|
||||||
|
PlacesPage._setHeader("advanced", "");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Need to collapse the advanced search box.
|
||||||
|
advancedSearch.collapsed = true;
|
||||||
|
|
||||||
|
// Update the +/- button
|
||||||
|
var button = document.getElementById("moreCriteria");
|
||||||
|
var placeBundle = document.getElementById("placeBundle");
|
||||||
|
button.label = placeBundle.getString("moreCriteria.label");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setRowId: function PQB_setRowId(element, rowId) {
|
||||||
|
if (element.id)
|
||||||
|
element.id = element.id.replace("advancedSearch1", "advancedSearch" + rowId);
|
||||||
|
if (element.hasAttribute('rowid'))
|
||||||
|
element.setAttribute('rowid', rowId);
|
||||||
|
for (var i = 0; i < element.childNodes.length; i++) {
|
||||||
|
this.setRowId(element.childNodes[i], rowId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateUIForRowChange: function PQB_updateUIForRowChange() {
|
||||||
|
// Titlebar should show "match any/all" iff there are > 1 queries visible.
|
||||||
|
var matchUI = document.getElementById("titlebarMatch");
|
||||||
|
matchUI.hidden = (this._numRows <= 1);
|
||||||
|
PlacesPage._setHeader("advanced", this._numRows <= 1 ? "" : ",");
|
||||||
|
|
||||||
|
// Disable the + buttons if there are max advanced search rows
|
||||||
|
// Disable the - button is there is only one advanced search row
|
||||||
|
for (var i = 1; i <= this._numRows; i++) {
|
||||||
|
var plus = document.getElementById("advancedSearch" + i + "Plus");
|
||||||
|
plus.disabled = (this._numRows >= this._maxRows);
|
||||||
|
var minus = document.getElementById("advancedSearch" + i + "Minus");
|
||||||
|
minus.disabled = (this._numRows == 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addRow: function PQB_addRow() {
|
||||||
|
if (this._numRows >= this._maxRows)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var gridRows = document.getElementById("advancedSearchRows");
|
||||||
|
var newRow = gridRows.firstChild.cloneNode(true);
|
||||||
|
|
||||||
|
var searchType = this._keywordSearch;
|
||||||
|
var lastMenu = document.getElementById("advancedSearch" +
|
||||||
|
this._numRows +
|
||||||
|
"Subject");
|
||||||
|
if (lastMenu && lastMenu.selectedItem) {
|
||||||
|
searchType = this._nextSearch[lastMenu.selectedItem.value];
|
||||||
|
}
|
||||||
|
|
||||||
|
this._numRows++;
|
||||||
|
this.setRowId(newRow, this._numRows);
|
||||||
|
this.showSearch(this._numRows, searchType);
|
||||||
|
gridRows.appendChild(newRow);
|
||||||
|
this.updateUIForRowChange();
|
||||||
|
},
|
||||||
|
|
||||||
|
removeRow: function PQB_removeRow() {
|
||||||
|
if (this._numRows <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var row = document.getElementById("advancedSearch" + this._numRows + "Row");
|
||||||
|
row.parentNode.removeChild(row);
|
||||||
|
this._numRows--;
|
||||||
|
|
||||||
|
this.updateUIForRowChange();
|
||||||
|
},
|
||||||
|
|
||||||
|
onDateTyped: function PQB_onDateTyped(event, row) {
|
||||||
|
var textbox = document.getElementById("advancedSearch" + row + "TimePicker");
|
||||||
|
var dateString = textbox.value;
|
||||||
|
var dateArr = dateString.split("-");
|
||||||
|
// The date can be split into a range by the '-' character, i.e.
|
||||||
|
// 9/5/05 - 10/2/05. Unfortunately, dates can also be written like
|
||||||
|
// 9-5-05 - 10-2-05. Try to parse the date based on how many hyphens
|
||||||
|
// there are.
|
||||||
|
var d0 = null;
|
||||||
|
var d1 = null;
|
||||||
|
// If there are an even number of elements in the date array, try to
|
||||||
|
// parse it as a range of two dates.
|
||||||
|
if ((dateArr.length & 1) == 0) {
|
||||||
|
var mid = dateArr.length / 2;
|
||||||
|
var dateStr0 = dateArr[0];
|
||||||
|
var dateStr1 = dateArr[mid];
|
||||||
|
for (var i = 1; i < mid; i++) {
|
||||||
|
dateStr0 += "-" + dateArr[i];
|
||||||
|
dateStr1 += "-" + dateArr[i + mid];
|
||||||
|
}
|
||||||
|
d0 = new Date(dateStr0);
|
||||||
|
d1 = new Date(dateStr1);
|
||||||
|
}
|
||||||
|
// If that didn't work, try to parse it as a single date.
|
||||||
|
if (d0 == null || d0 == "Invalid Date") {
|
||||||
|
d0 = new Date(dateString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d0 != null && d0 != "Invalid Date") {
|
||||||
|
// Parsing succeeded -- update the calendar.
|
||||||
|
var calendar = document.getElementById("advancedSearch" + row + "Calendar");
|
||||||
|
if (d0.getFullYear() < 2000)
|
||||||
|
d0.setFullYear(2000 + (d0.getFullYear() % 100));
|
||||||
|
if (d1 != null && d1 != "Invalid Date") {
|
||||||
|
if (d1.getFullYear() < 2000)
|
||||||
|
d1.setFullYear(2000 + (d1.getFullYear() % 100));
|
||||||
|
calendar.updateSelection(d0, d1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
calendar.updateSelection(d0, d0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// And update the search.
|
||||||
|
this.doSearch();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onCalendarChanged: function PQB_onCalendarChanged(event, row) {
|
||||||
|
var calendar = document.getElementById("advancedSearch" + row + "Calendar");
|
||||||
|
var begin = calendar.beginrange;
|
||||||
|
var end = calendar.endrange;
|
||||||
|
|
||||||
|
// If the calendar doesn't have a begin/end, don't change the textbox.
|
||||||
|
if (begin == null || end == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If the begin and end are the same day, only fill that into the textbox.
|
||||||
|
var textbox = document.getElementById("advancedSearch" + row + "TimePicker");
|
||||||
|
var beginDate = begin.getDate();
|
||||||
|
var beginMonth = begin.getMonth() + 1;
|
||||||
|
var beginYear = begin.getFullYear();
|
||||||
|
var endDate = end.getDate();
|
||||||
|
var endMonth = end.getMonth() + 1;
|
||||||
|
var endYear = end.getFullYear();
|
||||||
|
if (beginDate == endDate && beginMonth == endMonth && beginYear == endYear) {
|
||||||
|
// Just one date.
|
||||||
|
textbox.value = this._dateService.FormatDate("",
|
||||||
|
this._dateService.dateFormatShort,
|
||||||
|
beginYear,
|
||||||
|
beginMonth,
|
||||||
|
beginDate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Two dates.
|
||||||
|
var beginStr = this._dateService.FormatDate("",
|
||||||
|
this._dateService.dateFormatShort,
|
||||||
|
beginYear,
|
||||||
|
beginMonth,
|
||||||
|
beginDate);
|
||||||
|
var endStr = this._dateService.FormatDate("",
|
||||||
|
this._dateService.dateFormatShort,
|
||||||
|
endYear,
|
||||||
|
endMonth,
|
||||||
|
endDate);
|
||||||
|
textbox.value = beginStr + " - " + endStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the search.
|
||||||
|
this.doSearch();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleTimePickerClick: function PQB_handleTimePickerClick(event, row) {
|
||||||
|
var popup = document.getElementById("advancedSearch" + row + "DatePopup");
|
||||||
|
if (popup.showing)
|
||||||
|
popup.hidePopup();
|
||||||
|
else {
|
||||||
|
var textbox = document.getElementById("advancedSearch" + row + "TimePicker");
|
||||||
|
popup.showPopup(textbox, -1, -1, "popup", "bottomleft", "topleft");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
showSearch: function PQB_showSearch(row, values) {
|
||||||
|
for (val in values) {
|
||||||
|
var id = val.replace("_N_", row);
|
||||||
|
var element = document.getElementById(id);
|
||||||
|
if (values[val] || typeof(values[val]) == "string") {
|
||||||
|
if (typeof(values[val]) == "string") {
|
||||||
|
if (values[val] == "date") {
|
||||||
|
// "date" means that the current date should be filled into the
|
||||||
|
// textbox, and the calendar for the row updated.
|
||||||
|
var d = new Date();
|
||||||
|
element.value = this._dateService.FormatDate("",
|
||||||
|
this._dateService.dateFormatShort,
|
||||||
|
d.getFullYear(),
|
||||||
|
d.getMonth() + 1,
|
||||||
|
d.getDate());
|
||||||
|
var calendar = document.getElementById("advancedSearch" + row + "Calendar");
|
||||||
|
calendar.updateSelection(d, d);
|
||||||
|
}
|
||||||
|
else if (element.nodeName == "textbox") {
|
||||||
|
// values[val] is the initial value of the textbox.
|
||||||
|
element.value = values[val];
|
||||||
|
} else {
|
||||||
|
// values[val] is the menuitem which should be selected.
|
||||||
|
var itemId = values[val].replace("_N_", row);
|
||||||
|
var item = document.getElementById(itemId);
|
||||||
|
element.selectedItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
element.hidden = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
element.hidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.doSearch();
|
||||||
|
},
|
||||||
|
|
||||||
|
setKeywordQuery: function PQB_setKeywordQuery(query, prefix) {
|
||||||
|
query.searchTerms += document.getElementById(prefix + "Textbox").value + " ";
|
||||||
|
},
|
||||||
|
|
||||||
|
setUriQuery: function PQB_setUriQuery(query, prefix) {
|
||||||
|
var matchType = document.getElementById(prefix + "UriMenulist").selectedItem.value;
|
||||||
|
if (matchType == "startsWith")
|
||||||
|
query.uriIsPrefix = true;
|
||||||
|
else
|
||||||
|
query.uriIsPrefix = false;
|
||||||
|
|
||||||
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
|
getService(Ci.nsIIOService);
|
||||||
|
var spec = document.getElementById(prefix + "Textbox").value;
|
||||||
|
query.uri = ios.newURI(spec, null, null);
|
||||||
|
},
|
||||||
|
|
||||||
|
setHostQuery: function PQB_setHostQuery(query, prefix) {
|
||||||
|
if (document.getElementById(prefix + "HostMenulist").selectedItem.value == "is")
|
||||||
|
query.domainIsHost = true;
|
||||||
|
query.domain = document.getElementById(prefix + "Textbox").value;
|
||||||
|
},
|
||||||
|
|
||||||
|
setVisitedQuery: function PQB_setVisitedQuery(query, prefix) {
|
||||||
|
var searchType = document.getElementById(prefix + "TimeMenulist").selectedItem.value;
|
||||||
|
const DAY_MSEC = 86400000;
|
||||||
|
switch (searchType) {
|
||||||
|
case "on":
|
||||||
|
var calendar = document.getElementById(prefix + "Calendar");
|
||||||
|
var begin = calendar.beginrange.getTime();
|
||||||
|
var end = calendar.endrange.getTime();
|
||||||
|
if (begin == end) {
|
||||||
|
end = begin + DAY_MSEC;
|
||||||
|
}
|
||||||
|
query.beginTime = begin * 1000;
|
||||||
|
query.endTime = end * 1000;
|
||||||
|
break;
|
||||||
|
case "before":
|
||||||
|
var calendar = document.getElementById(prefix + "Calendar");
|
||||||
|
var time = calendar.beginrange.getTime();
|
||||||
|
query.endTime = time * 1000;
|
||||||
|
break;
|
||||||
|
case "after":
|
||||||
|
var calendar = document.getElementById(prefix + "Calendar");
|
||||||
|
var time = calendar.endrange.getTime();
|
||||||
|
query.beginTime = time * 1000;
|
||||||
|
break;
|
||||||
|
case "inLast":
|
||||||
|
var textbox = document.getElementById(prefix + "Textbox");
|
||||||
|
var amount = parseInt(textbox.value);
|
||||||
|
amount = amount * DAY_MSEC;
|
||||||
|
var menulist = document.getElementById(prefix + "TimeMenulist2");
|
||||||
|
if (menulist.selectedItem.value == "weeks")
|
||||||
|
amount = amount * 7;
|
||||||
|
else if (menulist.selectedItem.value == "months")
|
||||||
|
amount = amount * 30;
|
||||||
|
var now = new Date();
|
||||||
|
now = now - amount;
|
||||||
|
query.beginTime = now * 1000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
doSearch: function PQB_doSearch() {
|
||||||
|
// Create the individual queries.
|
||||||
|
var queryType = document.getElementById("advancedSearchType").selectedItem.value;
|
||||||
|
var queries = [];
|
||||||
|
if (queryType == "and")
|
||||||
|
queries.push(PlacesPage._hist.getNewQuery());
|
||||||
|
var onlyBookmarked = document.getElementById("advancedSearchOnlyBookmarked").checked;
|
||||||
|
for (var i = 1; i <= this._numRows; i++) {
|
||||||
|
var prefix = "advancedSearch" + i;
|
||||||
|
|
||||||
|
// If the queries are being AND-ed, put all the rows in one query.
|
||||||
|
// If they're being OR-ed, add a separate query for each row.
|
||||||
|
var query;
|
||||||
|
if (queryType == "and")
|
||||||
|
query = queries[0];
|
||||||
|
else
|
||||||
|
query = PlacesPage._hist.getNewQuery();
|
||||||
|
query.onlyBookmarked = onlyBookmarked;
|
||||||
|
|
||||||
|
var querySubject = document.getElementById(prefix + "Subject").value;
|
||||||
|
this._queryBuilders[querySubject](query, prefix);
|
||||||
|
|
||||||
|
if (queryType == "or")
|
||||||
|
queries.push(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set max results
|
||||||
|
var result = PlacesPage._content.getResult();
|
||||||
|
if (document.getElementById("advancedSearchHasMax").checked) {
|
||||||
|
var max = parseInt(document.getElementById("advancedSearchMaxResults").value);
|
||||||
|
if (isNaN(max))
|
||||||
|
max = 100;
|
||||||
|
result.queryOptions.maxResults = max;
|
||||||
|
dump("Max results = " + result.queryOptions.maxResults + "(" + max + ")\n");
|
||||||
|
}
|
||||||
|
// Make sure we're getting url results, not visits
|
||||||
|
result.queryOptions.resultType = result.queryOptions.RESULT_TYPE_URL;
|
||||||
|
|
||||||
|
PlacesPage._content.load(queries, result.queryOptions);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox id="historyCalendar"
|
<vbox id="historyCalendar"
|
||||||
|
class="history-calendar"
|
||||||
onselectionchanged="return PlacesPage.rangeSelected()"/>
|
onselectionchanged="return PlacesPage.rangeSelected()"/>
|
||||||
<hbox class="commands">
|
<hbox class="commands">
|
||||||
<button id="newFolder" view="placesList" command="placesCmd_new:folder"/>
|
<button id="newFolder" view="placesList" command="placesCmd_new:folder"/>
|
||||||
|
@ -87,16 +88,177 @@
|
||||||
<hbox id="titlebar" align="center">
|
<hbox id="titlebar" align="center">
|
||||||
<label id="showingPrefix"/>
|
<label id="showingPrefix"/>
|
||||||
<label id="contentTitle"/>
|
<label id="contentTitle"/>
|
||||||
|
<hbox align="center" id="titlebarMatch" hidden="true">
|
||||||
|
<label value="&advancedSearch.match.label;"/>
|
||||||
|
<menulist id="advancedSearchType"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="and" label="&advancedSearch.all.label;"/>
|
||||||
|
<menuitem value="or" label="&advancedSearch.any.label;"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
<label value="&advancedSearch.rules.label;"/>
|
||||||
|
</hbox>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<hbox id="searchModifiers" hidden="true" align="center">
|
<hbox id="searchModifiers" hidden="true" align="center">
|
||||||
<button id="saveSearch" class="small"
|
<button id="saveSearch" class="small"
|
||||||
label="&saveSearch.label;" accesskey="&saveSearch.accesskey;"
|
label="&saveSearch.label;" accesskey="&saveSearch.accesskey;"
|
||||||
command="placesCmd_search:save"/>
|
command="placesCmd_search:save"/>
|
||||||
<button class="small"
|
<button id="moreCriteria"
|
||||||
|
class="small"
|
||||||
label="&moreCriteria.label;"
|
label="&moreCriteria.label;"
|
||||||
command="placesCmd_search:moreCriteria"/>
|
command="placesCmd_search:moreCriteria"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
<vbox id="advancedSearch" collapsed="true">
|
||||||
|
<grid flex="1">
|
||||||
|
<columns>
|
||||||
|
<column flex="1"/>
|
||||||
|
<column flex="1"/>
|
||||||
|
<column flex="0"/>
|
||||||
|
<column flex="0"/>
|
||||||
|
</columns>
|
||||||
|
<rows id="advancedSearchRows">
|
||||||
|
<row id="advancedSearch1Row" flex="1">
|
||||||
|
<menulist id="advancedSearch1Subject" flex="1">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="keyword"
|
||||||
|
label="&advancedSearch.subj_keyword.label;"
|
||||||
|
selected="true"
|
||||||
|
rowid="1"
|
||||||
|
id="advancedSearch1SubjectKeyword"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._keywordSearch);"/>
|
||||||
|
<menuitem value="visited"
|
||||||
|
label="&advancedSearch.subj_visited.label;"
|
||||||
|
rowid="1"
|
||||||
|
id="advancedSearch1SubjectVisited"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._timeSearch);"/>
|
||||||
|
<menuitem value="host"
|
||||||
|
label="&advancedSearch.subj_host.label;"
|
||||||
|
rowid="1"
|
||||||
|
id="advancedSearch1SubjectHost"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._hostSearch);"/>
|
||||||
|
<menuitem value="uri"
|
||||||
|
label="&advancedSearch.subj_uri.label;"
|
||||||
|
rowid="1"
|
||||||
|
id="advancedSearch1SubjectUri"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._uriSearch);"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
|
||||||
|
<hbox flex="1" align="center">
|
||||||
|
<menulist id="advancedSearch1HostMenulist"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();"
|
||||||
|
hidden="true">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem id="advancedSearch1HostMenuSelected"
|
||||||
|
value="is"
|
||||||
|
label="&advancedSearch.host_is.label;"
|
||||||
|
selected="true"/>
|
||||||
|
<menuitem value="endsWith"
|
||||||
|
label="&advancedSearch.host_endswith.label;"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
|
||||||
|
<label id="advancedSearch1KeywordLabel"
|
||||||
|
value="&advancedSearch.include.label;"/>
|
||||||
|
|
||||||
|
<menulist id="advancedSearch1UriMenulist"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();"
|
||||||
|
hidden="true">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="is"
|
||||||
|
label="&advancedSearch.uri_is.label;"/>
|
||||||
|
<menuitem id="advancedSearch1UriMenuSelected"
|
||||||
|
value="startsWith"
|
||||||
|
selected="true"
|
||||||
|
label="&advancedSearch.uri_startswith.label;"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
|
||||||
|
<menulist id="advancedSearch1TimeMenulist" hidden="true">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="on"
|
||||||
|
id="advancedSearch1TimeDefault"
|
||||||
|
label="&advancedSearch.time_is.label;"
|
||||||
|
selected="true"
|
||||||
|
rowid="1"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._timeSearch);"/>
|
||||||
|
<menuitem value="before"
|
||||||
|
label="&advancedSearch.time_before.label;"
|
||||||
|
rowid="1"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._timeSearch);"/>
|
||||||
|
<menuitem value="after"
|
||||||
|
label="&advancedSearch.time_after.label;"
|
||||||
|
rowid="1"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._timeSearch);"/>
|
||||||
|
<menuitem value="inLast"
|
||||||
|
label="&advancedSearch.time_inlast.label;"
|
||||||
|
rowid="1"
|
||||||
|
oncommand="PlacesQueryBuilder.showSearch(this.getAttribute('rowid'), PlacesQueryBuilder._timeInLastSearch);"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
<textbox id="advancedSearch1Textbox"
|
||||||
|
flex="1"
|
||||||
|
oninput="PlacesQueryBuilder.doSearch();"/>
|
||||||
|
|
||||||
|
<textbox id="advancedSearch1TimePicker"
|
||||||
|
hidden="true" flex="1"
|
||||||
|
rowid="1"
|
||||||
|
oninput="PlacesQueryBuilder.onDateTyped(event, this.getAttribute('rowid'));"
|
||||||
|
onclick="PlacesQueryBuilder.handleTimePickerClick(event, this.getAttribute('rowid'));"/>
|
||||||
|
<popup id="advancedSearch1DatePopup"
|
||||||
|
onpopupshowing="this.setAttribute('showing', true);"
|
||||||
|
onpopuphidden="this.removeAttribute('showing');">
|
||||||
|
<vbox id="advancedSearch1Calendar"
|
||||||
|
class="history-calendar"
|
||||||
|
rowid="1"
|
||||||
|
onselectionchanged="return PlacesQueryBuilder.onCalendarChanged(event, event.target.getAttribute('rowid'));"/>
|
||||||
|
</popup>
|
||||||
|
|
||||||
|
<menulist id="advancedSearch1TimeMenulist2"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();"
|
||||||
|
hidden="true">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="days"
|
||||||
|
label="&advancedSearch.last_days.label;"
|
||||||
|
selected="true"/>
|
||||||
|
<menuitem value="weeks"
|
||||||
|
label="&advancedSearch.last_weeks.label;"/>
|
||||||
|
<menuitem value="months"
|
||||||
|
label="&advancedSearch.last_months.label;"/>
|
||||||
|
</menupopup>
|
||||||
|
</menulist>
|
||||||
|
|
||||||
|
</hbox>
|
||||||
|
<button id="advancedSearch1Plus"
|
||||||
|
label="&advancedSearch.plus.label;"
|
||||||
|
class="no-margin-button"
|
||||||
|
oncommand="PlacesQueryBuilder.addRow();"/>
|
||||||
|
<button id="advancedSearch1Minus"
|
||||||
|
disabled="true"
|
||||||
|
label="&advancedSearch.minus.label;"
|
||||||
|
class="no-margin-button"
|
||||||
|
oncommand="PlacesQueryBuilder.removeRow();"/>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
<hbox align="center">
|
||||||
|
<checkbox id="advancedSearchOnlyBookmarked"
|
||||||
|
label="&advancedSearch.onlybookmarked.label;"
|
||||||
|
checked="false"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();"/>
|
||||||
|
<spacer flex="1"/>
|
||||||
|
<checkbox id="advancedSearchHasMax"
|
||||||
|
label="&advancedSearch.max.label;"
|
||||||
|
oncommand="PlacesQueryBuilder.doSearch();"
|
||||||
|
checked="true"/>
|
||||||
|
<textbox id="advancedSearchMaxResults"
|
||||||
|
oninput="PlacesQueryBuilder.doSearch();"
|
||||||
|
value="100"/>
|
||||||
|
<spacer flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
</vbox>
|
||||||
<tree id="placeContent" class="placesTree" context="placesContext"
|
<tree id="placeContent" class="placesTree" context="placesContext"
|
||||||
flex="1" query="" type="places"
|
flex="1" query="" type="places"
|
||||||
ondblclick="PlacesController.mouseLoadURI(event);"
|
ondblclick="PlacesController.mouseLoadURI(event);"
|
||||||
|
|
|
@ -108,10 +108,6 @@
|
||||||
"Last Visit Date">
|
"Last Visit Date">
|
||||||
<!ENTITY col.visitcount.label
|
<!ENTITY col.visitcount.label
|
||||||
"Visit Count">
|
"Visit Count">
|
||||||
<!ENTITY advancedSearch.label
|
|
||||||
"More Options...">
|
|
||||||
<!ENTITY advancedSearch.accesskey
|
|
||||||
"O">
|
|
||||||
<!ENTITY search.label
|
<!ENTITY search.label
|
||||||
"Search:">
|
"Search:">
|
||||||
<!ENTITY search.accesskey
|
<!ENTITY search.accesskey
|
||||||
|
@ -130,3 +126,73 @@
|
||||||
"S">
|
"S">
|
||||||
<!ENTITY moreCriteria.label
|
<!ENTITY moreCriteria.label
|
||||||
"+">
|
"+">
|
||||||
|
<!ENTITY advancedSearch.onlybookmarked.label
|
||||||
|
"Search Bookmarks only">
|
||||||
|
<!ENTITY advancedSearch.match.label
|
||||||
|
"Match ">
|
||||||
|
<!ENTITY advancedSearch.all.label
|
||||||
|
"all">
|
||||||
|
<!ENTITY advancedSearch.any.label
|
||||||
|
"any">
|
||||||
|
<!ENTITY advancedSearch.rules.label
|
||||||
|
" of the following rules:">
|
||||||
|
<!ENTITY advancedSearch.subj_keyword.label
|
||||||
|
"Keywords">
|
||||||
|
<!ENTITY advancedSearch.subj_visited.label
|
||||||
|
"Visited">
|
||||||
|
<!ENTITY advancedSearch.subj_host.label
|
||||||
|
"Host">
|
||||||
|
<!ENTITY advancedSearch.subj_uri.label
|
||||||
|
"URI">
|
||||||
|
<!ENTITY advancedSearch.host_is.label
|
||||||
|
"is">
|
||||||
|
<!ENTITY advancedSearch.host_endswith.label
|
||||||
|
"ends with">
|
||||||
|
<!ENTITY advancedSearch.include.label
|
||||||
|
"include">
|
||||||
|
<!ENTITY advancedSearch.uri_is.label
|
||||||
|
"is">
|
||||||
|
<!ENTITY advancedSearch.uri_startswith.label
|
||||||
|
"starts with">
|
||||||
|
<!ENTITY advancedSearch.time_is.label
|
||||||
|
"on">
|
||||||
|
<!ENTITY advancedSearch.time_before.label
|
||||||
|
"before">
|
||||||
|
<!ENTITY advancedSearch.time_after.label
|
||||||
|
"after">
|
||||||
|
<!ENTITY advancedSearch.time_inlast.label
|
||||||
|
"in the last">
|
||||||
|
<!ENTITY advancedSearch.last_days.label
|
||||||
|
"days">
|
||||||
|
<!ENTITY advancedSearch.last_weeks.label
|
||||||
|
"weeks">
|
||||||
|
<!ENTITY advancedSearch.last_months.label
|
||||||
|
"months">
|
||||||
|
<!ENTITY advancedSearch.plus.label
|
||||||
|
"+">
|
||||||
|
<!ENTITY advancedSearch.minus.label
|
||||||
|
"-">
|
||||||
|
<!ENTITY advancedSearch.groupby.label
|
||||||
|
"Group by: ">
|
||||||
|
<!ENTITY advancedSearch.groupby_host.label
|
||||||
|
"host">
|
||||||
|
<!ENTITY advancedSearch.groupby_domain.label
|
||||||
|
"domain">
|
||||||
|
<!ENTITY advancedSearch.groupby_folder.label
|
||||||
|
"folder">
|
||||||
|
<!ENTITY advancedSearch.sortby.label
|
||||||
|
"Sort by: ">
|
||||||
|
<!ENTITY advancedSearch.sortby_title.label
|
||||||
|
"title">
|
||||||
|
<!ENTITY advancedSearch.sortby_date.label
|
||||||
|
"date">
|
||||||
|
<!ENTITY advancedSearch.sortby_visit.label
|
||||||
|
"visit count">
|
||||||
|
<!ENTITY advancedSearch.sortby_url.label
|
||||||
|
"url">
|
||||||
|
<!ENTITY advancedSearch.sortby_asc.label
|
||||||
|
"ascending">
|
||||||
|
<!ENTITY advancedSearch.sortby_desc.label
|
||||||
|
"descending">
|
||||||
|
<!ENTITY advancedSearch.max.label
|
||||||
|
"Maximum results: ">
|
||||||
|
|
|
@ -29,5 +29,9 @@ findPageLabel=Find in This Page...
|
||||||
|
|
||||||
headerTextShowing=Showing
|
headerTextShowing=Showing
|
||||||
headerTextResultsFor=Search Results for
|
headerTextResultsFor=Search Results for
|
||||||
|
headerTextAdvancedSearch=Advanced Search
|
||||||
|
|
||||||
searchDefault=Search
|
searchDefault=Search
|
||||||
|
|
||||||
|
lessCriteria.label=-
|
||||||
|
moreCriteria.label=+
|
||||||
|
|
|
@ -182,7 +182,7 @@ treechildren::-moz-tree-cell-text(title, separator, selected, focus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calendar */
|
/* Calendar */
|
||||||
#historyCalendar {
|
.history-calendar {
|
||||||
margin: 0px 0px 7px 6px;
|
margin: 0px 0px 7px 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,3 +240,7 @@ treechildren::-moz-tree-cell-text(title, separator, selected, focus) {
|
||||||
.calendar-day[month="other"] {
|
.calendar-day[month="other"] {
|
||||||
color:#888;
|
color:#888;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-margin-button {
|
||||||
|
min-width:0em;
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче