Bug 206464 Advanced search sidebar does not remember your chosen engines

Bug 212703 Advanced search sidebar does not display custom categories
r=varga
sr=alecf
This commit is contained in:
neil%parkwaycc.co.uk 2003-10-12 19:34:09 +00:00
Родитель 5afec654be
Коммит d41ae35ba4
3 изменённых файлов: 15 добавлений и 30 удалений

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

@ -99,13 +99,13 @@ function doLoad()
if (categoryList)
{
categoryList.database.AddDataSource(catDS);
var ref = categoryList.getAttribute("ref");
if (ref) categoryList.setAttribute("ref", ref);
categoryList.builder.rebuild();
}
var engineList = document.getElementById("engineList");
if (engineList)
{
engineList.database.AddDataSource(catDS);
engineList.builder.rebuild();
}
}
}

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

@ -411,14 +411,11 @@ function SearchPanelStartup()
if (catDS) {
catDS = catDS.QueryInterface(nsIRDFDataSource);
categoryList.database.AddDataSource(catDS);
var ref = categoryList.getAttribute("ref");
if (ref)
categoryList.setAttribute("ref", ref);
categoryList.builder.rebuild();
var engineList = document.getElementById("searchengines");
engineList.database.AddDataSource(catDS);
ref = engineList.getAttribute("ref");
if (ref)
engineList.setAttribute("ref", ref);
engineList.builder.rebuild();
engineList.addEventListener("CheckboxStateChange", saveEngine, false);
}
// try and determine last category name used
@ -507,35 +504,24 @@ function chooseCategory(aNode)
loadEngines(category);
}
function saveEngines()
function saveEngine(event)
{
var categoryList = document.getElementById("categoryList");
var category = categoryList.selectedItem.getAttribute("id");
if (category)
category = "NC:SearchCategory?category=" + category;
else
category = "NC:SearchEngineRoot";
var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);
var localStore = rdf.GetDataSource("rdf:local-store");
if (!localStore)
return;
var engineItems = document.getElementById("searchengines").getElementsByTagName("listitem");
var checkedProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#checked", true);
var categorySRC = rdf.GetResource(category, true);
var engines = event.currentTarget;
var categorySRC = rdf.GetResource(engines.ref, true);
for (var x = 0; x < engineItems.length; ++x) {
var itemNode = engineItems[x];
var engineURI = itemNode.getAttribute("id");
var engineSRC = rdf.GetResource(engineURI, true);
var itemNode = event.target;
var engineSRC = rdf.GetResource(itemNode.id, true);
if (itemNode.checked)
localStore.Assert(categorySRC, checkedProperty, engineSRC, true);
else
localStore.Unassert(categorySRC, checkedProperty, engineSRC, true);
}
if (itemNode.checked)
localStore.Assert(categorySRC, checkedProperty, engineSRC, true);
else
localStore.Unassert(categorySRC, checkedProperty, engineSRC, true);
// save changes; flush out the localstore
try {

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

@ -160,8 +160,7 @@
<vbox class="searchpanel-outerbox" flex="1">
<listbox id="searchengines" flex="1" class="plain"
datasources="rdf:internetsearch"
onselect="saveEngines();">
datasources="rdf:internetsearch">
<listhead>
<listheader id="EngineColumn" label="&engine.column.label;"
sortable="true" resource="http://home.netscape.com/NC-rdf#Name"