Bug 35404: centralize all URLs into builtinURLs.rdf (a=don,r=jbetak)

This commit is contained in:
tao%netscape.com 2000-05-04 23:49:45 +00:00
parent c4da25b7d6
commit c1007c6e93
6 changed files with 121 additions and 15 deletions

View File

@ -15,6 +15,7 @@ dialogBindings.xml
commonDialog.xul
commonDialog.js
strres.js
builtinURLs.js
about.html
logo.gif
credits.html

View File

@ -52,6 +52,7 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/charsetOverlay.xul \
$(srcdir)/charsetOverlay.js \
$(srcdir)/strres.js \
$(srcdir)/builtinURLs.js \
$(srcdir)/about.html \
$(srcdir)/logo.gif \
$(srcdir)/about.xul \

View File

@ -0,0 +1,107 @@
// the rdf service
var rdf_uri = 'component://netscape/rdf/rdf-service';
var RDF = Components.classes[rdf_uri].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
//var ds_uri = "http://h-208-12-37-237/client-urls/en-us/builtinURLS.rdf";
var ds_uri = "chrome://global/locale/builtinURLs.rdf";
var titleArc = RDF.GetResource("http://home.netscape.com/NC-rdf#title");
var contentArc = RDF.GetResource("http://home.netscape.com/NC-rdf#content");
var url_ds = null;
var rdfXMLSink = null;
var ds = null;
var state = 0x0; // init.
var loaded = false;
var SinkObserver =
{
onBeginLoad: function( aSink) {
state = (state | 1);
dump("\n-> SinkObserver:onBeginLoad: " + aSink + ", state=" + state + "\n");
},
onInterrupt: function( aSink) {
state = (state | 2);
dump("\n-> SinkObserver:onInterrupt: " + aSink + ", state=" + state + "\n");
},
onResume: function( aSink) {
state = (state & ~2);
dump("\n-> SinkObserver:onResume: " + aSink + ", state=" + state + "\n");
},
onEndLoad: function( aSink) {
state = (state | 4);
loaded = (state == 5);
dump("\n-> onEndLoad: " + aSink + ", state=" + state + ", loaded=" + loaded + "\n");
if (!loaded) {
dump("\n->" + ds_uri + " not loaded!\n");
return;
}
ds = aSink.QueryInterface(Components.interfaces.nsIRDFDataSource);
},
onError: function( aSink, aStatus, aErrMsg) {
state = (state | 8);
dump("\n-> SinkObserver:onError: " + aSink + ", status=" + aStatus +
", errMsg=" + aErrMsg + ", state=" + state + "\n");
}
};
function loadDS()
{
if (!RDF) {
dump("\n-->loadDS(): RDF is null!\n");
return;
}
url_ds = RDF.GetDataSource(ds_uri); // return nsIRDFDataSource
if (!url_ds) {
dump("\n >>Can't get " + ds_uri + "<-\n");
return;
}
rdfXMLSink = url_ds.QueryInterface( Components.interfaces.nsIRDFXMLSink );
if (rdfXMLSink) {
rdfXMLSink.addXMLSinkObserver(SinkObserver);
}
}
function xlateURL(key)
{
if (!ds || !loaded) {
dump("\n data source " + ds_uri + "is not loaded! Try again later! \n");
return;
}
// get data
var srcNode = RDF.GetResource(key);
var titleTarget = ds.GetTarget(srcNode, titleArc, true);
if (titleTarget) {
titleTarget =
titleTarget.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump("\n-> " + key + "::title=" + titleTarget.Value + "\n");
}
else {
dump("\n title target=" + titleTarget + "\n");
}
var contentTarget = ds.GetTarget(srcNode, contentArc, true);
if (contentTarget) {
contentTarget =
contentTarget.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump("\n-> " + key + "::content=" + contentTarget.Value + "\n");
return contentTarget.Value;
}
else {
dump("\n content target=" + contentTarget + "\n");
}
}
function loadXURL(key)
{
window.content.location.href = xlateURL(key);
}
loadDS();

View File

@ -180,7 +180,16 @@ function openTopWin( url )
{
dump("setting page: " + topWindowOfType.content.location.href + "\n");
topWindowOfType.focus();
topWindowOfType.content.location.href = url;
// urn:
var pos = url.indexOf("urn:");
dump("\n ** openTopWin, url=" + url + ", pos=" + pos + "\n");
if (pos == 0) {
topWindowOfType.content.location.href = xlateURL(url);
}
else
{
topWindowOfType.content.location.href = url;
}
}
else
{

View File

@ -8,6 +8,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- script language="JavaScript" src="chrome://global/content/strres.js"/ -->
<script language="javascript" src="chrome://global/content/builtinURLs.js" />
<script language="JavaScript" src="chrome://global/content/globalOverlay.js"/>
<!-- File Menu -->
@ -119,20 +120,6 @@
<!-- Help Menu -->
<menu id="menu_Help" value="&helpMenu.label;">
<menupopup id="helpPopup" oncreate="helpMenuCreate()">
<!-- Help Menu disabled
<menu value="&helpContentCmd.label;">
<menupopup>
<menuitem value="&webBrowsingCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/local/browserhelp/navtop.html');"/>
<menuitem value="&emailCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/local/mailhelp/mailtop.html');"/>
<menuitem value="&internetShopCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/served/shophelp/shoptop.html');"/>
<menuitem value="&customCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/served/custhelp/custtop.html');"/>
<menuseparator/>
<menuitem value="&softUpdatesCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/served/updatehelp/updatetop.html');"/>
<menuitem value="&connProbCmd.label;" oncommand="openTopWin('http://www.mozilla.org/projects/user-docs/local/troubleshoot/troubletop.html');"/>
<menuitem value="&secPrivCmd.label;" oncommand="openTopWin('http://home.netscape.com/security/basics/index.html');"/>
</menupopup>
</menu>
-->
<menuitem value="&releaseCommCmd.label;" id="releaseUrl" />
<menuitem value="&aboutCommCmd.label;" name="&aboutCommCmd.label;" id="releaseName" oncommand="goAboutDialog();"/>
</menupopup>

View File

@ -46,6 +46,7 @@ install::
$(MAKE_INSTALL) commonDialog.xul $(DISTBROWSER)
$(MAKE_INSTALL) commonDialog.js $(DISTBROWSER)
$(MAKE_INSTALL) strres.js $(DISTBROWSER)
$(MAKE_INSTALL) builtinURLs.js $(DISTBROWSER)
$(MAKE_INSTALL) about.html $(DISTBROWSER)
$(MAKE_INSTALL) logo.gif $(DISTBROWSER)
$(MAKE_INSTALL) about.xul $(DISTBROWSER)