Friday, 13 September 2013

JavaScript-Random Greek Letters Not Working

JavaScript-Random Greek Letters Not Working

So I have this absolutely fantastic javascript random stuff generator,
except for one thing. You see, I have it set so that if it brings up a
certain random value, it throws in a Greek letter too. It worked great
until I worked on it some and now that part is broken. The rest of it
works, but that one part is necessary for it to make sense to those using
it. Here is the code:
<div id="unitInfo"></div>
<script type="text/javascript">
var pre = ["Research", "Storage", "Containment", "Mobile", "Biological",
"Armed", "Dimensional", "Reliquary"];
var types = ["Command", "Site", "Sector", "Area", "Unit", "Task Force"];
var greek = ["Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta",
"Theta", "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", "Omicron", "Pi",
"Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega"];
var update = ["online", "offline", "classified", "under repair",
"experiencing containment breach", "under attack", "[CONNECTION
SEVERED]", "[DATA EXPUNGED]", "terminated", "rogue", "secure",
"secure", "secure", "secure", "secure", "secure", "secure", "secure",
"secure", "secure", "secure", "secure", "secure", "secure", "secure",
"secure", "secure", "secure", "secure", "secure", "secure", "secure",
"secure", "secure", "secure", "secure", "secure", "secure", "secure",
"secure", "secure", "secure", "secure", "secure", "secure", "secure"];
var info = pre[Math.floor(Math.random() * pre.length)];
info += " " + types[Math.floor(Math.random() * types.length)];
if ( types == "Task Force" )
{
info += " " + greek[Math.floor(Math.random() * greek.length)];
info += "-" + ( 1 + Math.floor(Math.random() * 50) );
info += " is " + update[Math.floor(Math.random() * update.length)];
}
else
{
info += "-" + ( 1 + Math.floor(Math.random() * 50) );
info += " is " + update[Math.floor(Math.random() * update.length)];
}
document.getElementById("unitInfo").innerHTML = info;
</script>

No comments:

Post a Comment