'; OutString += '
'; OutString += NavBar; if (Feedback.length>0){ OutString += '' } OutString += '
'; OutString += ''; OutString += Feedback; OutString += '
'; //Write it to the frame TopFrame.document.clear(); TopFrame.document.open(); TopFrame.document.write(OutString); TopFrame.document.close(); } function Restart(){ Penalties = 0; GuessSequence.length = 0; Segments = Shuffle(Segments); BuildCurrGuess(); WriteFeedback(RemainingWords + '
' + RemainingList + ''); BuildExercise(); DisplayExercise(Exercise); } function Undo(){ if (GuessSequence.length < 1){ return; } GuessSequence.length = GuessSequence.length - 1; BuildCurrGuess(); WriteFeedback('' + Output + '

' + RemainingWords + '
' + RemainingList + ''); BuildExercise(); DisplayExercise(Exercise); } function AddSegment(SegNum){ GuessSequence[GuessSequence.length] = SegNum; BuildCurrGuess(); WriteFeedback('' + Output + ''); // WriteFeedback('' + Output + '

' + RemainingWords + '
' + RemainingList + ''); BuildExercise(); DisplayExercise(Exercise); } function BuildCurrGuess(){ var i = 0; var j = 0; var NewSeg = ''; //first, create arrays of all the segments guessed so far and those not yet used GuessSegs = new Array(); GuessSegs.length = 0; //set the "used" markers all to 0 for (i=0; i 0){ OutString = OutArray[0]; } else{ OutString = ''; } var Spacer = ''; for (i=1; i -1)||(Punctuation.indexOf(OutArray[i].charAt(0)) > -1)){ Spacer = ''; } OutString = OutString + Spacer + OutArray[i]; } //Capitalize the first letter if necessary if (CapitalizeFirst == true){ i = 0; if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){ i++; } if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){ i++; } var Temp = OutString.charAt(i); Temp = Temp.toUpperCase(); OutString = OutString.substring(0, i) + Temp + OutString.substring(i+1, OutString.length); } return OutString; } function CheckAnswer(CheckType){ if (GuessSequence.length < 1){ if (CheckType == 1){ WriteFeedback(NextCorrect + '
' + FindSegment(Answers[0][0]) + ''); Penalties++; } return; } var i = 0; var j = 0; var k = 0; var WellDone = ''; var WhichCorrect = -1; var TryAgain = ''; var LongestCorrectBit = ''; TempCorrect = new Array(); LongestCorrect = new Array(); var TempHint = ''; var HintToReturn = 1; var OtherAnswers = ''; for (i=0; i LongestCorrect.length){ LongestCorrect.length = 0; for (k=0; k -1){ for (i=0; i

' + CorrectResponse + '
'; //Do score calculation here var Score = Math.floor(((Segments.length-Penalties) * 100)/Segments.length); WellDone += YourScoreIs + ' ' + Score + '%.
'; if (OtherAnswers.length > 0){ WellDone += TheseAnswersToo + '' + OtherAnswers + ''; } WriteFeedback(WellDone); return; } else{ TryAgain = '' + CompileString(GuessSequence) + '

'; Penalties++; if (CheckType == 0){ TryAgain += IncorrectResponse + '
'; } if (LongestCorrect.length > 0){ LongestCorrectBit = CompileString(LongestCorrect); GuessSequence.length = LongestCorrect.length; TryAgain += ThisMuchCorrect + '
' + LongestCorrectBit + '
'; } if (CheckType == 1){ TryAgain += NextCorrect + '
' + FindSegment(HintToReturn); } WriteFeedback(TryAgain); BuildCurrGuess(); BuildExercise(); DisplayExercise(Exercise); } } function FindSegment(SegID){ var Seg = ''; for (var i=0; i-1){ FirstBit = InString.substring(0, i); LastBit = InString.substring(i + Token.length, InString.length); InString = FirstBit + Replacement + LastBit; i = InString.indexOf(Token); } return InString; } function DisplayExercise(StuffToDisplay){ //Build the output string var OutString = ''; OutString += ''; OutString += '
'; OutString += '
'; OutString += TitleCode; OutString += ''; OutString += NavBar; OutString += '
'; OutString += ''; OutString += StuffToDisplay; OutString += '
'; if (is.CRAPBrowser){OutString=ResolveAllURLs(OutString);} //Write it to the frame BottomFrame.document.clear(); BottomFrame.document.open(); BottomFrame.document.write(OutString); BottomFrame.document.close(); } function Blank(){ return '
©Half-Baked Software. Loading...
'; } //--> //]]>
-->