/*
Copyright (c) 2008, Interactive Pulp, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Interactive Pulp, LLC nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// PulpCore 0.11
// Global functions accessed via LiveConnect
function pulpcore_getCookie(name) {
name = name + "=";
var i;
if (document.cookie.substring(0, name.length) == name) {
i = name.length;
}
else {
i = document.cookie.indexOf('; ' + name);
if (i == -1) {
return null;
}
i += name.length + 2;
}
var endIndex = document.cookie.indexOf('; ', i);
if (endIndex == -1) {
endIndex = document.cookie.length;
}
return unescape(document.cookie.substring(i, endIndex));
}
function pulpcore_setCookie(name, value, expireDate, path, domain, secure) {
var expires = new Date();
if (expireDate === null) {
// Expires in 90 days
expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000) * 90);
}
else {
expires.setTime(expireDate);
}
document.cookie =
name + "=" + escape(value) +
"; expires=" + expires.toGMTString() +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function pulpcore_deleteCookie(name, path, domain) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function pulpcore_appletLoaded() {
pulpCoreObject.hideSplash();
setTimeout(pulpCoreObject.showObject, 50);
}
// Internal PulpCore code
var pulpCoreObject = {
// The minimum JRE version
requiredJRE: "1.4",
// The minimum JRE version, formatted for IE
ieRequiredJRE: "1,4,0,0",
// The URL to the CAB of the latest JRE (for IE)
// See http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/autodl-files.html
getJavaCAB: "http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab",
// The URL of the XPI of the latest JRE (for Windows+Firefox)
// Currently using the unsigned version (-jc) since the signed version in 6u3 is broken
getJavaXPI: "http://java.sun.com/update/1.6.0/jre-6-windows-i586-jc.xpi",
//getJavaXPI: "http://java.sun.com/update/1.6.0/jre-6-windows-i586.xpi",
//getJavaXPI: "http://java.com/jre-install.xpi",
// The URL to the page to visit to install Java
getJavaURL: "http://java.sun.com/webapps/getjava/BrowserRedirect?host=java.com" +
'&returnPage=' + document.location,
// The Applet HTML (inserted after a delay)
appletHTML: "",
appletInserted: false,
// Gets the codebase from the document URL
getCodeBase: function() {
var codeBase = document.URL;
if (codeBase.length <= 7 || codeBase.substr(0, 7) != "http://") {
return "";
}
if (codeBase.charAt(codeBase.length - 1) != '/') {
var index = codeBase.lastIndexOf('/');
// Don't include the http://
if (index > 7) {
codeBase = codeBase.substring(0, index + 1);
}
else {
codeBase += '/';
}
}
return codeBase;
},
write: function() {
// JLint gives a warning about "eval" here.
// Note the HTML uses onload and onfocus attributes in a few places.
document.write(pulpCoreObject.getObjectHTML());
},
hideSplash: function() {
var splash = document.getElementById('pulpcore_splash');
splash.style.display = "none";
splash.style.visibility = "hidden";
},
showObject: function() {
if (pulpCoreObject.browserIsMozillaFamily) {
var spacer = document.getElementById('pulpcore_spacer');
spacer.style.display = "none";
spacer.style.visibility = "hidden";
}
var gameContainer = document.getElementById('pulpcore_game');
gameContainer.style.display = "block";
gameContainer.style.visibility = "visible";
if (pulpCoreObject.browserName == "Explorer") {
gameContainer.style.position = "static";
}
},
splashLoaded: function(splash) {
// Prevent this call from occuring again
// (IE will continue to call onLoad() if the splash loops.)
if (splash !== null) {
splash.onload = "";
}
pulpCoreObject.insertApplet();
},
insertApplet: function() {
if (pulpCoreObject.appletInserted) {
return;
}
var gameContainer = document.getElementById('pulpcore_game');
if (gameContainer === null) {
setTimeout(pulpCoreObject.insertApplet, 500);
}
else {
pulpCoreObject.appletInserted = true;
gameContainer.innerHTML = pulpCoreObject.appletHTML;
setTimeout(pulpcore_appletLoaded, navigator.javaEnabled() ? 15000 : 10);
}
},
getObjectHTML: function() {
pulpCoreObject.appletHTML = "";
pulpCoreObject.detectBrowser();
if (!pulpCoreObject.isAcceptableJRE()) {
return pulpCoreObject.installLatestJRE();
}
var splashHTML;
// The splash image to show during JRE boot and jar loading
var splash = window.pulpcore_splash || "splash.gif";
// Applet attributes and parameters
var code = window.pulpcore_class || "pulpcore.platform.applet.CoreApplet.class";
var width = window.pulpcore_width || 640;
var height = window.pulpcore_height || 480;
var archive = window.pulpcore_archive || "project.jar";
var bgcolor = window.pulpcore_bgcolor || "#000000";
var fgcolor = window.pulpcore_fgcolor || "#aaaaaa";
var scene = window.pulpcore_scene || "";
var assets = window.pulpcore_assets || "";
var params = window.pulpcore_params || { };
var codebase = window.pulpcore_codebase || pulpCoreObject.getCodeBase();
// Create the object tag parameters
var objectParams =
' \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n';
if (codebase.length > 0) {
objectParams += ' \n';
}
if (scene.length > 0) {
objectParams += ' \n';
}
if (assets.length > 0) {
objectParams += ' \n';
}
for (var i in params) {
objectParams += ' \n';
}
objectParams +=
' \n' +
' \n' +
' ' + pulpCoreObject.getInstallHTML();
// Create the Object tag.
if (pulpCoreObject.browserName == "Explorer") {
var extraAttributes = '';
if (pulpCoreObject.compareVersions(pulpCoreObject.browserVersion, "7") < 0 &&
parent.frames.length > 0)
{
// On IE6 and older, if the site is externally framed, LiveConnect will not work.
// However, IE can use onfocus to emulate the appletLoaded() behavior
extraAttributes = ' onfocus="pulpcore_appletLoaded();"\n';
}
// Use the