From fc6441e09d9faee3fefdc2d84c2b5f30be36c964 Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Thu, 22 Jul 1999 22:11:21 +0000 Subject: [PATCH] For a given node, try asking the grap for the URL before falling back to using the node's ID. They might be different. REALLY! git-svn-id: svn://10.0.0.236/trunk@40714 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/suite/browser/navigator.js | 26 ++++++++++++++++++- mozilla/suite/common/bookmarks/bookmarks.js | 24 +++++++++++++++++ .../browser/resources/content/navigator.js | 26 ++++++++++++++++++- .../bookmarks/resources/bookmarks.js | 24 +++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) diff --git a/mozilla/suite/browser/navigator.js b/mozilla/suite/browser/navigator.js index 3ba72059a1a..46b9baffa18 100644 --- a/mozilla/suite/browser/navigator.js +++ b/mozilla/suite/browser/navigator.js @@ -415,7 +415,31 @@ if (node.getAttribute('container') == "true") { return false; } - url = node.getAttribute('id'); + + var url = node.getAttribute('id'); + try + { + // first try asking RDF's graph for the URL + var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(); + if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService); + if (rdf) + { + var Bookmarks = rdf.GetDataSource("rdf:bookmarks"); + if (Bookmarks) + { + var src = rdf.GetResource(url, true); + var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true); + var target = Bookmarks.GetTarget(src, prop, true); + if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral); + if (target) target = target.Value; + if (target) url = target; + + } + } + } + catch(ex) + { + } // Ignore "NC:" urls. if (url.substring(0, 3) == "NC:") { diff --git a/mozilla/suite/common/bookmarks/bookmarks.js b/mozilla/suite/common/bookmarks/bookmarks.js index 9312f4d428e..c62f6c07aa6 100644 --- a/mozilla/suite/common/bookmarks/bookmarks.js +++ b/mozilla/suite/common/bookmarks/bookmarks.js @@ -56,6 +56,30 @@ function OpenURL(event, node) var url = node.getAttribute('id'); + try + { + // first try asking RDF's graph for the URL + var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(); + if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService); + if (rdf) + { + var Bookmarks = rdf.GetDataSource("rdf:bookmarks"); + if (Bookmarks) + { + var src = rdf.GetResource(url, true); + var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true); + var target = Bookmarks.GetTarget(src, prop, true); + if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral); + if (target) target = target.Value; + if (target) url = target; + + } + } + } + catch(ex) + { + } + // Ignore "NC:" urls. if (url.substring(0, 3) == "NC:") { diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index 3ba72059a1a..46b9baffa18 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -415,7 +415,31 @@ if (node.getAttribute('container') == "true") { return false; } - url = node.getAttribute('id'); + + var url = node.getAttribute('id'); + try + { + // first try asking RDF's graph for the URL + var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(); + if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService); + if (rdf) + { + var Bookmarks = rdf.GetDataSource("rdf:bookmarks"); + if (Bookmarks) + { + var src = rdf.GetResource(url, true); + var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true); + var target = Bookmarks.GetTarget(src, prop, true); + if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral); + if (target) target = target.Value; + if (target) url = target; + + } + } + } + catch(ex) + { + } // Ignore "NC:" urls. if (url.substring(0, 3) == "NC:") { diff --git a/mozilla/xpfe/components/bookmarks/resources/bookmarks.js b/mozilla/xpfe/components/bookmarks/resources/bookmarks.js index 9312f4d428e..c62f6c07aa6 100644 --- a/mozilla/xpfe/components/bookmarks/resources/bookmarks.js +++ b/mozilla/xpfe/components/bookmarks/resources/bookmarks.js @@ -56,6 +56,30 @@ function OpenURL(event, node) var url = node.getAttribute('id'); + try + { + // first try asking RDF's graph for the URL + var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService(); + if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService); + if (rdf) + { + var Bookmarks = rdf.GetDataSource("rdf:bookmarks"); + if (Bookmarks) + { + var src = rdf.GetResource(url, true); + var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true); + var target = Bookmarks.GetTarget(src, prop, true); + if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral); + if (target) target = target.Value; + if (target) url = target; + + } + } + } + catch(ex) + { + } + // Ignore "NC:" urls. if (url.substring(0, 3) == "NC:") {