diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt')
| -rw-r--r-- | Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt | 1067 |
1 files changed, 1067 insertions, 0 deletions
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt new file mode 100644 index 0000000..da3e032 --- /dev/null +++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt @@ -0,0 +1,1067 @@ +/***********************
+WARNING: this file has been extensively hacked to allow for certain features (matrix and alternate step) that
+were requested very late in the programming stage.
+It is very hard to understand these functions because we were trying to allow for backwards compatiblity.
+***********************/
+//var deviceUsed;
+var hasDefaultGraphic; // boolean to check whether there is a backup graphics for all steps
+var Language;
+var labDrill=false; // string, either "True" or "False", whether or not it is a lab drill or a syntax drill
+ // variable is set in the data files of the labs
+var loadedCommands = new Object(); // keeps track of all command modes loaded into flash
+
+var matrix = null; // global array to keep track of matrix check finished steps
+var AnswerArray = new Array();
+var errorArray = new Array();
+var stepModeArray = new Array();
+var parsestatus = 0; //global variable to check if the command is conflicting
+ // Here are the enum'ed variable for parsestatus
+ SUCCESSFULregcmd = 0;
+ UNSUCCESSFULregcmd = 1;
+ INCOMPLETEregcmd = 2;
+ UNSUPPORTEDregcmd = 3;
+ AMBIGUOUSregcmd = 4;
+ SUCCESSFULhelpcmd = 5;
+ UNSUCCESSFULhelpcmd = 6;
+ INCOMPLETEhelpcmd = 7;
+ UNSUPPORTEDhelpcmd = 8;
+ AMBIGUOUShelpcmd = 9;
+var instructionArray = new Array();
+var resultArray = new Array();
+var graphicArray = new Array();
+var chapterCovered = ""
+var wantShowTopology = false;
+var routerInfoArray = new Array();
+var routerUsedForThisStep = new Array();
+
+// A data structure to store device Command history
+var devCmdHist = new Array();
+function deviceCommandHistoryClass()
+{
+ this.configHistory = new Array();
+ this.userHistory = new Array();
+
+ this.userHistIndex=0;
+ this.configHistIndex=0;
+ this.historyBufferLength=10;
+}
+
+
+var stepnum = 1; // global variable, used very often, keeps track of the current step number
+var substepNumber; // keeps track of current substep number
+
+function resultObj()
+{
+ this.stepnum = "0";
+ this.result = new Array();
+
+}
+//router information object
+
+function routerInfoObj()
+{
+ this.routerNum = 0;
+ this.hostName = "";
+ this.enablePassword = "";
+ this.enableSecret = "";
+ this.deviceType = "";
+}
+
+function generalObj()
+{
+ this.stepnum = "0";
+ this.commandName = ""; // the first word of the command, ie. enable or interface
+ this.param1 = ""; // second word in the command, ie. ethernet, serial
+ this.param2 = ""; // third
+ this.param3 = "";
+ this.param4 = "";
+ this.param5 = "";
+ this.param6 = "";
+ this.param7 = "";
+ this.param8 = "";
+ this.param9 = "";
+ this.param10 = "";
+ this.param11 = "";
+ this.param12 = "";
+ this.param13 = "";
+ this.param14 = "";
+ this.param15 = "";
+
+}
+
+function addToRouterSIMObject(rNum, hName, ePwd,eSecret, deviceType)
+{
+ routerInfoArray[rNum] = new routerInfoObj();
+ routerInfoArray[rNum].routerNum = rNum;
+ routerInfoArray[rNum].hostName = hName;
+ routerInfoArray[rNum].enablePassword = ePwd;
+ routerInfoArray[rNum].enableSecret = eSecret;
+ routerInfoArray[rNum].deviceType = deviceType;
+
+ devCmdHist[rNum] = new deviceCommandHistoryClass();
+}
+
+
+function assignValueToAnswer(indexvalue,stepnum,substep,commandName,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15)
+{
+ // this was added for alternate steps.
+ // each alternate step is in an array of the AnswerArray ( 2 dimensional array)
+ if(AnswerArray[indexvalue] == null)
+ AnswerArray[indexvalue] = new Array();
+
+ var subIndex=AnswerArray[indexvalue].length;
+ AnswerArray[indexvalue][subIndex] = new generalObj();
+ AnswerArray[indexvalue][subIndex].stepnum = stepnum;
+ AnswerArray[indexvalue][subIndex].commandName = commandName;
+ AnswerArray[indexvalue][subIndex].matrixCheck = substep; // true if this step is a part of a matrix check (ie steps done out of order)
+ // false otherwise
+ AnswerArray[indexvalue][subIndex].status = false;
+ AnswerArray[indexvalue][subIndex].param1 = param1;
+ AnswerArray[indexvalue][subIndex].param2 = param2;
+ AnswerArray[indexvalue][subIndex].param3 = param3;
+ AnswerArray[indexvalue][subIndex].param4 = param4;
+ AnswerArray[indexvalue][subIndex].param5 = param5;
+ AnswerArray[indexvalue][subIndex].param6 = param6;
+ AnswerArray[indexvalue][subIndex].param7 = param7;
+ AnswerArray[indexvalue][subIndex].param8 = param8;
+ AnswerArray[indexvalue][subIndex].param9 = param9;
+ AnswerArray[indexvalue][subIndex].param10 = param10;
+ AnswerArray[indexvalue][subIndex].param11 = param11;
+ AnswerArray[indexvalue][subIndex].param12 = param12;
+ AnswerArray[indexvalue][subIndex].param13 = param13;
+ AnswerArray[indexvalue][subIndex].param14 = param14;
+ AnswerArray[indexvalue][subIndex].param15 = param15;
+
+
+}
+
+
+
+function assignValueToError(indexvalue,stepnum,commandName,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,param11,param12,param13,param14,param15)
+{
+ // used for alternate steps
+ if(errorArray[indexvalue] == null)
+ errorArray[indexvalue] = new Array();
+ var subIndex=errorArray[indexvalue].length;
+ errorArray[indexvalue][subIndex] = new generalObj();
+ errorArray[indexvalue][subIndex].stepnum = stepnum;
+ errorArray[indexvalue][subIndex].commandName = commandName;
+ errorArray[indexvalue][subIndex].param1 = param1;
+ errorArray[indexvalue][subIndex].param2 = param2;
+ errorArray[indexvalue][subIndex].param3 = param3;
+ errorArray[indexvalue][subIndex].param4 = param4;
+ errorArray[indexvalue][subIndex].param5 = param5;
+ errorArray[indexvalue][subIndex].param6 = param6;
+ errorArray[indexvalue][subIndex].param7 = param7;
+ errorArray[indexvalue][subIndex].param8 = param8;
+ errorArray[indexvalue][subIndex].param9 = param9;
+ errorArray[indexvalue][subIndex].param10 = param10;
+ errorArray[indexvalue][subIndex].param11 = param11;
+ errorArray[indexvalue][subIndex].param12 = param12;
+ errorArray[indexvalue][subIndex].param13 = param13;
+ errorArray[indexvalue][subIndex].param14 = param14;
+ errorArray[indexvalue][subIndex].param15 = param15;
+
+}
+
+function assignValueToResult(indexvalue,stepnum,result)
+{
+ resultArray[indexvalue] = new resultObj();
+ resultArray[indexvalue].stepnum = stepnum;
+// resultArray[indexvalue].result = result;
+
+ for (var i=2; i<arguments.length; i++)
+ resultArray[indexvalue].result.push(arguments[i]);
+}
+
+
+// Parse status codes
+// SUCCESSFULregcmd = 0;
+// UNSUCCESSFULregcmd = 1;
+// INCOMPLETEregcmd = 2;
+// UNSUPPORTEDregcmd = 3;
+// AMBIGUOUSregcmd = 4;
+// SUCCESSFULhelpcmd = 5;
+// UNSUCCESSFULhelpcmd = 6;
+// INCOMPLETEhelpcmd = 7;
+// UNSUPPORTEDhelpcmd = 8;
+// AMBIGUOUShelpcmd = 9;
+function processStep(snum)
+{
+trace("parsestatus = " + parsestatus);
+ if (parsestatus == SUCCESSFULregcmd)
+ {
+ //errorNotice("Successful command");
+ }
+ else if (parsestatus == UNSUCCESSFULregcmd)
+ {
+ //errorNotice("Unsuccessful command");
+ }
+ else if (parsestatus == INCOMPLETEregcmd)
+ {
+ //errorNotice("Incomplete command");
+ }
+ else if (parsestatus == UNSUPPORTEDregcmd)
+ {
+ errorNotice("Unsupported command");
+ return;
+ }
+ else if (parsestatus == AMBIGUOUSregcmd)
+ {
+// errorNotice("Ambiguous command");
+ return;
+ }
+ else if (parsestatus == SUCCESSFULhelpcmd)
+ {
+ //errorNotice("Successful help command");
+ return;
+ }
+ else if (parsestatus == UNSUCCESSFULhelpcmd)
+ {
+// errorNotice("Unsuccessful help command");
+ return;
+ }
+ else if (parsestatus == INCOMPLETEhelpcmd)
+ {
+ //errorNotice("Incomplete help command");
+ return;
+ }
+ else if (parsestatus == UNSUPPORTEDhelpcmd)
+ {
+ errorNotice("Unsupported help command");
+ return;
+ }
+ else if (parsestatus == AMBIGUOUShelpcmd)
+ {
+ //errorNotice("Ambiguous help command");
+ return;
+ }
+ else
+ {
+ // We should never get to this else statement.
+ // If we did, we have made a new case for parsestatus
+ errorNotice("Fatal Error. Contact developer.");
+ return;
+ }
+ // Main case, should be here often, do this first for optimization purposes.
+
+ // As this is a rewrite, I have left out some support for expanding 'e0' and 's0'.
+ // The older algorithm had a flaw anyways and so it would have made incorrect commands
+ // into correct ones. When it is needed, it will be re'implemented correctly -- Daniel
+ processSuccessfulStep(snum);
+}
+
+// This function is for parsing all correct commands/displaying error messages if its not correct.
+function processSuccessfulStep(snum)
+{
+ MaxParam = 15; // for now we leave it in this function as it is the only one that uses it.
+
+ shortCutTab = new Array("e0","e1","s0","s1","atm0","dialer0","bri0");
+ shortCutExpand = new Array("ethernet 0", "ethernet 1","serial 0","serial 1", "atm 0", "dialer 0", "bri 0");
+ if (labDrill == "False")
+ {
+ for(var i = 0; i < _root.completeKeywordneeded.length; i++)
+ {
+ _root.completeKeywordneeded[i] =true;
+ }
+
+ }
+ else
+ {
+
+ // Expansion of e0, s0, atm0 etc...
+// loop through the whole command typed in,
+ for (i=0; i < COMMAND.length; i++)
+ {
+ // for each, check if its from the table, if it is, expand it.
+ for (j=0;j < shortCutTab.length; j++)
+ {
+
+ if (COMMAND[i].toLowerCase() == shortCutTab[j].toLowerCase())
+ {
+ // everything before, leave as is
+ newCmdAr = new Array();
+ newCmdAr = COMMAND.slice(0,i);
+
+ // add in what we need
+ newCmdAr = newCmdAr.concat(shortCutExpand[j].split(" "));
+
+ // fill in the rest
+ newCmdAr = newCmdAr.concat(COMMAND.slice(i+1,COMMAND.length));
+
+ // move the iterator up to skip the check
+ COMMAND = newCmdAr;
+ i=i+1;
+ break;
+ }
+ }
+ }
+ }
+
+ // bounds check on step number, 0 and above AnswerArray
+ if (snum <= 0 || snum > AnswerArray.length)
+ {
+ errorNotice("Fatal Error. Step number out of bounds.");
+ return;
+ }
+
+ var found = false;
+ var errorpos = 0;
+trace("_root.completeKeywordneeded = " + _root.completeKeywordneeded);
+
+ // now we index into the right Answer array.
+ // With the right Answer key, we check each parameter in the command line for matching criterion.\
+ var boolDrill = false;
+ matrixOffset=0; // keeps track of which out-of-order step to use
+ alternateOffset=0; // use for alternate commands
+
+ // check if matrix check is on, if it is, check the answer with all relevent substeps
+ if (matrix != null)
+ { // matrix check is on
+ if (labDrill == "False")
+ { // syntax drill
+ // find the correct indexvalue that matches this substep
+ for (matrixOffset = 0; (matrixOffset < matrix.length); matrixOffset++)
+ {
+ if (matrix[matrixOffset] == false)
+ {
+ // go through all the alternate steps
+ for (var i = 0; (i < AnswerArray[_root.stepnum + matrixOffset].length); i++)
+ {
+ alternateOffset = i;
+ boolDrill = (AnswerArray[_root.stepnum+matrixOffset][i].commandName.toLowerCase() == COMMAND[0].toLowerCase());
+ if(boolDrill== true)
+ {
+ //matrix[matrixOffset] = true;
+ snum = _root.stepnum + matrixOffset;
+ break;
+ }
+ }
+ }
+
+ if(boolDrill == true)
+ break;
+ }
+
+ // can't find a match, reset to a substep that has not been completed yet
+ if(boolDrill == false)
+ {
+ for(matrixOffset=0; matrixOffset<matrix.length; matrixOffset++)
+ if(matrix[matrixOffset] == false) break;
+ snum = _root.stepnum + matrixOffset;
+ }
+
+ }
+ else
+ { // labdrill
+ for(matrixOffset = 0; (matrixOffset < matrix.length); matrixOffset++)
+ {
+ if(matrix[matrixOffset] == false)
+ {
+ for(var i = 0; (i < AnswerArray[_root.stepnum + matrixOffset].length); i++)
+ {
+ alternateOffset = i;
+ boolDrill = (AnswerArray[_root.stepnum+matrixOffset][i].commandName.substring(0,COMMAND[0].length).toLowerCase() == COMMAND[0].toLowerCase());
+ if(boolDrill == true)
+ {
+ //matrix[matrixOffset] = true;
+ snum = _root.stepnum + matrixOffset;
+ break;
+ }
+ }
+ }
+
+ if(boolDrill == true)
+ break;
+ }
+
+ // can't find a match, reset to a substep that has not been completed yet
+ if(boolDrill == false)
+ {
+ for(matrixOffset=0; matrixOffset<matrix.length; matrixOffset++)
+ if(matrix[matrixOffset] == false) break;
+ snum = _root.stepnum + matrixOffset;
+ }
+ }
+ }
+ else
+ {// no matrix check needed
+ if(labDrill == "False")
+ { // syntax drill
+ for(var i = 0; (i < AnswerArray[snum].length); i++)
+ {
+ boolDrill = (AnswerArray[snum][i].commandName.toLowerCase() == COMMAND[0].toLowerCase());
+ if(boolDrill == true)
+ {
+ alternateOffset = i;
+ break;
+ }
+ }
+ }
+ else
+ { // lab drill
+ for(var i = 0; (i < AnswerArray[snum].length); i++)
+ {
+ if(_root.completeKeywordneeded[0] == false)
+ {
+//msgNotice("Complete keyword not needed");
+ boolDrill = (AnswerArray[snum][i].commandName.substring(0,COMMAND[0].length).toLowerCase() == COMMAND[0].toLowerCase());
+ if(boolDrill == true)
+ {
+ alternateOffset = i;
+ break;
+ }
+ }
+ else
+ {
+//msgNotice("Complete keyword needed");
+ boolDrill = (AnswerArray[snum][i].commandName.toLowerCase() == COMMAND[0].toLowerCase());
+ if(boolDrill == true)
+ {
+ alternateOffset = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+trace("boolDrill = " + boolDrill);
+//msgNotice(boolDrill);
+ if (boolDrill)
+ {
+ trace("After boolDrill is true");
+ // Any errors, mark the position and break out
+ // No errors, command is complete
+ found = true;
+
+ // loop through all the matrix steps
+ for(matrixOffset = 0; (matrixOffset == 0) || (matrixOffset < matrix.length); matrixOffset++)
+ {
+trace("Checking matrix " + matrixOffset);
+ // check the commandName first, if it's the same, look through the parameters
+ // if not the same, then check the next matrix step
+ if ((matrix != null) && (matrix[matrixOffset] == true))
+ {
+ found = false;
+ continue;
+ }
+
+ // for every alternate step, check all the parameters to see which is correct
+ for(var i =0; i < AnswerArray[_root.stepnum+matrixOffset].length; i++)
+ {
+trace("Checking Alternate Step " + i);
+ //msgNotice(i);
+ var temp = AnswerArray[_root.stepnum+matrixOffset][i];
+ strvalue=temp.commandName;
+
+ if (_root.completeKeywordneeded[0] == true)
+ {
+ if (strvalue.toLowerCase() == COMMAND[0].toLowerCase())
+ {
+ found = true;
+ }
+ else
+ {
+ found = false;
+ }
+ }
+ else
+ {
+ if (strvalue.substring(0,COMMAND[0].length).toLowerCase() == COMMAND[0].toLowerCase())
+ {
+ found = true;
+ }
+ else
+ {
+ found = false;
+ }
+ }
+
+ if (found == false)
+ continue;
+
+trace("About to check parameters");
+ for (var curParam = 1; (curParam <= MaxParam) && (curParam <= COMMAND.length); curParam++)
+ {
+trace("Checking parameter " + curParam);
+
+ strvalue = eval("temp.param" + curParam);
+trace("String value = " + strvalue);
+ //msgNotice(alternateOffset);
+ //blah = eval("AnswerArray[snum][alternateOffset].param" + curParam);
+ //msgNotice(blah);
+//trace("str = " + strvalue);
+ if (_root.completeKeywordneeded[curParam] == true)
+ {
+ //msgNotice("COMPLETE KEYWORD NEEDED");
+//trace("MUST need whole command");
+ if (strvalue.toLowerCase() == COMMAND[curParam].toLowerCase())
+ {
+ //msgNotice(AnswerArray[6][1].param2.toLowerCase() +" "+ COMMAND[curParam].toLowerCase())
+ //msgNotice(AnswerArray[6][1].param2.toLowerCase())
+ //msgNotice(curParam +"\n"+ String(COMMAND[curParam].toLowerCase()))
+ found = true;
+ continue;
+ }
+ else
+ {
+ //msgNotice("curParam = " + curParam);
+//msgNotice("1");
+// msgNotice("NOT FOUND:\n"+strvalue.toLowerCase() + " " + COMMAND[curParam].toLowerCase());
+ found = false;
+ errorpos = curParam;
+ break;
+ }
+ }
+ else
+ {
+ if (strvalue.substring(0,COMMAND[curParam].length).toLowerCase() == COMMAND[curParam].toLowerCase())
+ {
+ found = true;
+ continue;
+ }
+ else
+ {
+//msgNotice("2");
+ found = false;
+ errorpos = curParam;
+ break;
+ }
+ }
+
+ } // end for
+
+ if(found == true)
+ {
+ snum = _root.stepnum + matrixOffset;
+ //msgNotice("found =true");
+ alternateOffset = i;
+ break;
+ }
+
+ } // end for
+
+ if(found == true)
+ {
+ break;
+ }
+
+ } // end for
+
+ } // end if
+
+ // Now we see if the whole command was correct or not.
+ if (found == true)
+ {
+ // The answer is correct.
+ if(matrix != null)
+ matrix[matrixOffset] = true;
+
+ resultOutput = resultArray[snum].result;
+ _root.showTheResult(resultOutput);
+
+ //trace("correctCommand = " + correctCommand);
+ if (typeof(_root.correctCommand) == "function")
+ {
+ correctCommand();
+ }
+
+ correctCommand = null;
+
+ // All non next to last step gets processed like this
+ if(matrix != null)
+ {
+ // process matrix checking procedure here
+ // check if all the matrix sub steps are done
+ var matrixDone = true;
+ for(var i = 0; i < matrix.length; i++)
+ {
+ if(matrix[i] == false)
+ {
+ matrixDone = false;
+ break;
+ }
+ }
+
+ // not finished all substeps
+ if(matrixDone == false)
+ {
+ goToNextStep(_root.stepnum, _root.stepnum-1);
+ commandline_setMode(stepModeArray[_root.stepnum], _root.active_router);
+ }
+ else
+ {
+ // finished all substeps
+ // go on to next step not within this matrix
+ oldstep = _root.stepnum
+ for(_root.stepnum++;(_root.stepnum < stepModeArray.length)&&(AnswerArray[_root.stepnum][0].matrixCheck == true) && (AnswerArray[_root.stepnum][0].stepnum == AnswerArray[_root.stepnum-1][0].stepnum); _root.stepnum++);
+
+ if(_root.stepnum < stepModeArray.length)
+ {
+ // still have more steps to go
+ matrix= null;
+ loadImage(_root.stepnum,_root.stepnum-1);
+ goToNextStep(_root.stepnum, _root.stepnum-1);
+ commandline_setMode(stepModeArray[_root.stepnum], _root.active_router);
+ }
+ else
+ {
+ // no more steps to go
+ showInstruction(oldstep);
+ doneIsWaiting = true;
+ matrix = null;
+ }
+ }
+ }
+ else
+ {
+ if (snum < stepModeArray.length - 1)
+ {
+ if ((AnswerArray[snum][alternateOffset].commandName.toLowerCase() == "enable") &&
+ ((_root.rRouterA.run.password.length > 0) || (_root.rRouterA.run.secret.length > 0)) )
+ {
+ _root.commandline_changeProcess("password_processPassword");
+ password_passwordLine();
+ }
+ else
+ {
+ // check if this mode is ever used again later, if not, unload, if yes, do nothing.
+ unloadCommands(stepnum);
+ if(matrix != null)
+ {
+ while(AnswerArray[stepnum][alternateOffset].matrixCheck == true)
+ stepnum++;
+ }
+ else
+ stepnum++;
+
+ loadImage(stepnum,stepnum-1);
+ goToNextStep(stepnum, stepnum-1);
+ commandline_setMode(stepModeArray[snum+1], _root.active_router);
+ }
+ }
+ else
+ {
+ doneIsWaiting = true;
+ matrix = null;
+
+ /*
+ if (_root.processName == "output_processMore")
+ doneIsWaiting = true;
+ else
+ {
+ doneIsWaiting = false;
+ _root.commandline_changeProcess("");
+
+ msgNotice("\nCongratulations !!!!!\nYou have succesfully completed the Lab-Drill Exercise\n")
+ }*/
+ break;
+ }
+ }
+ }
+ else
+ {
+ // not found
+ // no substep, no need to check anything.
+ var rptr = errorArray[snum][alternateOffset];
+//trace(rptr);
+ if (errorpos > 0)
+ errorstring = eval("rptr.param" + errorpos);
+ else
+ {
+ // commandName is wrong..
+ // make sure to use the first alternate step (default)
+ errorstring = errorArray[snum][0].commandName;
+// msgNotice(String(alternateOffset)+" "+ errorArray[snum][0].commandName);
+ }
+
+ if (errorstring.length > 0)
+ {
+ errorNotice(errorstring);
+ }
+ else
+ {
+ errorNotice("Too many arguments");
+ }
+ }
+
+ //reset the keyword completion check
+ fillcompleteKeyword(true);
+}
+
+function checkDone()
+{
+//trace("_root.processName =" +_root.processName);
+//trace("_root.doneIsWaiting = " +_root.doneIsWaiting);
+//trace("countdown = " + countdown);
+//trace("startTime = " + startTime);
+//trace("curTime = " + curTime);
+ if ((_root.processName != "output_processMore") && (_root.doneIsWaiting))
+ {
+ if (countdown == null)
+ {
+ countdown = 2000;
+ startTime = getTimer();
+ }
+ else
+ {
+ curTime = getTimer();
+ if ((curTime-startTime) >= countdown)
+ {
+ // count down for a half a sec or so and print out info
+ _root.active_router.hostname = "";
+ _root.commandline_changeProcess("");
+ _root.msgNotice("\nCongratulations !!!!!\nYou have succesfully completed the Lab-Drill Exercise\n");
+ _root.doneIsWaiting = false;
+ _root.disableAllButtons();
+ }
+ }
+ }
+}
+
+
+function getMatchCommandParts(command1, command2, matchComplete)
+{
+ var cmd1 = command1.split(" ");
+ var cmd2 = command2.split(" ");
+
+ var numOfParts = (cmd1.length < cmd2.length) ? cmd1.length : cmd2.length;
+
+ for (var i = 0; i < numOfParts; i++)
+ {
+ if ( (cmd1[i].toLowerCase() != cmd2[i].substring(0, cmd1[i].length).toLowerCase())
+ || (matchComplete && (cmd1[i].toLowerCase() != cmd2[i].toLowerCase())) )
+ return i;
+ }
+
+ return i;
+}
+
+
+// this function checks if the mode the current step is ever used again in this lab, if not, unload it.
+function unloadCommands(step)
+{
+ var stepDevice = _root.routerInfoArray[_root.routerUsedForThisStep[_root.stepnum]].deviceType;
+ CurrentMode = stepModeArray[step];
+ // step through all the steps
+ for(i=step+1; i < (stepModeArray.length); i++)
+ {
+ // if same as currentmode, do nothing
+ if(stepModeArray[i] == CurrentMode)
+ {
+// trace("same mode");
+ return;
+ }
+ }
+
+ // unload the commands because there are no later steps that use it.
+// trace("unload movie");
+ eval(CurrentMode +"C") = new Array();
+ eval("_root.loadedCommands." + CurrentMode) = null;
+
+}
+
+// Use this function to send out error Window messages w/ only one line of code.
+function errorNotice(str)
+{
+ _root.HyperTerminal.errorWindow.msg = "<b><p align=\"center\">" + str + "</p></b>";
+ _root.HyperTerminal.errorWindow._visible = true;
+}
+
+// Use this function to send out messages to the message window w/ only one line of code.
+function msgNotice(str)
+{
+ _root.HyperTerminal.errorWindowTelnet.msg = "<b><p align=\"center\">" + str + "</p></b>";
+ _root.HyperTerminal.errorWindowTelnet._visible = true;
+}
+
+function isSubStepCompleted(stepNumber)
+{
+ var completed = false;
+ var ctrCompleted = 0;
+ var ctrTotal = 0;
+ for (m = 0; m < AnswerArray.length; m++)
+ {
+ if (AnswerArray[m][0].stepnum == stepNumber)
+ {
+ ctrTotal++;
+
+ if (AnswerArray[m][0].status == true)
+ ctrCompleted++;
+ }
+ }
+ if (ctrTotal == ctrCompleted)
+ completed = true;
+
+
+ return completed;
+}
+
+
+function showTheResult(inputString)
+{
+ var outputString = "";
+ var i = 0;
+ var lastString = "";
+/*
+ while (i < inputString.length)
+ {
+ output_write(inputString.substr(i,1));
+ lastString = inputString.substr(i,1);
+ i = i + 1;
+
+ }
+*/
+ for (var i=0; i<inputString.length; i++)
+ output_write(inputString[i]);
+
+ if ( (lastString.length > 0) && (lastString != "\n"))
+ {
+ output_write("\n");
+ }
+
+/*
+ while (i < inputString.length)
+ {
+ if ( (inputString.substr(i,1) == "\\n") ){ //&& (inputString.substr(i+1,1) == "n") ) {
+ output_write(outputString);
+ output_write("\n");
+ outputString = "";
+ i = i + 1;
+ }
+ else {
+ outputString += inputString.substr(i,1);
+ }
+
+ i = i + 1;
+ }
+ if (outputString.length > 0) {
+ output_write(outputString);
+ output_write("\n");
+ }
+*/
+
+
+}
+
+function showInstruction(num)
+{
+ var stepStr = "";
+ if (num > 0)
+ {
+ // if matrixCheck is on for this step, make a new array to keep track of which
+ // sub step is done.
+ if( (AnswerArray[num][0].matrixCheck == true) && (matrix == null) )
+ {
+ matrix = new Array();
+ for(var i = 0; (AnswerArray[num+i][0].matrixCheck == true) && (AnswerArray[num][0].stepnum == AnswerArray[num+i][0].stepnum); i++)
+ matrix[i] = false;
+ }
+ else if(AnswerArray[num][0].matrixCheck == false)
+ matrix = null;
+
+
+ // figure out substep number to show
+ var substepNumber;
+ for (substepNumber = 1; (AnswerArray[num-substepNumber][0].stepnum == AnswerArray[num][0].stepnum); substepNumber++);
+
+ if ((substepNumber == 1) && (AnswerArray[num][0].stepnum != AnswerArray[num+1][0].stepnum))
+ substepNumber = 0;
+
+ // increment the substep number with the amount of finished matrix sub steps.
+ if(matrix != null)
+ {
+ for(var i =0; i<matrix.length; i++)
+ if(matrix[i] == true)
+ substepNumber++;
+ }
+/*
+ if (AnswerArray[num].stepnum != AnswerArray[num-1].stepnum)
+ {
+ substepNumber = 1;
+ if (AnswerArray[num].stepnum != AnswerArray[num+1].stepnum)
+ substepNumber = 0;
+ }
+ else
+ substepNumber++;
+*/
+ if (substepNumber > 0)
+ stepStr = "<font color='#ff0000'>" + AnswerArray[num][0].stepnum + "." + substepNumber + "</font><br>";
+
+ }
+
+ // initialize the menu instructions
+ if(matrix != null)
+ {
+ _root.menu.instr = "<b>" + stepStr;
+ for(var i = 0; i<matrix.length; i++)
+ {
+ if(matrix[i] == true)
+ _root.menu.instr += "<font color = '#669999'>" + instructionArray[num+i] + "</font><br><br>";
+ else if(matrix[i] == false)
+ _root.menu.instr += instructionArray[num+i] + "<br><br>";
+ }
+ _root.menu.instr += "</b>";
+ }
+ else _root.menu.instr = "<b>" + stepStr + instructionArray[num] + "</b>";
+
+ /*var i = 0;
+ while (outputString != "") {
+
+ if (outputString.length > 21) {
+ i = i + 21;
+ _root.menu.instr += "\n" + outputString.substr(0,21);
+ outputString = instructionArray[num].substring(i);
+ }
+ else {
+ _root.menu.instr += "\n" + outputString;
+ outputString = "";
+ }
+ }*/
+
+
+}
+
+
+function loadImage(num, prev)
+{
+ // Assume graphics are all 588 x 388
+ var graphicImage = "";
+ var prevImage = "";
+
+ graphicImage = getGraphicName(num) + ".swf";
+
+ if (prev != null)
+ {
+ prevImage = getGraphicName(prev) + ".swf";
+ }
+ stepImage._visible = true;
+
+//trace("hasDefaultGraphic = " + _root.hasDefaultGraphic);
+ if (_root.hasDefaultGraphic == true && graphicImage == ".swf")
+ {
+ // we have a default graphic so all blank steps should use the [0] graphic.
+ graphicImage = getGraphicName(0) + ".swf";
+ }
+ if (_root.hasDefaultGraphic == true && prevImage == ".swf")
+ {
+ // we make sure we compare to a default page
+ prevImage = getGraphicName(0) + ".swf";
+ }
+
+ if (graphicImage != ".swf")
+ {
+ // If same image, don't reload
+
+ if (graphicImage != prevImage)
+ {
+ if (_level0.LabDataDir == "")
+ loadMovie((_level0.LabDataDir +graphicImage), _root.stepImage.realImage);
+ else
+ {
+ loadMovie((_level0.LabDataDir + _level0.eLabAr[_level0.currentLab].directory +"/"+graphicImage), _root.stepImage.realImage);
+ }
+ //trace(_level0.LabDataDir);
+ //trace(chapterCovered);
+ //trace(graphicImage);
+ }
+ }
+ else
+ {
+ stepImage._visible = false
+ }
+ // Shrinking the image to fit at the top
+ moveImageDefault();
+ blowImageDown();
+}
+
+function blowImageDown()
+{
+ _root.stepImage._xscale = 45;
+ _root.stepImage._yscale = 45;
+ _root.HyperTerminal._visible = true;
+}
+
+function blowImageUp()
+{
+ _root.stepImage._xscale = 100;
+ _root.stepImage._yscale = 100;
+ _root.HyperTerminal._visible = false;
+}
+
+function moveImageDefault()
+{
+ _root.stepImage._x = 324;
+ _root.stepImage._y = 7;
+}
+
+function moveImageHT()
+{
+ _root.stepImage._x = 186;
+ _root.stepImage._y = 183;
+}
+
+function getGraphicName(num)
+{
+ return graphicArray[num];
+}
+
+function goToNextStep(num,prevnum)
+{
+/*
+ for (i = 0; i <= AnswerArray.length; i++)
+ {
+ eval("blank.buttonlist.step" + i).gotoAndStop(1);
+ }
+*/
+ _root.stepnum = num;
+ _root.showInstruction(_root.stepnum);
+
+ if(num > prevnum)
+ _root.stepscrollDown();
+ else
+ _root.stepscrollUp();
+
+ // miwang
+ if(num == 0)
+ _root.coverButton(0);
+ else
+ _root.coverButton(AnswerArray[_root.stepnum][0].stepnum);
+
+
+
+ clickedButton = _root.stepnum;
+ //eval("blank.buttonlist.step" + _root.stepnum).gotoAndStop(2);
+ changeRouterInformation(_root.stepnum);
+}
+
+function isComputer()
+{
+// trace("StepModeArray[stepNum] = " + StepModeArray[stepNum]);
+ return (_root.routerInfoArray[_root.routerUsedForThisStep[_root.stepnum]].deviceType == "Workstation");
+}
+
+function isNameOnly()
+{
+// trace("StepModeArray[_root.stepnum] = " + StepModeArray[stepnum])
+ return (StepModeArray[stepnum] == "NameOnly")
+}
+
+function changeRouterInformation(num)
+{
+ var rNum = 0;
+
+ rNum = routerUsedForThisStep[num];
+
+ //_root.deebug1 = rNum + ";" + routerInfoArray[rNum].hostName + ";" ;
+
+ _root.rRouterA.run.hostname = routerInfoArray[rNum].hostName;
+
+ //Enable Password
+ _root.rRouterA.run.password = routerInfoArray[rNum].enablePassword;
+
+ //Enable Secret
+ _root.rRouterA.run.secret = routerInfoArray[rNum].enableSecret;
+
+}
\ No newline at end of file |
