All pastes #256591 Raw Edit

Mine

public text v1 · immutable
#256591 ·published 2006-11-24 12:25 UTC
rendered paste body
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 <title>Download</title>
 <script language="javascript" type="text/javascript">
  <!--

// Change this ID for whatever game you want to install
var titleId = "000100014A414345"; // F-Zero

var shop = new wiiShop();
var ec = new ECommerceInterface();

/*
var debug = false;
var wii = true;
var opera = true;
var msie = false;
*/

var ecTimeout = null;
var ecProgressInterval = 1000; // Timeout for checking progress in milliseconds
var isConnecting = false; // Unneeded...

function ECTimeout(timeout)
{
	this.timeout = timeout; // Timeout in milliseconds (to cancel)
	this.noProgressMillis = 0; // Milliseconds for which no progress was made
	this.lastPhase = 0; // Last progress phase
	this.lastDownloadedSize = 0; // Last downloaded size
}

function getLaunchTicket(titleId)
{
	var limitedTicket = null;

	var tickets = ec.getTicketInfos(titleId);

	if (typeof(tickets) == "object") {
		for (var n = 0;  n < tickets.length; n++)
		{
			var ticket = tickets.get(n);

			// Unlimited ?
			if ( (ticket.limits == null) ||
			     (ticket.limits.length == 0) )
			{
				return ticket;
			}
			else
			{
				limitedTicket = ticket;
			}
		}
	}

	return limitedTicket;
}

function onDownloadDone(progress)
{
	var connecting = "setSessionValue" in ec && "getSessionValue" in ec?ec.getSessionValue("connecting"):true;
	if (connecting != "true")
	{
		shop.endWaiting();
	}

	shop.enableHRP();

	// Download didnt fail
	if (progress.status >= 0)
	{
		// Set the wallpaper to cWP_Black (1)
		shop.setWallpaper(1);

		var t = getLaunchTicket(titleId);

		if (typeof(t) == "object") {
			ec.launchTitle(t.titleId, t.ticketId);
		}
	}
}

function checkProgress(firstTime, operation, description, onDone)
{
	var progress = ec.getProgress();

	if (progress.status == EC_ERROR_NOT_BUSY)
		return;

	if (progress.status == EC_ERROR_NOT_DONE)
	{
		if (ecTimeout != null)
		{
			if (firstTime)
			{
				ecTimeout.noProgressMillis = 0;
				ecTimeout.lastDownloadedSize = 0;
				ecTimeout.phase = progress.phase;
			}
			else
			{
				var hasProgress = false;

				if (progress.totalSize)
				{
					// There is a totalSize - see if progress was made
					hasProgress = (progress.downloadedSize != ecTimeout.lastDownloadedSize);
				}
				else
				{
					hasProgress = (progress.phase != ecTimeout.lastPhase);
				}

				if (hasProgress)
				{
					ecTimeout.noProgressMillis = 0;
					ecTimeout.lastDownloadedSize = progress.downloadedSize;
					ecTimeout.lastPhase = progress.phase;
				}
				else
				{
					ecTimeout.noProgressMillis += ecProgressInterval;
				}

				// Timeout
				if ( (progress.phase != EC_PHASE_GettingTicketsFromServer) &&
				     (ecTimeout.noProgressMillis >= ecTimeout.timeout) )
					ec.cancelOperation();
			}
		}

		// Call this function again after ecProgressInterval (milliseconds)
		setTimeout ('checkProgress(false,"' + operation + '","' + description + '","' + onDone + '")', ecProgressInterval);
	}
	else if (progress.status == EC_ERROR_CANCEL_FAILED)
	{
		var ossErrorCode = getOssErrorCode(progress);

		shop.endWaiting();
		shop.enableHRP();
		shop.error(ossErrorCode, cET_Server);
	}
	else
	{
		eval (onDone+"(progress)");
	}
}

function init()
{
	ec.cancelOperation();

	// Leave these 2 for now
	ecsUrl = 'https://ecs.shop.wii.com/ecs/services/ECommerceSOAP';
	iasUrl = 'https://ias.shop.wii.com/ias/services/IdentityAuthenticationSOAP';

	// Update these accordingly
	ccsUrl = 'http://ccs.cdn.shop.wii.com/ccs/download';
	ucsUrl = 'http://ccs.shop.wii.com/ccs/download';

	ec.setWebSvcUrls(ecsUrl, iasUrl);
	ec.setContentUrls(ccsUrl, ucsUrl);

	// Set timeout
	ecTimeout = new ECTimeout(parseInt("60000"));

	// setLogUrl("Log.jsp");
	// updateHistory();
	isConnecting = (isConnecting == "true");

	// Set the 'connecting' session value to the string "true"
	ec.setSessionValue("connecting", "true");
	// Start Waiting
	shop.beginWaiting();

	// Disable the homepage button on the wiimote
	shop.disableHRP();

	// finishOp();
	var opName = "Download";
	var opDesc = "Downloading "  + titleId;
	var doneFunc = "onDownloadDone";

	var progress = ec.downloadTitle(titleId);

	var connecting = "setSessionValue" in ec && "getSessionValue" in ec?ec.getSessionValue("connecting"):true;

	if ( (progress.status < 0) &&
	     (progress.status != EC_ERROR_NOT_DONE) )
	{
		if (connecting != "true")
		{
			shop.endWaiting();
		}

		// Enable wiimote buttons
		shop.enableHRP();

		// Call the 'downFunc' function
		eval(doneFunc+"(progress)");
	}
	else
	{
		checkProgress(true, opName, opDesc, doneFunc);

		if (connecting != "true")
		{
			shop.beginWaiting();
		}
	}
}

  //-->
 </script>
</head>
<body onload="javascript:init();">
</body>
</head>