2000-03-21 03:16:39 +00:00
|
|
|
var gSubscribeTree = null;
|
2000-03-17 23:08:51 +00:00
|
|
|
var okCallback = null;
|
2000-03-21 03:16:39 +00:00
|
|
|
var gChangeTable = {};
|
|
|
|
var gServerURI = null;
|
2000-06-01 02:41:03 +00:00
|
|
|
var gSubscribableServer = null;
|
2000-04-01 01:56:16 +00:00
|
|
|
var RDF = null;
|
2000-04-20 03:41:30 +00:00
|
|
|
var gSubscribeDS = null;
|
2000-05-05 07:25:16 +00:00
|
|
|
var gStatusBar = null;
|
2000-05-05 07:40:33 +00:00
|
|
|
var gNameField = null;
|
2000-05-12 06:43:11 +00:00
|
|
|
var gFolderDelimiter = ".";
|
2000-08-14 21:43:19 +00:00
|
|
|
var gStatusFeedback = new nsMsgStatusFeedback;
|
2000-03-17 18:28:31 +00:00
|
|
|
|
2000-05-15 21:44:34 +00:00
|
|
|
function SetUpRDF()
|
|
|
|
{
|
|
|
|
if (!RDF) {
|
|
|
|
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
|
|
|
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gSubscribeDS) {
|
|
|
|
gSubscribeDS = RDF.GetDataSource("rdf:subscribe");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-02 19:58:09 +00:00
|
|
|
function Stop()
|
|
|
|
{
|
2000-08-14 21:43:19 +00:00
|
|
|
dump("xxx todo implement stop.\n");
|
2000-04-02 19:58:09 +00:00
|
|
|
}
|
|
|
|
|
2000-04-25 01:30:30 +00:00
|
|
|
var Bundle = srGetStrBundle("chrome://messenger/locale/subscribe.properties");
|
|
|
|
|
|
|
|
function SetServerTypeSpecificTextValues()
|
|
|
|
{
|
2000-05-20 01:25:27 +00:00
|
|
|
if (!gServerURI) return;
|
|
|
|
|
2000-04-25 01:30:30 +00:00
|
|
|
var serverType = GetMsgFolderFromUri(gServerURI).server.type;
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("serverType="+serverType+"\n");
|
2000-04-25 01:30:30 +00:00
|
|
|
|
|
|
|
/* set the server specific ui elements */
|
|
|
|
var element = document.getElementById("foldertextlabel");
|
|
|
|
var stringName = "foldertextfor-" + serverType;
|
|
|
|
var stringval = Bundle.GetStringFromName(stringName);
|
|
|
|
element.setAttribute('value',stringval);
|
|
|
|
|
|
|
|
stringName = "foldersheaderfor-" + serverType;
|
|
|
|
stringval = Bundle.GetStringFromName(stringName);
|
|
|
|
element = document.getElementById("foldersheaderlabel");
|
|
|
|
element.setAttribute('value',stringval);
|
2000-05-13 00:47:47 +00:00
|
|
|
|
2000-06-01 02:41:03 +00:00
|
|
|
// xxx todo, fix this hack
|
2000-05-13 00:47:47 +00:00
|
|
|
// qi the server to get a nsISubscribable server
|
|
|
|
// and ask it for the delimiter
|
2000-05-13 01:09:26 +00:00
|
|
|
if (serverType == "nntp") {
|
2000-05-13 00:47:47 +00:00
|
|
|
gFolderDelimiter = ".";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gFolderDelimiter = "/";
|
|
|
|
}
|
2000-04-25 01:30:30 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
function onServerClick(event)
|
|
|
|
{
|
|
|
|
var item = event.target;
|
|
|
|
gServerURI = item.id;
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("gServerURI="+gServerURI+"\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-04-25 01:30:30 +00:00
|
|
|
SetServerTypeSpecificTextValues();
|
2000-05-17 05:27:04 +00:00
|
|
|
SetUpTree(false);
|
2000-04-20 03:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function SetUpServerMenu()
|
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("SetUpServerMenu()\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
var serverMenu = document.getElementById("serverMenu");
|
|
|
|
var menuitems = serverMenu.getElementsByAttribute("id", gServerURI);
|
2000-04-25 01:30:30 +00:00
|
|
|
|
2000-05-15 21:44:34 +00:00
|
|
|
try {
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("gServerURI="+gServerURI+"\n");
|
|
|
|
//dump("menuitems="+menuitems+"\n");
|
|
|
|
//dump("menuitems[0]="+menuitems[0]+"\n");
|
|
|
|
//dump("serverMenu="+serverMenu+"\n");
|
2000-05-15 21:44:34 +00:00
|
|
|
serverMenu.selectedItem = menuitems[0];
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to set the selected server: " + ex + "\n");
|
|
|
|
}
|
2000-04-25 01:30:30 +00:00
|
|
|
|
|
|
|
SetServerTypeSpecificTextValues();
|
2000-04-20 03:41:30 +00:00
|
|
|
}
|
|
|
|
|
2000-04-23 05:18:23 +00:00
|
|
|
var MySubscribeListener = {
|
|
|
|
OnStopPopulating: function() {
|
2000-06-01 02:41:03 +00:00
|
|
|
// only re-root the tree, if it is null.
|
|
|
|
// otherwise, we are in here because we are populating
|
|
|
|
// a part of the tree
|
|
|
|
|
|
|
|
var refValue = gSubscribeTree.getAttribute('ref');
|
|
|
|
//dump("ref = " + refValue + refValue.length + "\n");
|
|
|
|
if (refValue == "null") {
|
|
|
|
dump("root subscribe tree at: "+ gServerURI +"\n");
|
|
|
|
gSubscribeTree.setAttribute('ref',gServerURI);
|
|
|
|
}
|
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gStatusFeedback.ShowProgress(100);
|
|
|
|
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("doneString"));
|
|
|
|
gStatusBar.setAttribute("mode","normal");
|
2000-04-23 05:18:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-05-17 05:27:04 +00:00
|
|
|
function SetUpTree(forceToServer)
|
2000-03-28 04:03:25 +00:00
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("SetUpTree()\n");
|
2000-05-15 21:44:34 +00:00
|
|
|
SetUpRDF();
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gStatusBar = document.getElementById('statusbar-icon');
|
2000-04-30 00:27:23 +00:00
|
|
|
gSubscribeTree.setAttribute('ref',null);
|
|
|
|
|
2000-05-20 01:25:27 +00:00
|
|
|
if (!gServerURI) return;
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
var folder = GetMsgFolderFromUri(gServerURI);
|
|
|
|
var server = folder.server;
|
|
|
|
|
2000-04-23 01:19:51 +00:00
|
|
|
try {
|
2000-06-01 02:41:03 +00:00
|
|
|
gSubscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
2000-03-28 04:03:25 +00:00
|
|
|
|
2000-06-01 02:41:03 +00:00
|
|
|
gSubscribableServer.subscribeListener = MySubscribeListener;
|
2000-04-23 05:18:23 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gStatusFeedback.ShowProgress(0);
|
|
|
|
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("pleaseWaitString"));
|
|
|
|
gStatusBar.setAttribute("mode","undetermined");
|
2000-05-09 02:48:25 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gSubscribableServer.populateSubscribeDatasource(msgWindow, forceToServer);
|
2000-04-23 01:19:51 +00:00
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to populate subscribe ds: " + ex + "\n");
|
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
}
|
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
|
2000-03-17 18:28:31 +00:00
|
|
|
function SubscribeOnLoad()
|
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("SubscribeOnLoad()\n");
|
2000-03-28 04:03:25 +00:00
|
|
|
|
2000-06-01 02:41:03 +00:00
|
|
|
gSubscribeTree = document.getElementById('subscribetree');
|
2000-05-05 07:40:33 +00:00
|
|
|
gNameField = document.getElementById('namefield');
|
2000-03-17 18:28:31 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
msgWindow = Components.classes[msgWindowProgID].createInstance(Components.interfaces.nsIMsgWindow);
|
|
|
|
msgWindow.statusFeedback = gStatusFeedback;
|
|
|
|
msgWindow.SetDOMWindow(window);
|
|
|
|
|
2000-03-17 23:08:51 +00:00
|
|
|
doSetOKCancel(subscribeOK,subscribeCancel);
|
|
|
|
|
|
|
|
// look in arguments[0] for parameters
|
|
|
|
if (window.arguments && window.arguments[0]) {
|
|
|
|
if ( window.arguments[0].title ) {
|
|
|
|
top.window.title = window.arguments[0].title;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( window.arguments[0].okCallback ) {
|
|
|
|
top.okCallback = window.arguments[0].okCallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-20 01:25:27 +00:00
|
|
|
gServerURI = null;
|
2000-03-17 23:08:51 +00:00
|
|
|
if (window.arguments[0].preselectedURI) {
|
2000-04-20 03:41:30 +00:00
|
|
|
var uri = window.arguments[0].preselectedURI;
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("subscribe: got a uri," + uri + "\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
folder = GetMsgFolderFromUri(uri);
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("folder="+folder+"\n");
|
|
|
|
//dump("folder.server="+folder.server+"\n");
|
2000-05-20 01:25:27 +00:00
|
|
|
try {
|
2000-06-01 02:41:03 +00:00
|
|
|
gSubscribableServer = folder.server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
2000-05-20 01:25:27 +00:00
|
|
|
gServerURI = folder.server.serverURI;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("not a subscribable server\n");
|
2000-06-01 02:41:03 +00:00
|
|
|
gSubscribableServer = null;
|
2000-05-20 01:25:27 +00:00
|
|
|
gServerURI = null;
|
|
|
|
}
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
2000-05-20 01:25:27 +00:00
|
|
|
|
|
|
|
if (!gServerURI) {
|
|
|
|
//dump("subscribe: no uri\n");
|
|
|
|
dump("xxx todo: use the default news server. right now, I'm just using the first server\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
var serverMenu = document.getElementById("serverMenu");
|
|
|
|
var menuitems = serverMenu.getElementsByTagName("menuitem");
|
2000-05-20 01:25:27 +00:00
|
|
|
|
|
|
|
if (menuitems.length > 1) {
|
|
|
|
gServerURI = menuitems[1].id;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dump("xxx todo none of your servers are subscribable\n");
|
|
|
|
dump("xxx todo fix this by disabling subscribe if no subscribable server or, add a CREATE SERVER button, like in 4.x\n");
|
|
|
|
return;
|
|
|
|
}
|
2000-04-13 21:56:28 +00:00
|
|
|
}
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
SetUpServerMenu();
|
2000-05-17 05:27:04 +00:00
|
|
|
SetUpTree(false);
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-05-12 06:43:11 +00:00
|
|
|
|
|
|
|
gNameField.focus();
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeOK()
|
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("in subscribeOK()\n")
|
2000-03-17 23:08:51 +00:00
|
|
|
if (top.okCallback) {
|
2000-03-21 03:16:39 +00:00
|
|
|
top.okCallback(top.gServerURI,top.gChangeTable);
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
2000-06-01 02:41:03 +00:00
|
|
|
if (gSubscribableServer) {
|
|
|
|
gSubscribableServer.subscribeCleanup();
|
|
|
|
}
|
2000-03-17 23:08:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeCancel()
|
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("in subscribeCancel()\n");
|
2000-04-02 19:58:09 +00:00
|
|
|
Stop();
|
2000-06-01 02:41:03 +00:00
|
|
|
if (gSubscribableServer) {
|
|
|
|
gSubscribableServer.subscribeCleanup();
|
|
|
|
}
|
2000-03-17 23:08:51 +00:00
|
|
|
return true;
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 07:11:27 +00:00
|
|
|
function SetState(uri,name,state,stateStr)
|
2000-03-17 18:28:31 +00:00
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("SetState(" + uri +"," + name + "," + state + "," + stateStr + ")\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
if (!uri || !stateStr) return;
|
2000-04-01 01:56:16 +00:00
|
|
|
|
|
|
|
try {
|
2000-06-01 02:41:03 +00:00
|
|
|
// xxx should we move this code into nsSubscribableServer.cpp?
|
2000-04-01 01:56:16 +00:00
|
|
|
var src = RDF.GetResource(uri, true);
|
|
|
|
var prop = RDF.GetResource("http://home.netscape.com/NC-rdf#Subscribed", true);
|
2000-04-20 03:41:30 +00:00
|
|
|
var oldLiteral = gSubscribeDS.GetTarget(src, prop, true);
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("oldLiteral="+oldLiteral+"\n");
|
2000-04-14 05:34:49 +00:00
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
oldValue = oldLiteral.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("oldLiteral.Value="+oldValue+"\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
if (oldValue != stateStr) {
|
|
|
|
var newLiteral = RDF.GetLiteral(stateStr);
|
|
|
|
gSubscribeDS.Change(src, prop, oldLiteral, newLiteral);
|
|
|
|
StateChanged(name,state);
|
2000-04-14 05:34:49 +00:00
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
catch (ex) {
|
|
|
|
dump("failed: " + ex + "\n");
|
2000-03-21 01:03:25 +00:00
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-14 05:34:49 +00:00
|
|
|
function StateChanged(name,state)
|
2000-03-21 03:16:39 +00:00
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("StateChanged(" + name + "," + state + ")\n");
|
|
|
|
//dump("start val=" +gChangeTable[name] + "\n");
|
2000-03-21 03:16:39 +00:00
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
if (gChangeTable[name] == undefined) {
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump(name+" not in table yet\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
gChangeTable[name] = state;
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-04-20 03:41:30 +00:00
|
|
|
var oldValue = gChangeTable[name];
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump(name+" already in table\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
if (oldValue != state) {
|
|
|
|
gChangeTable[name] = undefined;
|
|
|
|
}
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("end val=" +gChangeTable[name] + "\n");
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
|
|
|
|
2000-03-21 01:03:25 +00:00
|
|
|
function SetSubscribeState(state)
|
2000-03-17 18:28:31 +00:00
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("SetSubscribedState()\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
var stateStr;
|
|
|
|
if (state) {
|
|
|
|
stateStr = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stateStr = 'false';
|
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
|
|
|
|
try {
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("subscribe button clicked\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-03-21 03:16:39 +00:00
|
|
|
var groupList = gSubscribeTree.selectedItems;
|
2000-03-21 01:03:25 +00:00
|
|
|
for (i=0;i<groupList.length;i++) {
|
|
|
|
group = groupList[i];
|
|
|
|
uri = group.getAttribute('id');
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump(uri + "\n");
|
2000-04-14 05:34:49 +00:00
|
|
|
name = group.getAttribute('name');
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump(name + "\n");
|
2000-04-20 07:11:27 +00:00
|
|
|
SetState(uri,name,state,stateStr);
|
2000-03-21 01:03:25 +00:00
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("SetSubscribedState failed: " + ex + "\n");
|
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 06:59:43 +00:00
|
|
|
function ReverseStateFromNode(node)
|
|
|
|
{
|
|
|
|
var stateStr;
|
|
|
|
var state;
|
|
|
|
|
|
|
|
if (node.getAttribute('Subscribed') == "true") {
|
|
|
|
stateStr = "false";
|
|
|
|
state = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stateStr = "true";
|
|
|
|
state = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var uri = node.getAttribute('id');
|
2000-04-20 07:11:27 +00:00
|
|
|
var name = node.getAttribute('name');
|
|
|
|
SetState(uri, name, state, stateStr);
|
2000-04-20 06:59:43 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
function ReverseState(uri)
|
|
|
|
{
|
2000-05-16 21:40:32 +00:00
|
|
|
//dump("ReverseState("+uri+")\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
}
|
|
|
|
|
2000-03-17 18:28:31 +00:00
|
|
|
function SubscribeOnClick(event)
|
|
|
|
{
|
2000-05-16 11:35:12 +00:00
|
|
|
if (event.detail == 2) {
|
2000-04-20 06:59:43 +00:00
|
|
|
ReverseStateFromNode(event.target.parentNode.parentNode);
|
2000-04-20 03:41:30 +00:00
|
|
|
}
|
2000-05-05 07:40:33 +00:00
|
|
|
else {
|
|
|
|
var targetclass = event.target.getAttribute('class');
|
2000-06-01 02:41:03 +00:00
|
|
|
if (targetclass == 'tree-cell-twisty') {
|
|
|
|
var treeitem = event.target.parentNode.parentNode.parentNode;
|
|
|
|
var open = treeitem.getAttribute('open');
|
|
|
|
if(open == "true") {
|
2000-06-01 03:59:14 +00:00
|
|
|
var uri = treeitem.getAttribute("id");
|
|
|
|
|
2000-06-01 22:49:46 +00:00
|
|
|
dump("do twisty for " + uri + "\n");
|
2000-06-01 02:41:03 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gStatusFeedback.ShowProgress(0);
|
|
|
|
gStatusFeedback.ShowStatusString(Bundle.GetStringFromName("pleaseWaitString"));
|
|
|
|
gStatusBar.setAttribute("mode","undetermined");
|
2000-06-01 02:41:03 +00:00
|
|
|
|
2000-08-14 21:43:19 +00:00
|
|
|
gSubscribableServer.populateSubscribeDatasourceWithUri(msgWindow, true /* force to server */, uri);
|
2000-06-01 02:41:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2000-05-05 07:40:33 +00:00
|
|
|
var name = event.target.parentNode.parentNode.getAttribute('name');
|
2000-06-09 22:14:23 +00:00
|
|
|
if (name && (name.length > 0)) {
|
|
|
|
gNameField.setAttribute('value',name);
|
|
|
|
}
|
2000-05-05 07:40:33 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
|
|
|
|
function RefreshList()
|
|
|
|
{
|
2000-05-17 05:27:04 +00:00
|
|
|
// force it to talk to the server
|
|
|
|
SetUpTree(true);
|
2000-03-28 04:03:25 +00:00
|
|
|
}
|
2000-04-02 19:58:09 +00:00
|
|
|
|
2000-05-12 06:43:11 +00:00
|
|
|
function trackGroupInTree()
|
|
|
|
{
|
|
|
|
var portion = gNameField.value;
|
|
|
|
selectNodeByName( portion );
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectNodeByName( aMatchString )
|
|
|
|
{
|
|
|
|
var lastDot = aMatchString.lastIndexOf(gFolderDelimiter);
|
|
|
|
var nodeValue = lastDot != -1 ? aMatchString.substring(0, lastDot) : aMatchString;
|
|
|
|
|
|
|
|
var chain = aMatchString.split(gFolderDelimiter);
|
|
|
|
if( chain.length == 1 ) {
|
|
|
|
var node = getTreechildren(gSubscribeTree);
|
|
|
|
if( !node )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var node = gSubscribeTree.getElementsByAttribute("name",nodeValue)[0];
|
|
|
|
if( node.getAttribute("container") == "true" &&
|
|
|
|
node.getAttribute("open") != "true" )
|
|
|
|
node.setAttribute("open","true");
|
|
|
|
node = getTreechildren(node);
|
2000-06-07 01:05:50 +00:00
|
|
|
dump("*** node = " + node.localName + "\n");
|
2000-05-12 06:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( var i = 0; i < node.childNodes.length; i++ )
|
|
|
|
{
|
|
|
|
var currItem = node.childNodes[i];
|
|
|
|
dump("*** chain = " + chain[chain.length-1] + "\n");
|
|
|
|
if( !currItem.getAttribute("name").indexOf( aMatchString ) ) {
|
|
|
|
gSubscribeTree.selectItem( currItem );
|
|
|
|
gSubscribeTree.ensureElementIsVisible( currItem );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTreechildren( aTreeNode )
|
|
|
|
{
|
|
|
|
if( aTreeNode.childNodes )
|
|
|
|
{
|
|
|
|
for( var i = 0; i < aTreeNode.childNodes.length; i++ )
|
|
|
|
{
|
2000-06-07 01:05:50 +00:00
|
|
|
if( aTreeNode.childNodes[i].localName.toLowerCase() == "treechildren" )
|
2000-05-12 06:43:11 +00:00
|
|
|
return aTreeNode.childNodes[i];
|
|
|
|
}
|
|
|
|
return aTreeNode;
|
|
|
|
}
|
|
|
|
return null;
|
2000-05-13 00:47:47 +00:00
|
|
|
}
|