Two versions of a startup page that will attempt to first load the Welcome

Guide locally (file://) and upon failure will load it from svn.berlios.de.
Once either of these files are inserted into browser.jar's content/browser,
it can be accessed via chrome://browser/content/<filename>. This will allow
BeZillaBrowser to be installed in any location and still be able to access 
that file. Thanks to Ryan Leavengood and mathewblack for the files!
This commit is contained in:
Matt Madia
2009-07-08 01:39:23 +00:00
parent 77d00162dc
commit f556c0fd9a
2 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<html>
<head>
<title>Opening the welcome page...</title>
<script type="text/javascript">
function fileExists(filename) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert("Permission to read file was denied.");
}
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(
Components.interfaces.nsILocalFile);
file.initWithPath(filename);
return file.exists();
}
window.onload = function() {
var url = "http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk/docs/welcome/welcome.html";
var localWelcome = "/boot/system/documentation/welcome/welcome.html";
if (fileExists(localWelcome))
url = "file://" + localWelcome;
window.open(url, "_self");
}
</script>
</head>
<body>
Opening the welcome page...
</body>
</html>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="all" />
<title>Welcome to Haiku!</title>
<link rel="stylesheet" type="text/css" href="../Haiku-doc.css" />
<script type="text/javascript">
var xmlhttp;
var offLineWelcomePage = 'file:///boot/system/documentation/welcome/welcome.html';
var onLineWelcomePage = 'http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk/docs/welcome/welcome.html';
function redirect()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=state_Change;
try
{
xmlhttp.open("GET",offLineWelcomePage);
xmlhttp.send(null);
}
catch(err)
{
window.location = onLineWelcomePage;
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200 ||xmlhttp.status==0)
{// 200 = "OK"; loading from file:// so no http status set! hence status == 0.
if(xmlhttp.responseText.length != 0)
window.location = offLineWelcomePage;
else
window.location = onLineWelcomePage;
}
else
{
alert("Problem retrieving data:" + xmlhttp.statusText);
}
}
}
</script>
</head>
<body onload="redirect()">
</body>
</html>