home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Multimedia Spanish 3
/
ProOne-MultimediaSpanishIII-WinMac.bin
/
mac
/
span3web
/
verbfr.js
< prev
next >
Wrap
Text File
|
1998-04-19
|
5KB
|
218 lines
var verbForms; // the verb forms
var instruction; // the instructions for this exercise
var instrRef; // instruction reference number
var currProblem; // which verb form are we on?
function SetWords( wArray, startPos )
{
var i;
for (i=2; i<SetWords.arguments.length; i++)
{
wArray[startPos + i - 2] = SetWords.arguments[i];
}
}
function SetNumeric( nArray, n )
{
var i;
for (i=0; i < n; i++)
{
nArray[i] = i;
}
}
function GetInstrRef( n )
{
var i;
for (i = instrRef.length-1; i >=0; i--)
{
if (n >= instrRef[i])
{
return i;
}
}
return 0;
}
function Shuffle( nArray, startAt, n )
{
var i, j, swap;
for (i = startAt; i < startAt + n; i++)
{
j = startAt + Math.round(Math.random() * (n - 1));
swap = nArray[i];
nArray[i] = nArray[j];
nArray[j] = swap;
}
}
/*******************************************************************************
Split words from string str into a word array (wordArr).
Words are delimited by the delim argument.
Returns the number of words that were split out.
Note: this function is here because not all browsers have Javascript's
"split" function enabled.
*******************************************************************************/
function SplitWords( str, delim, wordArr ) // for browsers not having a "split" function
{
var fromPos, toPos, n;
n = 0;
fromPos = 0;
toPos = str.indexOf( delim, 0 );
while (toPos >= 0)
{
wordArr[n++] = str.substring( fromPos, toPos );
fromPos = toPos + 1;
while (str.charAt( fromPos ) == ' ')
{
fromPos++;
}
toPos = str.indexOf( delim, fromPos );
}
/* take last word on line and store it */
wordArr[n++] = str.substring( fromPos, str.length );
return n;
}
function LoadSound(name)
{
var d;
d = top.soundFrame.document;
d.open();
d.writeln("<html><head></head><body bgcolor=\"#ffffff\">");
d.writeln("<center>");
if (navigator.appVersion.indexOf("Mac") == -1)
{
d.writeln("<embed src=\"" + name + "\" autostart=\"true\" ");
d.writeln(" width=\"144\" height=\"15\" controls=\"smallconsole\">");
}
else
{
d.writeln("<embed src=\"" + name + "\" width=\"144\" height=\"24\" autoplay=\"true\"",
" autostart=\"true\" controls=\"smallconsole\">");
}
d.writeln("</center>");
d.writeln("</body></html>");
d.close();
}
function PlayVerb( n )
{
var dest;
dest = waveOffset + n;
dest = soundDir + dest + ".wav";
LoadSound( dest );
}
function WriteProblem( n )
{
var i;
var doc;
var verb;
var pronoun;
pronoun = new Array( 6 );
pronoun[0] = "yo";
pronoun[2] = "tú";
pronoun[4] = "él<br>ella<br>usted";
pronoun[1] = "nosotros";
pronoun[3] = "";
pronoun[5] = "ellos<br>ellas<br>ustedes";
doc = top.problemFrame.document;
doc.open();
doc.writeln("<html><head></head><body bgcolor='#ffffff'>");
doc.writeln("<div align='center'><img src='pics/barflgs.gif' width='514' height='16'><p>");
doc.writeln(instruction[GetInstrRef(n)]);
doc.writeln("<hr>");
doc.writeln("<table width='70%'>");
verb = new Array( 7 );
nChoices = SplitWords( verbForms[n], "|", verb );
doc.writeln("<tr><td colspan='4' align='center'>" + verb[6] + "</td></tr>");
doc.writeln("<tr><td align='right'>" + pronoun[0] + "</td><td>" + verb[0] + "</td>");
doc.writeln("<td align='right'>" + pronoun[1] + "</td><td>" + verb[1] + "</td></tr>");
doc.writeln("<tr><td align='right'>" + pronoun[2] + "</td><td>" + verb[2] + "</td>");
doc.writeln("<td><br></td><td><br></tr>");
doc.writeln("<tr><td align='right'>" + pronoun[4] + "</td><td>" + verb[4] + "</td>");
doc.writeln("<td align='right'>" + pronoun[5] + "</td><td>" + verb[5] + "</td></tr>");
doc.writeln("</table><p>");
doc.write("<a href='javascript:top.PlayVerb(top.currProblem)'>");
doc.writeln("<img src=\"pics/speaker.gif\" border=0 alt=\"[Speaker]\"></a>");
doc.writeln("</div>");
if (currProblem == 0)
{
top.naviFrame.location.href = (maxProblem == 1) ? "vbutnX.htm" : "vverbN.htm";
}
else if (currProblem != maxProblem-1)
{
top.naviFrame.location.href = "vverbBN.htm";
}
else
{
top.naviFrame.location.href = "vverbB.htm";
}
doc.writeln("</body></html>");
doc.close();
}
function GoNext()
{
if (currProblem < maxProblem-1)
{
nTries = 0;
currProblem++;
WriteProblem( currProblem );
}
else
{
window.status = "You are already on the last set."
}
}
function GoBack()
{
if (currProblem != 0)
{
currProblem--;
WriteProblem( currProblem );
}
else
{
window.status = "You are already on the first set."
}
}
function GoIndex()
{
top.location.href = lessonURL + top.location.search;
}
function Setup()
{
currProblem = 0;
verbForms = new Array( maxProblem );
Initialize();
WriteProblem(0);
}