gecko-dev/docshell/resources/content/netError.xhtml

213 строки
7.6 KiB
HTML
Исходник Обычный вид История

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html [
<!ENTITY % htmlDTD
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
%htmlDTD;
<!ENTITY % netErrorDTD
SYSTEM "chrome://global/locale/netError.dtd">
%netErrorDTD;
<!ENTITY % globalDTD
SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
]>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Adam Lock <adamlock@netscape.com>
- William R. Price <wrprice@alumni.rice.edu>
- Henrik Skupin <mozilla@hskupin.info>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&loadError.label;</title>
<link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
<!-- Include the localized error titles/descriptions -->
<script type="application/x-javascript">
var errorTitle = {
generic: "&generic.title;",
dnsNotFound: "&dnsNotFound.title;",
fileNotFound: "&fileNotFound.title;",
malformedURI: "&malformedURI.title;",
protocolNotFound: "&protocolNotFound.title;",
connectionFailure: "&connectionFailure.title;",
netTimeout: "&netTimeout.title;",
redirectLoop: "&redirectLoop.title;",
unknownSocketType: "&unknownSocketType.title;",
netReset: "&netReset.title;",
netOffline: "&netOffline.title;",
netInterrupt: "&netInterrupt.title;",
deniedPortAccess: "&deniedPortAccess.title;",
proxyResolveFailure: "&proxyResolveFailure.title;",
proxyConnectFailure: "&proxyConnectFailure.title;"
};
var errorDesc = {
generic: "&generic.longDesc;",
dnsNotFound: "&dnsNotFound.longDesc;",
fileNotFound: "&fileNotFound.longDesc;",
malformedURI: "&malformedURI.longDesc;",
protocolNotFound: "&protocolNotFound.longDesc;",
connectionFailure: "&connectionFailure.longDesc;",
netTimeout: "&netTimeout.longDesc;",
redirectLoop: "&redirectLoop.longDesc;",
unknownSocketType: "&unknownSocketType.longDesc;",
netReset: "&netReset.longDesc;",
netOffline: "&netOffline.longDesc;",
netInterrupt: "&netInterrupt.longDesc;",
deniedPortAccess: "&deniedPortAccess.longDesc;",
proxyResolveFailure: "&proxyResolveFailure.longDesc;",
proxyConnectFailure: "&proxyConnectFailure.longDesc;"
};
</script>
<script type="application/x-javascript"><![CDATA[
// Error url MUST be formatted like this:
// moz-neterror:page?e=error&u=url&d=desc
// Note that this file uses document.documentURI to get
// the URL (with the format from above). This is because
// document.location.href gets the current URI off the docshell,
// which is the URL displayed in the location bar, i.e.
// the URI that the user attempted to load.
function getErrorCode()
{
var url = document.documentURI;
var error = url.search(/e\=/);
var duffUrl = url.search(/\&u\=/);
return decodeURIComponent(url.slice(error + 2, duffUrl));
}
function getDescription()
{
var url = document.documentURI;
var desc = url.search(/d\=/);
// desc == -1 if not found; if so, return an empty string
// instead of what would turn out to be portions of the URI
if (desc == -1) return "";
return decodeURIComponent(url.slice(desc + 2));
}
function retryThis()
{
// Session history has the URL of the page that failed
// to load, not the one of the error page. So, just call
// reload(), which will also repost POST data correctly.
location.reload();
}
function parseFakeTags(instr)
{
return instr.replace(/\[([^\]]+)\]/g, '<$1>');
}
function initPage()
{
var err = getErrorCode();
// Map unknown error codes to generic
if (!(err in errorDesc && err in errorTitle))
err = "generic";
var title = document.getElementById("errorTitleText");
if (title)
title.textContent = errorTitle[err];
var sd = document.getElementById("errorShortDescText");
if (sd)
sd.textContent = getDescription();
var ld = document.getElementById("errorLongDesc");
if (ld)
ld.innerHTML = parseFakeTags(errorDesc[err]);
// Focus the Try Again button. We can't just do this inline because of
// bug 232004. We can't use onload (see comment below). Since the
// <script> that calls initPage is the last DOM node in the document,
// a setTimeout of 0 should work.
setTimeout(function(){
var tryAgainButton = document.getElementById("errorTryAgain");
if (tryAgainButton)
tryAgainButton.focus();
}, 0);
}
]]></script>
</head>
<body dir="&locale.dir;">
<!-- PAGE CONTAINER (for styling purposes only) -->
<div id="errorPageContainer">
<!-- Error Title -->
<div id="errorTitle">
<h1 id="errorTitleText" />
</div>
<!-- LONG CONTENT (the section most likely to require scrolling) -->
<div id="errorLongContent">
<!-- Short Description -->
<div id="errorShortDesc">
<p id="errorShortDescText" />
</div>
<!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
<div id="errorLongDesc" />
</div>
<!-- Retry Button -->
<xul:button xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="errorTryAgain" label="&retry.label;" oncommand="retryThis();" />
</div>
<!--
- Note: It is important to run the script this way, instead of using
- an onload handler. This is because error pages are loaded as
- LOAD_BACKGROUND, which means that onload handlers will not be executed.
-->
<script type="application/x-javascript">initPage();</script>
</body>
</html>