/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Gnextop                                                    *
* A PSP Portal by BlazeByte (http://blazebyte.org/gnextop)   *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Boot Screen API
===============

This script allows Gnextop to report boot progress to the user. This allows basic debugging (determine where an error may occur)


Functions:
---------

Gnextop.BootComplete ()
- Hides the boot screen and shows the main screen

Gnextop.StartBoot ()
- Hides the main screen, shows the boot screnn

Gnextop.ReturnLoading (string Text)
- Shows text explaining loading stage

Gnextop.LoadingDot ()
- Shows a "." every x seconds - shows loading

*/

Gnextop.Booted = false;
Gnextop.BootLines = new Array();
Gnextop.BootLines[0] = "Gnextop Version " + Gnextop.Version + " (" + Gnextop.ReleaseDate + ").";
// BootNewLine is an entire screen-width of characters to force a new line in a div (since <br/>, or any HTML, cannot be used)
Gnextop.BootNewLine = " ";
for(var i=0 ; i<160 ; i++)
  Gnextop.BootNewLine +=String.fromCharCode(160);
Gnextop.BootNewLine += " ";

Gnextop.BootComplete = function() {
  document.getElementById("screen").style.visibility = "visible";
  document.getElementById("bootscreen").style.visibility = "hidden";
  Gnextop.Booted = true;
}

Gnextop.StartBoot = function() {
  Gnextop.ReturnLoading(" @nln Preparing Screen...");
  Gnextop.Booted = false;
  document.getElementById("bootscreen").style.visibility = "visible";
  document.getElementById("screen").style.visibility = "hidden";
  Gnextop.LoadingDot();
}

Gnextop.ReturnLoading = function (strText){
  strText = strText.split("@nln"); // Force new line
  Gnextop.BootLines[Gnextop.BootLines.length-1] += strText[0];
  if(strText.length>1) Gnextop.BootLines[Gnextop.BootLines.length] = strText[1];
  if(Gnextop.BootLines.length>5) Gnextop.BootLines.shift();                                        // Limit lines to the screen height.
  document.getElementById("bootscreen").innerHTML = Gnextop.BootLines.join(Gnextop.BootNewLine);
}

Gnextop.LoadingDot = function() {
  if(!Gnextop.Booted){
    Gnextop.ReturnLoading('.');
    setTimeout("Gnextop.LoadingDot();",500)
  }
}