summaryrefslogtreecommitdiffstats
path: root/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts')
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/Copy of drillObject.txt1041
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/DeviceModeMatrix.txt45
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_buttons.txt317
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commandline.txt1168
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commands.txt1592
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_history.txt239
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_manual_scrolling.txt176
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_output.txt548
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_password.txt238
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router.txt257
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router_startup.txt173
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_scenario.txt176
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt30
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_utility.txt178
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/answer.txt190
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.bak2.txt1039
-rw-r--r--Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt1067
17 files changed, 8474 insertions, 0 deletions
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/Copy of drillObject.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/Copy of drillObject.txt
new file mode 100644
index 0000000..fb17bca
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/Copy of drillObject.txt
@@ -0,0 +1,1041 @@
+/***********************
+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++)
+ {
+ // go through all the alternate steps
+ for(var i = alternateOffset; (i< AnswerArray[_root.stepnum + matrixOffset].length) && (AnswerArray[_root.stepnum + matrixOffset][i].matrixCheck == true) && (AnswerArray[_root.stepnum+matrixOffset][i].stepnum == AnswerArray[_root.stepnum][i].stepnum); i++)
+ {
+
+ if(matrix[matrixOffset] == false)
+ {
+ 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++)
+ {
+ for(var i =alternateOffset; (i<AnswerArray[_root.stepnum+matrixOffset].length)&&(AnswerArray[_root.stepnum + matrixOffset][i].matrixCheck == true)&&(AnswerArray[_root.stepnum+matrixOffset][i].stepnum == AnswerArray[_root.stepnum][i].stepnum);i++)
+ {
+ if(matrix[matrixOffset] == false)
+ {
+ 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)
+ if(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;
+ }
+ }
+ }
+ if(found == true)
+ {
+ snum = _root.stepnum + matrixOffset;
+ //msgNotice("found =true");
+ alternateOffset = i;
+ break;
+ }
+ }
+ if(found == true)
+ {
+ break;
+ }
+ }
+ }
+
+ // 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 -1)
+ {
+ // 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
+ {
+ errorstring = rptr.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();
+ }
+ }
+ }
+}
+
+
+// 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)
+{
+
+ // miwang
+ 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;
+
+
+ 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 + chapterCovered +"/"+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
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/DeviceModeMatrix.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/DeviceModeMatrix.txt
new file mode 100644
index 0000000..85a2685
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/DeviceModeMatrix.txt
@@ -0,0 +1,45 @@
+
+
+ DEVICE (inFile/onPaper)
+File Mode Router Switch Switch Switch Switch Switch
+ 2600 1900 2950 3550 4006 Sup 2 4006 Sup 3
+ (IOS) (MENU/IOS) (IOS) (IOS) (CLI) (IOS)
+user.fla (>) (1/1) (1/1) (1/1) (1/1) ( /1) (1/1)
+enable.fla (#) (1/1) (1/1) (1/1) (1/1) ( /1) (1/1)
+global.fla (config) (1/1) (1/1) (1/1) ( /1) ( /1) (1/1)
+
+intAsync.fla (async) (1/1) ( / ) ( /1) ( /1) ( / ) ( /1)
+intBri.fla (bri) (1/1) ( / ) ( / ) ( / ) ( / ) ( / )
+intDialer.fla (dialer) (1/1) ( / ) ( /1) ( /1) ( / ) ( /1)
+intE.fla (eth) (1/ ) (1/1) (1/ ) ( / ) ( / ) (1/?)
+intF.fla (fast eth) (1/1) (1/1) (1/1) ( /1) ( / ) ( /1)
+intGig.fla (gig eth) ( / ) ( / ) (1/1) (1/1) ( / ) (1/1)
+intLoopBack.fla (loopback) (1/1) ( / ) (1/1) (1/1) ( / ) (1/1)
+intS.fla (serial) (1/ ) ( / ) (1/ ) ( / ) ( / ) (1/ )
+intATM.fla (ATM) (/)
+
+intVlan.fla (vlan) ( / ) ( / ) (1/1) (1/1) ( / ) (1/1)
+vlanDB.fla (vlan DB) ( / ) ( / ) (1/1) (1/1) ( / ) (1/1)
+vlan.fla (vlan) ( / ) ( / ) (1/1) ( /1) ( / ) ( /1)
+
+linecon.fla (con) (1/1) ( /1) (1/1) (1/1) ( / ) (1/1)
+linevty.fla (vty) (1/1) ( / ) (1/1) (1/1) ( / ) (1/1)
+lineaux.fla (aux) (1/1) ( / ) ( / ) ( / ) ( / ) (1/ )
+ (tty) ( /1) ( / ) ( / ) ( / ) ( / ) ( / )
+
+routerBGP.fla (bgp) (router) (1/1) ( / ) ( / ) ( /1) ( / ) (1/1)
+routerEIGRP.fla (eigrp) (router) (1/1) ( / ) ( / ) (1/1) ( / ) (1/1)
+routerIGRP.fla (igrp) (router) (1/1) ( / ) (1/ ) (1/1) ( / ) (1/1)
+routerRIP.fla (rip) (router) (1/1) ( / ) (1/ ) (1/1) ( / ) (1/1)
+routerOSPF.fla (ospf) (router) (1/1) ( / ) ( / ) (1/1) ( / ) (1/1)
+
+controllerT1.fla (config-controller) (1/1) ( / ) ( / ) ( / ) ( / ) ( / )
+ExtNacl.fla (config-ext-nacl) (1/1) ( / ) (1/1) (1/1) ( / ) (1/1)
+mapClass.fla (config-map-class) (1/1) ( / ) (1/1) (1/1) ( / ) (1/1)
+routerAF.fla (config-router-af) (1/1) ( / ) ( / ) ( / ) ( / ) (1/1)
+subifF.fla (config-subif) (1/1) ( / ) ( /1) ( /1) ( / ) ( / )
+subifS.fla (config-subif) (1/1) ( / ) (1/1) ( /1) ( / ) ( / )
+subifG.fla (config-subif) ( / ) ( / ) ( / ) ( / ) ( / ) ( / )
+timeRange.fla (config-time-range) (1/1) ( / ) (1/1) (1/1) ( / ) (1/1)
+dhcp.fla (dhcp-config) (1/1) ( / ) ( / ) ( / ) ( / ) (1/1)
+routeMap.fla (config-route-map) (1/1) ( / ) ( / ) (1/1) ( / ) (1/1) \ No newline at end of file
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_buttons.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_buttons.txt
new file mode 100644
index 0000000..b3d07ff
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_buttons.txt
@@ -0,0 +1,317 @@
+var btnptr = null;
+
+var bHeight = blank._height;
+var additionalVSpace = 1;
+var clickedButton = 0;
+
+var totalSteps = _root.AnswerArray[_root.AnswerArray.length - 1][0].stepnum;
+
+_root.ShowMe._visible = false;
+
+
+populateTopic();
+menuInitialize();
+
+//making the first step as default
+_root.stepnum = 0;
+_root.showInstruction(_root.stepnum);
+_root.loadImage(_root.stepnum,null); // no previous image
+clickedButton = _root.stepnum;
+//eval("blank.buttonlist.step" + _root.stepnum).gotoAndStop(2);
+
+
+// initialize device select buttons
+//initializeDeviceButtons();
+function initializeDeviceButtons()
+{
+ /* Don't run this function since we don't have any more devices to initialize...
+ Dont't waste CPU cycles
+ device0.deviceName = routerInfoArray[0].hostName;
+ device0.deviceNum = 0;
+ device0.gotoAndStop(2);
+
+ for (var i=1; i<routerInfoArray.length; i++)
+ {
+ device0.duplicateMovieClip("device" + i, 6000 + i);
+ eval("device" + i).deviceName = routerInfoArray[i].hostName;
+ eval("device" + i).deviceNum = i;
+ eval("device" + i)._x = device0._x + device0._width * i;
+ }
+ */
+}
+
+
+
+function menuInitialize()
+{
+ var numOfSteps = AnswerArray.length - 1;
+
+ // if we have more than 24 buttons, we have to allow for scroll, otherwise turn it off
+ if (totalSteps <= 15)
+ scrollDisable();
+
+ blank.buttonlist.attachMovie("stepblock","stepblock","8000");
+
+ // miwang
+ AnswerArray[0][0].stepnum = 0;
+ var j = 0;
+ blank.buttonlist.attachMovie("step","step" + j, j);
+ eval("blank.buttonlist.step" + j).text = j;
+ eval("blank.buttonlist.step" + j).num = 0;
+ eval("blank.buttonlist.step" + j)._y = j * (eval("blank.buttonlist.step" + j)._height + additionalVSpace);
+ j++;
+
+ for (i = 1; i <= numOfSteps; i++)
+ {
+trace("i=" + i + ", j=" + j);
+ // miwang
+ // if step number is different from the previous element's, then add new button
+ if (AnswerArray[i][0].stepnum != AnswerArray[i-1][0].stepnum)
+ {
+ blank.buttonlist.attachMovie("step","step" + j, j);
+ eval("blank.buttonlist.step" + j).text = j;
+ eval("blank.buttonlist.step" + j).num = i;
+
+ eval("blank.buttonlist.step" + j)._y = j * (eval("blank.buttonlist.step" + j)._height + additionalVSpace);
+
+ j++;
+ }
+ }
+
+ _root.coverButton(0);
+ /*
+ additionalHSpace = 12;
+ for (i = 0; i <= totalSteps; i++)
+ {
+ // Once we hit 24, we need to start a new column of buttons
+ if (i == 24)
+ {
+ bHeight = 0;
+ }
+
+ if (i < 24)
+ {
+ blank.attachMovie("step", "step" + i, i);
+ eval("blank.step" + i).text = i;
+
+ eval("blank.step" + i)._y = bHeight;
+ bHeight = blank._height + additionalVSpace;
+ }
+ else
+ {
+ blank.attachMovie("step", "step" + i, i);
+ eval("blank.step" + i).text = i;
+
+ eval("blank.step" + i)._y = bHeight;
+ bHeight += eval("blank.step" +i)._height + additionalVSpace;
+ eval("blank.step" + i)._x = additionalHSpace;
+ }
+ }
+ */
+}
+
+function scrollDisable()
+{
+ blank.scrollUp._visible = false;
+ blank.scrollDown._visible = false;
+ blank.scrollbar._visible = false;
+}
+
+function stepscrollUp()
+{
+//trace("buttonlist _y = " +blank.buttonlist._y);
+//trace("buttonlist _height = " + blank.buttonlist._height);
+//trace("buttonlist _y + _height = " + (blank.buttonlist._y + blank.buttonlist._height));
+
+//trace("blank _y = " +blank._y);
+//trace("blank _height = " + blank._height);
+//trace("blank _y + _height = " + (blank._y + blank._height));
+ if (blank.buttonlist._y <= -12)
+ {
+ blank.buttonlist._y = blank.buttonlist._y + 12;
+ step_setSlider(blank.buttonlist);
+ }
+}
+
+function stepscrollDown()
+{
+//trace("buttonlist _y = " +blank.buttonlist._y);
+//trace("buttonlist _height = " + blank.buttonlist._height);
+//trace("buttonlist _y + _height = " + (blank.buttonlist._y + blank.buttonlist._height));
+
+trace("blank _y = " +blank._y);
+trace("blank _height = " + blank._height);
+trace("blank _y + _height = " + (blank._y + blank._height));
+
+ if (blank.buttonlist._y +blank.buttonlist._height > 259)
+ {
+ blank.buttonlist._y = blank.buttonlist._y - 12;
+ step_setSlider(blank.buttonlist);
+ }
+}
+
+function step_setScroll(slider)
+{
+ //trace("Y = " +slider._y);
+
+
+ _root.blank.buttonlist._y = (1-(slider._y/450) * (_root.blank.buttonlist._height-271.4));
+ trace("buttonlist Y = " + _root.blank.buttonlist._y);
+}
+
+function step_setSlider(buttonlist)
+{
+ //trace("Y = " +slider._y);
+ //trace("buttonlist Y = " + _root.menu.buttonlist._y);
+
+ _root.blank.scrollbar.slider._y = (425 * ((Math.abs(_root.blank.buttonlist._y))/(_root.blank.buttonlist._height-271.4)));
+ trace("buttonlist._y = " + _root.blank.buttonlist._y);
+ trace("buttonlist._height = " + _root.blank.buttonlist._height);
+ trace("scrollbar slider._y = " + _root.blank.scrollbar.slider._y);
+ trace("scrollbar._height = " + _root.blank.scrollbar._height);
+}
+
+function stepClick(text)
+{
+ // reset the matrix check array
+ matrix = null;
+ var prevStep = _root.stepnum; // THIS is important for remembering the previous step.
+
+ //check to see if he has clicked on the same step
+ i = Number(text);
+ if (_root.stepnum == i)
+ {
+ matrix = null;
+ _root.showInstruction(_root.stepnum);
+ return;
+ }
+ clickedButton = i;
+ _root.stepnum = i;
+
+ //begin loading the images is done here
+ _root.loadImage(_root.stepnum, prevStep);
+ //end loading the images is done here
+
+ //check to see if the answer button is clicked if so then display the answer
+ if (showAns == true)
+ {
+ //if it step zero then reset everything
+ if (i > 0)
+ {
+ showAnswer(i);
+ }
+ else
+ {
+ _root.showInstruction(_root.stepnum);
+ answerInitialize(false);
+ _root.exitRouter();
+ _root.menu.DoneButton.gotoAndPlay("Show");
+ showAns = false;
+ _root.ShowMe._visible = false;
+
+ // miwang
+ _root.coverButton(0);
+ }
+ }
+ else
+ {
+ _root.goToNextStep(_root.stepnum, prevStep);
+
+ //add for step 0
+ _root.showInstruction(_root.stepnum);
+ if (_root.stepnum == 0)
+ {
+ _root.exitRouter();
+ }
+ else
+ {
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+ rptr.lineIndexCounter = 0;
+
+ _root.commandline_setMode(_root.stepModeArray[_root.stepnum], _root.active_router);
+ output_write("\n");
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_commandLine();
+ }
+ }
+}
+
+function coverButton(step)
+{
+ blank.buttonlist.stepblock._visible = true;
+ blank.buttonlist.stepblock._x = eval("blank.buttonlist.step" + step)._x;
+ blank.buttonlist.stepblock._y = eval("blank.buttonlist.step" + step)._y;
+ blank.buttonlist.stepblock.text = step;
+}
+
+function stepRollOver()
+{
+/*
+ x = _xmouse;
+ y = _ymouse;
+
+ for (i = 0; i <= totalSteps; i++)
+ {
+ found = eval("blank.buttonlist.step" + i).hitTest (x, y, false);
+ if (found)
+ {
+ eval("blank.buttonlist.step" + i).gotoAndStop(2);
+ }
+ }
+ */
+}
+
+
+
+
+function stepRollOut()
+{
+/*
+ x = _xmouse;
+ y = _ymouse;
+
+ for (i = 0; i <= totalSteps; i++)
+ {
+ found = eval("blank.buttonlist.step" + i).hitTest (x, y, false);
+ if (!found)
+ {
+ if (i != clickedButton)
+ eval("blank.buttonlist.step" + i).gotoAndStop(1);
+ }
+ }
+ */
+}
+
+
+function exitRouter()
+{
+ // normal exit
+ var r = eval("_root.r" + _root.active_router);
+ output_write("\n");
+ r.userHistory = new Array();
+ r.configHistory = new Array();
+ _root.commandline_changeProcess("router_startup_processStartUp");
+ eval("_root.r" + _root.active_router + ".router_startup") = false; // forcing to be restarted
+ router_startup_checkStartUp();
+ _root.disableAllSteps()
+}
+
+
+function disableAllButtons()
+{
+/*
+ for (i = 1; i <= totalSteps; i++)
+ {
+ eval("blank.buttonlist.step" + i)._visible = false;
+ } */
+ blank.buttonlist.stepblock._visible = false;
+}
+
+
+function populateTopic()
+{
+ _root.menu.topicCovered = _root.chapterCovered ;
+ if (_root.wantShowTopology == false)
+ _root.menu.TopologyButton._visible = false;
+
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commandline.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commandline.txt
new file mode 100644
index 0000000..468987f
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commandline.txt
@@ -0,0 +1,1168 @@
+// Modified by Dean Wood 05.10.01
+// Changed hard-coded 7s to cursorXOffset
+
+
+// ***** process (int) *****
+// IN: 1 integer representing the keycode of a key pressed
+// DO: process the key by calling other functions
+// NOTE:
+// process is a global variable name. it can be assigned with another function name.
+// that means process is a pointer variable to other functions.
+// ie, the following line, when the key capturing event calls process(keycode),
+// it will call the router_startup_processStartUp() function.
+
+var process = router_startup_processStartUp;
+var processName = new String("router_startup_processStartUp"); // a global variable storing which function is currently pointed by process.
+
+var doneIsWaiting = false;
+
+// ***** commandline_changeProcess (str) *****
+//IN: p = string, name of a function (next process to run)
+//DO: assign this function to the process 'p'
+//OUT: <none>
+function commandline_changeProcess(p) {
+/*
+ if (doneIsWaiting)
+ {
+ doneIsWaiting = false;
+ p = "";
+ _root.active_router.hostname = ""
+ msgNotice("\nCongratulations !!!!!\nYou have Successfully Completed the Lab-Drill Excercise\n")
+ }
+*/
+ processName = p;
+
+ //the current process is set to the 'p' process
+ eval("_root.r" + _root.active_router + ".processCurrent") = p;
+ process = eval(p);
+}
+
+
+
+
+// ***** commandline_processCommandLine(int) *****
+//IN: keycode = int, represents the keycode of a key pressed
+//
+// NOTE: This is the most common process function because the user is at
+// the command line most of the time.
+//DO: process a key entered at the command line
+function commandline_processCommandLine(keycode) {
+
+ //special keycodes temporarily defined
+ var KEY_CTRL = -10;
+ var KEY_TAB = -11;
+
+
+ //this.controlCharPressed = 0;
+ //this.lineIndexCounter = 0;
+
+
+ // use this as a pointer to the visible router object
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // use this as a pointer to the active router object
+ var rptr2 = eval("_root.r" + _root.active_router);
+
+ //resets the more function scroll; tells the more function to count
+ //the number of lines printed starting from the line when this
+ //function is called
+ rptr.scrollStartLine = rptr.lastDLine - 23;
+
+ //output_write("keycode="+keycode);
+ //output_write("!switch="+rptr.controlCharPressed);
+
+ if (rptr.controlCharPressed == 0) {
+
+ if (keycode == KEY_CTRL) {
+
+ //<Ctrl> key is pressed
+
+ //set the rptr.controlCharPressed switch so that the
+ //next key to be pressed, becomes part of a
+ //<Ctrl>-something sequence
+ rptr.controlCharPressed = 1;
+ return;
+
+ } else {
+
+ //the key pressed was anything but <Ctrl>, so
+ //interpret the keypress like normal
+
+
+ if (keycode == 8) {
+
+ //BACKSPACE detected: delete 1 character if
+ //the input is longer than 0.
+
+
+ if (rptr.lineIndexCounter > 0) {
+ //we only need to delete a character if there are
+ //characters to delete. if lineIndexCounter is <= 0,
+ //then there are no characters on the command line
+ //input!
+
+
+ if (rptr.INPUT.length == rptr.lineIndexCounter) {
+ //the cursor is at the end of the commandline
+ //input. no need to do anything special to
+ //remove it
+
+ //erase last character position and adjust rptr.lineIndexCounter
+ rptr.INPUT = rptr.INPUT.substring(0,rptr.INPUT.length-1);
+
+ //Move the rptr.lineIndexCounter one postion to the left to
+ //account for removed character
+ rptr.lineIndexCounter -=1;
+
+ //actually erase one character from the line
+ //buffer as well, and reprint the commandline
+ output_erase(1);
+
+ } else {
+ //cursor is not at the end of the command line input,
+ //we need to delete from some other part of it.
+
+ //decrement the cursor pointer
+ rptr.lineIndexCounter -=1;
+
+ //remove the character denoted by 'rptr.lineIndexCounter'
+ //from the command line input string
+ rptr.INPUT = rptr.INPUT.substr(0,rptr.lineIndexCounter)+rptr.INPUT.substr(rptr.lineIndexCounter+1,rptr.INPUT.length+1-rptr.lineIndexCounter);
+
+ //remove the correct character from the output buffer
+ //and reprint the output buffer to the Hyperterminal window
+ var grab = rptr.lineIndexCounter + rptr.PROMPT.length;
+ rptr.line[rptr.lastLine] = rptr.line[rptr.lastLine].substr(0,grab) + rptr.line[rptr.lastLine].substr(grab+1,rptr.line[rptr.lastLine].length+1-grab);
+ output_write();
+
+ //move the cursor over one character to the left
+ //to account for the deleted character
+ rptr.cursorX = rptr2.PROMPT.length + rptr.lineIndexCounter;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+ }
+
+ } //end if(rptr.lineIndexCounter > 0)
+
+
+ } else if (keycode == 13) {
+
+ //ENTER detected--the command entry is finished. now,
+ //the entire current command line string is to be parsed...
+ //...reset the cursor pointer, as well.
+
+ rptr.lineIndexCounter = 0;
+ commandline_parseCommandLine(1,1);
+ } else if (keycode == -1) {
+
+ //we are returning from a popup box display, so no
+ //newline needed when the next prompt is
+ //printed (0 is the flag value)
+ rptr.lineIndexCounter = 0;
+ rptr.HELPING = false;
+ commandline_parseCommandLine(0,1);
+
+ } else if (keycode == KEY_TAB) {
+
+ //<TAB> detected
+
+ //prevent the Flash projector
+ //from "stealing" the tab
+ Selection.setFocus(_root.Menu.tabAbsorb);
+
+ //try to match the current command line
+ //input to existing commands..
+ commands_tabCompleteCommand(eval(rptr2.MODE+"C"), rptr.INPUT);
+
+ } else {
+
+ //all other keys
+ //begin for the configuration mode of the routers -- suresh
+ //if the user is in the erase command then what ever character the user presses
+ //it is checked and action is performed
+ if ( eval("config" + _root.active_router) == "erase"){
+ eval("config" + _root.active_router) = "normal"; //resetting the mode back to normal
+ output_write("\n");
+ rptr.lineIndexCounter = 0;
+ //checking if the user presses y or Y
+ if (keycode == 121 || keycode == 89)
+ COMMAND[0] = "y";
+ else
+ COMMAND[0] = "n";
+ processErase();
+ rptr.INPUT = "";
+ commandline_parseCommandLine(0,0);
+ return;
+ }
+ //end for the configuration mode of the routers -- suresh
+ if (keycode == 63)
+ {
+ if (!isComputer() && !isNameOnly())
+ {
+ //'?' detected
+
+ //print the key that was pressed out to the console
+ output_write(chr(keycode));
+
+ //the user pressed "?", then turn on HELPING.
+ rptr2.HELPING = true;
+ commandline_parseCommandLine(1,1);
+ }
+ else if(isComputer())
+ {
+ // When the user is on a computer, please make them know there are no ? help
+ errorNotice("On workstations, there are no '?' help commands. Supported commands: ping, tracert, telnet");
+ }
+ else if(isNameOnly())
+ {
+ }
+
+ } else if (rptr.INPUT.length == rptr.lineIndexCounter) {
+ //the cursor is at the end of the commandline,
+ //so just append this new incoming character to
+ //the end of the commandline input
+
+ //print the key that was pressed out to the console
+ output_write(chr(keycode));
+
+ //add the character pressed to the router's
+ //input buffer
+ rptr.INPUT += chr(keycode);
+
+ //update the cursor pointer
+ rptr.lineIndexCounter += 1;
+
+ } else {
+
+ //the cursor is somewhere in the middle of the
+ //current command line input (at location 'rptr.indexLineCounter').
+ //this new key that was pressed must be inserted into the
+ //commandline input at the specified location.
+
+
+ //add the character to the middle of the
+ //command line input buffer
+ rptr.INPUT = rptr.INPUT.substr(0,rptr.lineIndexCounter) + chr(keycode) + rptr.INPUT.substr(rptr.lineIndexCounter,rptr.INPUT.length+1-rptr.lineIndexCounter);
+
+ //add the character to the middle of the
+ //output buffer
+ var grab = rptr.lineIndexCounter + rptr.PROMPT.length;
+ rptr.line[rptr.lastLine] = rptr.line[rptr.lastLine].substr(0,grab) + chr(keycode) + rptr.line[rptr.lastLine].substr(grab,rptr.line[rptr.lastLine].length+1-grab);
+
+ //update the display with the new character
+ //inserted somewhere in the middle...
+ output_write();
+//trace("LINE INDEX COUNTER = " + rptr.lineIndexCounter);
+ //reposition the cursor to accomodate for the added character
+ rptr.cursorX = rptr.PROMPT.length + rptr.lineIndexCounter + 1;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+
+ //increment the cursor pointer
+ rptr.lineIndexCounter +=1;
+
+ } //end if (keycode == 63)
+
+ } //end keycode if-else-if chain
+
+ } //end if (keycode == 17) else..
+
+ } else { //if (rptr.controlCharPressed == 0)
+
+ //this part of the if-else block executes if the <Ctrl> key
+ //has been pressed--the next character matched will complete
+ //a control key sequence to be interpreted as a command
+ //
+ //currently supported control sequences:
+ //-----------------------------------------------------------
+ //<Ctrl-b> = move cursor one character to the left
+ //<Ctrl-f> = move cursor one character to the right
+ //<Ctrl-a> = move cursor to beginning of command line input
+ //<Ctrl-e> = move cursor to end of command line input
+ //<Ctrl-z> = shortcut for "end" (exits config modes)
+ //<Ctrl-p> = move to prev line in the command history
+ //<Ctrl-n> = move to next line in the command history
+ //<Ctrl-c> = [currently not implemented]
+
+
+ //reset the control character switch
+ rptr.controlCharPressed = 0;
+
+ //the following if-else-if.. block interprets the second half
+ //of the control key sequence:
+ //
+ if ((keycode == 98) || (keycode == 66)) {
+
+ //<Ctrl-b> or <Ctrl-B> detected
+
+ //move cursor one character left
+ commandline_arrowLeft();
+
+
+ } else if ((keycode == 102) || (keycode == 70)) {
+
+ //<Ctrl-f> or <Ctrl-F> detected
+
+ //move cursor one character right
+ commandline_arrowRight();
+
+
+ } else if ((keycode == 97) || (keycode == 65)) {
+
+ //<Ctrl-a> or <Ctrl-A> detected
+ //move to beginning of input line
+
+ //set cursor pointer to the beginning of the
+ //current command line input string
+ rptr.lineIndexCounter = 0;
+
+ //move the cursor to the beginning of the
+ //command line input string
+ rptr.cursorX = rptr.PROMPT.length;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+
+
+ } else if ((keycode == 101) || (keycode == 69)) {
+
+ //begin commented for template
+ /*
+ //<Ctrl-e> or <Ctrl-E> detected
+ //move to end of input line
+
+ //set cursor pointer to the length of the
+ //current command line input string (the end
+ //of the command line input string)
+ rptr.lineIndexCounter = rptr.INPUT.length;
+
+ //move the cursor to the end of the
+ //command line input string
+ rptr.cursorX = rptr.PROMPT.length + rptr.INPUT.length;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+ */
+ //end commented for template
+
+
+ } else if ((keycode == 122) || (keycode == 90)) {
+
+ //<Ctrl-z> or <Ctrl-Z> detected
+
+ //exits configuration mode, or any of
+ //the configuration submodes
+ //begin commented for template
+ /*if (!((rptr2.MODE == "user") || (rptr2.MODE == "enable"))) {
+
+ //this if-statement only executes if the user
+ //is in configuration mode, or in one of the
+ //configuration submodes (i.e. not in user or
+ //enable mode)
+
+ //substitute the "end" command into the input line
+ rptr.INPUT = "end";
+
+ //do commandline parse and execution--the 0 flag
+ //denotes that this "end" command wont be stored
+ //in the command history
+ commandline_parseCommandLine(1,0);
+ }
+ */
+ //end commented for template
+
+
+ } else if ((keycode == 112) || (keycode == 80)) {
+
+ //<Ctrl-p> or <Ctrl-P> detected
+
+ //move to previous line in command history (same
+ //routine as pressing up arrow
+ _root.history_historyBackward();
+
+
+ } else if ((keycode == 110) || (keycode == 78)) {
+
+ //<Ctrl-n> or <Ctrl-N> detected
+
+ //move to next line in command history (same
+ //routine as pressing down arrow)
+ _root.history_historyForward();
+
+
+ } else if ((keycode == 99) || (keycode == 67)) {
+
+ //<Ctrl-c> or <Ctrl-C> detected
+
+ //'break'--this will put user in common mode
+ //if issues right after reload command.
+
+ //not implemented yet..
+
+
+ } else {}
+
+
+ } //if (rptr.controlCharPressed == 0)
+
+}
+
+
+
+//*** commandline_arrowLeft()
+//IN: <none>
+//DO: moves the cursor one character to the left
+//OUT: <none>
+//
+function commandline_arrowLeft() {
+
+ //move cursor one character left
+
+
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ if (rptr.lineIndexCounter > 0) {
+
+ //if characters exist to back up to (>0),
+ //then back up the pointer one character.
+ rptr.lineIndexCounter -= 1;
+
+ //move the cursor one character
+ //backward on the screen
+ rptr.cursorX -= 1;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+
+ }
+}
+
+
+
+//*** commandline_arrowRight()
+//IN: <none>
+//DO: moves the cursor one character to the right
+//OUT: <none>
+//
+function commandline_arrowRight() {
+
+ //move cursor one character to the right
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ if (rptr.lineIndexCounter < rptr.INPUT.length) {
+
+ //if the cursor isn't all the way to the
+ //end of the commandline text, then
+ //move it one position to the right
+ rptr.lineIndexCounter +=1;
+
+ //move the cursor one character
+ //forward on the screen
+ rptr.cursorX += 1;
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+ }
+}
+
+
+// ***** commandline_parseCommandLine(int flag_prNewline, int flag_storeInHist)
+//IN: flag_prNewline = int, flag whether or not to print a newline
+// before the current command is parsed/interpreted
+// (1 prints the newline, 0 does not).
+// 2 = perfect config hack
+// flag_storeInHist = int, flag that determines whether or not to
+// add this command to the command history
+// (1 adds to history, 0 does not).
+// rptr.INPUT = the command line input string
+//DO: split up the command line input into an array with multiple elements.
+// each element is a word separated by one or more spaces at the command line.
+// The commands_useCommand function to interpret the input...
+//OUT: <none>
+function commandline_parseCommandLine(flag_prNewline, flag_storeInHist) {
+
+ // use this as a pointer to the visible router object
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // use this as a pointer to the active router object
+ var actrptr = eval("_root.r" + _root.active_router);
+
+ //separate the command line input (rptr.INPUT) into different words,
+ //using the space " " as a delimiter. COMMAND is an array of strings,
+ //the individual words
+ COMMAND = rptr.INPUT.split(" ");
+ for (var i = 0; i < COMMAND.length; i++) {
+
+ //removes the empty "" elements from
+ //the COMMAND array
+ if (COMMAND[i] == "") {
+ COMMAND.splice(i,1);
+ i--;
+ }
+ }
+
+
+ if (flag_prNewline == 1) {
+ //if 'flag_prNewline' is 1, print a newline.
+ output_write("\n");
+ }
+
+ //if the input command is not empty or "?" is pressed
+ if ((COMMAND.length != 0) || (actrptr.HELPING == true)) {
+
+
+ //if "?" WASN'T pressed, store this input command
+ //line to the history buffer
+ if (actrptr.HELPING == false) {
+
+ //if 'flag_storeInHist' is 1,
+ //store this command in
+ //the history buffer
+ if (flag_storeInHist == 1) {
+ history_setHistory();
+ }
+
+ }
+ //begin for the configuration mode of the routers -- suresh
+ //checking if the user is in any of the commands like "config", "erase",
+ //"start", "run" or "telnet"
+ // reason is :- if the user types any of the above command then the corresponding
+ //question has to be asked. since for every key pressed it comes to this function
+ //we are checking for these commands when the user enters something after these commands
+ //were shown.
+ //we can acheive the same functionality by changing the process. But then we need to
+ //check for every key pressed in all of the process.
+
+ if ( eval("config" + _root.active_router) == "normal"){
+ //"use" this command (interpret the commandline input)
+ //trace((eval(actrptr.MODE+"C")).toString());
+ var returnvalue = commands_useCommand(eval(actrptr.MODE+"C"), 0);
+ //calling the processStep function of the lab-drill -- suresh
+ processStep(stepnum,returnvalue);
+ }
+ else if ( eval("config" + _root.active_router) == "config"){
+ eval("config" + _root.active_router) = "normal";
+ processConfig(eval(actrptr.MODE+"C")["configure"]);
+ }
+ else if ( eval("config" + _root.active_router) == "erase"){
+ eval("config" + _root.active_router) = "normal";
+ processErase();
+ }
+ else if ( eval("config" + _root.active_router) == "start"){
+ eval("config" + _root.active_router) = "normal";
+ copyStartupToRun();
+ }
+ else if ( eval("config" + _root.active_router) == "run"){
+ eval("config" + _root.active_router) = "normal";
+ copyRunToStartup();
+ }
+ else if ( eval("config" + _root.active_router) == "telnethost"){
+ eval("config" + _root.active_router) = "normal";
+ doTelnet();
+ }
+ //end for the configuration mode of the routers -- suresh
+ }
+ else if ( eval("config" + _root.active_router) == "config") {
+ //begin for the configuration mode of the router -- suresh
+ eval("config" + _root.active_router) = "normal";
+ processConfig(eval(actrptr.MODE+"C")["configure"]);
+ }
+ else if ( eval("config" + _root.active_router) == "erase") {
+ //begin for the configuration mode of the router -- suresh
+ eval("config" + _root.active_router) = "normal";
+ processErase();
+ }
+ else if ( eval("config" + _root.active_router) == "start") {
+ //begin for the configuration mode of the router -- suresh
+ eval("config" + _root.active_router) = "normal";
+ copyStartupToRun();
+ }
+ else if ( eval("config" + _root.active_router) == "run") {
+ //begin for the configuration mode of the router -- suresh
+ eval("config" + _root.active_router) = "normal";
+ copyRunToStartup();
+ }
+ else if ( eval("config" + _root.active_router) == "telnethost"){
+ eval("config" + _root.active_router) = "normal";
+ doTelnet();
+ }
+ //end for the configuration mode of the router -- suresh
+
+
+
+ //if the process is "commandline_processCommandLine",
+ //then print the command line.
+ if (processName == "commandline_processCommandLine")
+ commandline_commandLine();
+}
+
+
+
+
+// ***** commandline_commandLine() *****
+//IN: rptr.PROMPT, the command line prompt
+// rptr.INPUT, the command line input
+//DO: echo the command line prompt to the console
+//OUT: the command line prompt is printed to the screen
+function commandline_commandLine() {
+
+ // use this as a pointer to the active router object
+ var rptr = eval("_root.r" + _root.active_router);
+
+ var rptr2 = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ //print out the current prompt
+ output_write(rptr.PROMPT);
+
+
+ if (rptr.HELPING == true) {
+
+ //HELPING is on (==true), that means "?" has been pressed. the
+ //command line will show the input of the last input before "?".
+ // else, clear the input
+ rptr.HELPING = false;
+ output_write(rptr2.INPUT);
+ } else {
+
+ //the command line prompt has been printed, and is ready for the
+ //next command from the user--clear the input buffer to prepare
+ //for the next command to be typed.
+ rptr2.INPUT = "";
+ }
+
+ //reset the COMMAND array, which will be used to hold the next
+ //command line input that is parsed
+ COMMAND = new Array();
+}
+
+
+
+
+// commandline_setMode(arg1, arg2)
+//IN: arg1 = string, the new mode to change the router to
+// arg2 = string, router name in which to change the mode
+//DO: Changes the current mode to the new mode
+//OUT: the current mode is changed to 'newMode' on the 'rtrName' router,
+// and the command prompt will change to the reflect the new mode
+function commandline_setMode(arg1, arg2) {
+
+ var rptr = eval("_root.r" + arg2); //pointer to router that will
+ //get its mode changed
+
+// *********** for loading command arrays *******
+ //trace("stepnum " + _root.stepnum);
+ var stepDevice = _root.routerInfoArray[_root.routerUsedForThisStep[_root.stepnum]].deviceType;
+ //trace("device for this step: " + stepDevice);
+ if (eval("_root.loadedCommands." + arg1) != stepDevice)
+ {
+ eval("_root.loadedCommands." + arg1) = stepDevice;
+ //trace("loading " + stepDevice + "/" + arg1 + ".swf");
+
+ eval("_root." + arg1 + "C") = new Array();
+
+
+ tellTarget("CommandLoad")
+ {
+ loadMovie(_level0.EngineDir + stepDevice + "/" + arg1 + ".swf", _root.CommandLoad);
+ }
+
+ }
+// ***********************************************
+
+
+ //holds the string that is the new prompt
+ var p = "";
+
+ if (arg1 == "user") {
+
+ if (deviceUsed != "Switch 4006 Sup 2")
+ p = ">";
+ else
+ p = "> ";
+
+ } else if (arg1 == "enable") {
+
+ if (deviceUsed != "Switch 4006 Sup 2")
+ p = "#";
+ else
+ p = "> (enable) ";
+
+ } else if (arg1 == "global") {
+
+ p = "(config)#";
+
+ }
+
+ else if (arg1.substr(0, 3) == "int") {
+ p = "(config-if)#";
+ }
+
+ else if (arg1.substr(0, 3) == "sub") {
+ p = "(config-subif)#";
+ }
+
+ else if (arg1.substr(0, 4) == "line") {
+ p = "(config-line)#";
+ }
+
+ else if (arg1.substr(0, 6) == "router") {
+ p = "(config-router)#";
+ }
+
+ else if (arg1.indexOf("controller") == 0) {
+ p = "(config-controller)#";
+ }
+
+ else if (arg1 == "extNacl") {
+ p = "(config-ext-nacl)#";
+ }
+
+ else if (arg1 == "mapClass") {
+ p = "(config-map-class)#";
+ }
+
+ else if (arg1 == "timeRange") {
+ p = "(config-time-range)#";
+ }
+
+ else if (arg1 == "dhcp") {
+ p = "(dhcp-config)#";
+ }
+
+ else if (arg1 == "routeMap") {
+ p = "(config-route-map)#";
+ }
+
+ else if (arg1 == "classMap") {
+ p = "(config-cmap)#";
+ }
+
+ else if (arg1 == "policyMap") {
+ p = "(config-pmap)#";
+ }
+
+ else if (arg1 == "policyMapClass") {
+ p = "(config-pmap-c)#";
+ }
+
+ else if (arg1 == "vlanDB") {
+ p = "(vlan)#";
+ }
+ else if (arg1 == "ATMPVC") {
+ p = "(config-if-atm-vc)#";
+ }
+ else if (arg1 == "DOS")
+ {
+ p = " C:\\>";
+ }
+ else if (arg1 == "NameOnly")
+ {
+ p = "";
+ }
+
+ //set the new prompt and mode on the router in question
+ rptr.PROMPT = rptr.run.hostname + p;
+ rptr.MODE = arg1;
+}
+
+
+
+
+// ***** commandline_matchKey(int, char) *****
+//IN: keycode = int, representing the keycode of the key pressed
+// letter = char, 1 character
+//DO: determines if given 'keycode' represents the character 'letter'
+//OUT: true = if character represented by 'keycode' matches 'letter'
+// false = no match
+function commandline_matchKey(keycode, letter) {
+
+ return (chr(keycode).toUpperCase() == letter.toUpperCase());
+}
+
+
+
+//begin for the configuration mode of the routers -- suresh
+
+// ***** processConfig(commandArray) *****
+//IN: commandArray = array, representing all the options under the configure mode
+//DO: determines if the parameter given for the configure mode is one of its valid option
+
+function processConfig(commandArray)
+{
+ var rptr = eval("_root.r" + _root.active_router);
+ var arrayptr = eval(rptr.MODE + "C")["configure"];
+
+ //if the user did not type any option then by default the terminal option is chosen
+ if (COMMAND.length == 0)
+ COMMAND[0] = "terminal";
+
+ for (var i=0; i<commandArray.length; i++) {
+ if (COMMAND[0].toLowerCase() == commandArray[i].substring(0,COMMAND[0].length).toLowerCase()) {
+
+ //if for the option there is a .enter function then execute it
+ if (typeof(arrayptr[commandArray[i]].enter) == "function") {
+ arrayptr[commandArray[i]].enter();
+ }
+ else {
+ rptr.PROMPT = rptr.run.hostname + "#";
+ }
+
+ return;
+ }
+ }
+ output_write("?Must be 'terminal', 'memory' or 'network'");
+ output_write("\n");
+ rptr.PROMPT = rptr.run.hostname + "#";
+
+}
+
+//end for the configuration mode of the routers -- suresh
+
+
+//begin for the configuration mode of the routers -- suresh
+
+// ***** processrase() *****
+//DO: Erases the startup configuration of the active router
+
+function processErase()
+{
+ //if the user did not type any option then by default the terminal option is chosen
+
+ if (COMMAND.length == 0)
+ COMMAND[0] = "y";
+
+ if (COMMAND[0].toLowerCase() == "y") {
+ eval("_root.r" + _root.active_router + ".eraseFlag") = false;
+ if(_root.active_router == "RouterA") {
+
+ //re-set the values
+ rptr = eval("_root.rRouterA.startup_file");
+ rptr.e0.exist = true;
+ rptr.e1.exist = true;
+ rptr.s0.exist = true;
+ rptr.hostname = "Router";
+ rptr.secret = "";
+ rptr.password = "";
+ } else if(_root.active_router == "RouterB"){
+
+ //re-set the values
+ rptr = eval("_root.rRouterB.startup_file");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+ rptr.hostname = "Router";
+ rptr.secret = "";
+ rptr.password = "";
+
+ } else if(_root.active_router == "RouterC"){
+
+ //re-set the values
+ rptr = eval("_root.rRouterC.startup_file");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+ rptr.hostname = "Router";
+ rptr.secret = "";
+ rptr.password = "";
+
+ } else if(_root.active_router == "RouterD"){
+
+ //re-set the values
+ rptr = eval("_root.rRouterD.startup_file");
+ rptr.e0.exist = true;
+ rptr.s1.exist = true;
+ rptr.hostname = "Router";
+ rptr.secret = "";
+ rptr.password = "";
+ } else if(_root.active_router == "RouterE"){
+
+ //re-set the values
+ rptr = eval("_root.rRouterE.startup_file");
+ rptr.e0.exist = true;
+ rptr.hostname = new String("Router");
+ rptr.secret = new String("");
+ rptr.password = new String("");
+ }
+ output_write("PAUSE\n");
+ output_write("[OK]\n");
+ output_write("Erase of nvram: complete");
+ output_write("\n");
+ }
+ var temprptr = eval("_root.r" + _root.active_router);
+ temprptr.PROMPT = temprptr.run.hostname + "#"; //re-set the prompt
+
+}
+
+//end for the configuration mode of the routers -- suresh
+
+//begin modified by suresh as in router 2500 OS 12.0
+// ***** copyRunToStartup() *****
+//DO: copies the running configuration to the startup configuration of the active router
+function copyRunToStartup()
+{
+ var rptr = eval("_root.r" + _root.active_router);
+ //if the user did not type any option then by default the startup-config option is chosen
+ if (COMMAND.length == 0)
+ COMMAND[0] = new String("startup-config");
+ if (COMMAND[0] == "startup-config") {
+
+ with(eval("_root.r" + _root.active_router))
+ {
+ output_write("Building configuration...\n", "PAUSE\n");
+ eraseFlag = true;
+ startup_file.line.con_login = run.line.con_login; // console login
+ startup_file.line.con_password = run.line.con_password; //console password
+ startup_file.line.aux_login = run.line.aux_login; // aux login
+ startup_file.line.aux_password = run.line.aux_password; //aux password
+ startup_file.line.vty_login = run.line.vty_login; //virtual terminal login
+ startup_file.line.vty_password = run.line.vty_password; //virtualterminal password
+
+ //global configuration
+
+ // RIP
+ startup_file.global.RIP = run.global.RIP;
+ startup_file.global.RIP_network = new Array();
+ for (var i=0; i<run.global.RIP_network.length; i++)
+ startup_file.global.RIP_network[i] = run.global.RIP_network[i];
+
+ // IGRP
+ startup_file.global.IGRP = run.global.IGRP;
+ startup_file.global.IGRP_network = new Array();
+ for (var i=0; i<run.global.IGRP_network.length; i++)
+ {
+ startup_file.global.IGRP_network[i] = new Array();
+ for (var j=0; j<run.global.IGRP_network[i].length; j++)
+ startup_file.global.IGRP_network[i][j] = run.global.IGRP_network[i][j];
+ }
+
+
+ //ip host table
+ startup_file.global.ipHostNameTable = new Array();
+ startup_file.global.ipHostAddressTable = new Array();
+ for (var i=0; i<run.global.ipHostNameTable.length; i++)
+ startup_file.global.ipHostNameTable[i] = run.global.ipHostNameTable[i];
+ for (var i=0; i<run.global.ipHostAddressTable.length; i++)
+ {
+ startup_file.global.ipHostAddressTable[i] = new Array();
+ for (var j=0; j<run.global.ipHostAddressTable[i].length; j++)
+ startup_file.global.ipHostAddressTable[i][j] = run.global.ipHostAddressTable[i][j];
+ }
+
+
+ //interface ethernet 0 configuration
+
+
+ startup_file.e0.exist = run.e0.exist; // determine if interface is there or not
+ startup_file.e0.description = run.e0.description; // interface description
+ startup_file.e0.ip = run.e0.ip; //ip address of interface
+ startup_file.e0.subnet = run.e0.subnet; // subnet mask
+ startup_file.e0.shutdown = run.e0.shutdown; // shutdown ?
+ startup_file.e0.clockrate = run.e0.clockrate; // used only by serial 0
+
+ //interface ethernet 1 configuration
+
+
+ startup_file.e1.exist = run.e1.exist; // determine if interface is there or not
+ startup_file.e1.description = run.e1.description; // interface description
+ startup_file.e1.ip = run.e1.ip; //ip address of interface
+ startup_file.e1.subnet = run.e1.subnet; // subnet mask
+ startup_file.e1.shutdown = run.e1.shutdown; // shutdown ?
+ startup_file.e1.clockrate = run.e1.clockrate; // used only by serial 0
+
+ //interface serial 0 configuration
+
+
+ startup_file.s0.exist = run.s0.exist; // determine if interface is there or not
+ startup_file.s0.description = run.s0.description; // interface description
+ startup_file.s0.ip = run.s0.ip; //ip address of interface
+ startup_file.s0.subnet = run.s0.subnet; // subnet mask
+ startup_file.s0.shutdown = run.s0.shutdown; // shutdown ?
+ startup_file.s0.clockrate = run.s0.clockrate; // used only by serial 0
+
+ //interface serial 1 configuration
+
+
+ startup_file.s1.exist = run.s1.exist; // determine if interface is there or not
+ startup_file.s1.description = run.s1.description; // interface description
+ startup_file.s1.ip = run.s1.ip; //ip address of interface
+ startup_file.s1.subnet = run.s1.subnet; // subnet mask
+ startup_file.s1.shutdown = run.s1.shutdown; // shutdown ?
+ startup_file.s1.clockrate = run.s1.clockrate; // used only by serial 0
+
+
+ startup_file.hostname = run.hostname; //Router hostname
+ startup_file.secret = run.secret; // secret password (enable secret)
+ startup_file.password = run.password;// enable password
+
+ startup_file.global.bannermotd = run.global.bannermotd;
+
+ }
+
+ output_write("[OK]\n");
+ }
+ else {
+ commandline_showErrorMsg("File Name has to be startup-config");
+ }
+ rptr.PROMPT = rptr.run.hostname + "#";
+
+}
+
+
+// ***** copyStartupToRun() *****
+//DO: copies the startup configuration to the running configuration of the active router
+function copyStartupToRun()
+{
+ var rptr = eval("_root.r" + _root.active_router);
+ //if the user did not type any option then by default the running-config option is chosen
+ if (COMMAND.length == 0)
+ COMMAND[0] = "running-config";
+ if (COMMAND[0] == "running-config") {
+
+ with(eval("_root.r" + _root.active_router))
+ {
+ run.line.con_login = startup_file.line.con_login; // console login
+ run.line.con_password = startup_file.line.con_password; //console password
+ run.line.aux_login = startup_file.line.aux_login; // aux login
+ run.line.aux_password = startup_file.line.aux_password; //aux password
+ run.line.vty_login = startup_file.line.vty_login; //virtual terminal login
+ run.line.vty_password = startup_file.line.vty_password; //virtualterminal password
+
+
+ //global configuration
+
+ // RIP
+ run.global.RIP = startup_file.global.RIP;
+ run.global.RIP_network = new Array();
+ for (var i=0; i<startup_file.global.RIP_network.length; i++)
+ run.global.RIP_network[i] = startup_file.global.RIP_network[i];
+
+ // IGRP
+ run.global.IGRP = startup_file.global.IGRP;
+ run.global.IGRP_network = new Array();
+ for (var i=0; i<startup_file.global.IGRP_network.length; i++)
+ {
+ run.global.IGRP_network[i] = new Array();
+ for (var j=0; j<startup_file.global.IGRP_network[i].length; j++)
+ run.global.IGRP_network[i][j] = startup_file.global.IGRP_network[i][j];
+ }
+
+ //ip host table
+ run.global.ipHostNameTable = new Array();
+ run.global.ipHostAddressTable = new Array();
+ for (var i=0; i<startup_file.global.ipHostNameTable.length; i++)
+ run.global.ipHostNameTable[i] = startup_file.global.ipHostNameTable[i];
+ for (var i=0; i<startup_file.global.ipHostAddressTable.length; i++)
+ {
+ run.global.ipHostAddressTable[i] = new Array();
+ for (var j=0; j<startup_file.global.ipHostAddressTable[i].length; j++)
+ run.global.ipHostAddressTable[i][j] = startup_file.global.ipHostAddressTable[i][j];
+ }
+
+
+ //interface ethernet 0 configuration
+
+
+ run.e0.exist = startup_file.e0.exist; // determine if interface is there or not
+ run.e0.description = startup_file.e0.description; // interface description
+ run.e0.ip = startup_file.e0.ip; //ip address of interface
+ run.e0.subnet = startup_file.e0.subnet; // subnet mask
+ run.e0.shutdown = startup_file.e0.shutdown; // shutdown ?
+ run.e0.clockrate = startup_file.e0.clockrate; // used only by serial 0
+
+ //interface ethernet 1 configuration
+
+
+ run.e1.exist = startup_file.e1.exist; // determine if interface is there or not
+ run.e1.description = startup_file.e1.description; // interface description
+ run.e1.ip = startup_file.e1.ip; //ip address of interface
+ run.e1.subnet = startup_file.e1.subnet; // subnet mask
+ run.e1.shutdown = startup_file.e1.shutdown; // shutdown ?
+ run.e1.clockrate = startup_file.e1.clockrate; // used only by serial 0
+
+ //interface serial 0 configuration
+
+
+ run.s0.exist = startup_file.s0.exist; // determine if interface is there or not
+ run.s0.description = startup_file.s0.description; // interface description
+ run.s0.ip = startup_file.s0.ip; //ip address of interface
+ run.s0.subnet = startup_file.s0.subnet; // subnet mask
+ run.s0.shutdown = startup_file.s0.shutdown; // shutdown ?
+ run.s0.clockrate = startup_file.s0.clockrate; // used only by serial 0
+
+ //interface serial 1 configuration
+
+
+ run.s1.exist = startup_file.s1.exist; // determine if interface is there or not
+ run.s1.description = startup_file.s1.description; // interface description
+ run.s1.ip = startup_file.s1.ip; //ip address of interface
+ run.s1.subnet = startup_file.s1.subnet; // subnet mask
+ run.s1.shutdown = startup_file.s1.shutdown; // shutdown ?
+ run.s1.clockrate = startup_file.s1.clockrate; // used only by serial 0
+
+
+ run.hostname = startup_file.hostname; //Router hostname
+ run.secret = startup_file.secret; // secret password (enable secret)
+ run.password = starupt_file.password; // enable password
+
+ run.global.bannermotd = startup_file.global.bannermotd;
+
+ output_write("979 bytes copied in 4.940 secs (244 bytes/sec)\n");
+ }
+
+ commandline_setMode("enable", _root.active_router);
+
+ // updating the routing table
+ routing_table_noRIPUpdate();
+ routing_table_updateLinkTable();
+ }
+ else {
+ commandline_showErrorMsg("File Name has to be running-config");
+ }
+
+ rptr.PROMPT = rptr.run.hostname + "#";
+
+}
+// ***** commandline_showErrorMsg(errMessage)*****
+//IN: errMessage = denotes the message that needs to be displayed in the error message dialog
+//DO: gets the error message and displays the message in the error message dialog.
+
+function commandline_showErrorMsg(errMessage)
+{
+ commandline_changeProcess(null);
+ _root.HyperTerminal.errorWindow.msg = errMessage;
+ _root.HyperTerminal.errorWindow._visible = true;
+
+ if (_root.VISIBLE_ROUTER != "RouterA") {
+ _root.Menu.disabledRouterA._visible = true;
+ _root.Menu.mRouterA._visible = false;
+ }
+ if (_root.VISIBLE_ROUTER != "RouterB") {
+ _root.Menu.disabledRouterB._visible = true;
+ _root.Menu.mRouterB._visible = false;
+ }
+ if (_root.VISIBLE_ROUTER != "RouterC") {
+ _root.Menu.disabledRouterC._visible = true;
+ _root.Menu.mRouterC._visible = false;
+ }
+ if (_root.VISIBLE_ROUTER != "RouterD") {
+ _root.Menu.disabledRouterD._visible = true;
+ _root.Menu.mRouterD._visible = false;
+ }
+ if (_root.VISIBLE_ROUTER != "RouterE") {
+ _root.Menu.disabledRouterE._visible = true;
+ _root.Menu.mRouterE._visible = false;
+ }
+ return;
+}
+//end modified by suresh as in router 2500 OS 12.0
+
+//begin suresh for telnet
+//if the user types telnet without giving the ip address then this function will be called
+// ***** doTelnet() *****
+//DO: get the ip address and call the checkhost function
+function doTelnet()
+{
+ var rptr = eval("_root.r" + _root.active_router);
+ if ( COMMAND.length == 1) {
+ TELNET_ADDRESS = COMMAND[0];
+ _root.telnet_checkHost(TELNET_ADDRESS);
+ }
+ else {
+ commands_invalidInput(this, COMMAND[0]);
+ }
+ commandline_setMode(rptr.MODE, _root.VISIBLE_ROUTER);
+
+}
+//end suresh for telnet
+
+
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commands.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commands.txt
new file mode 100644
index 0000000..60ddc1d
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commands.txt
@@ -0,0 +1,1592 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+// these are the command arrays
+// the "C" stands for Command
+userC = new Array(); // user mode commands
+enableC = new Array(); // privileged mode commands
+globalC = new Array(); // global config mode commands
+
+routerRIPC = new Array(); // RIP
+routerIGRPC = new Array(); // IGRP
+routerEIGRPC = new Array(); // EIGRP
+routerOSPFC = new Array(); // OSPF
+routerBGPC = new Array(); // BGP
+routerAFC = new Array(); // BGP address-family
+routerISISC = new Array(); // IS-IS
+
+lineconC = new Array(); // line console
+lineauxC = new Array(); // line aux
+linevtyC = new Array(); // line vty
+linettyC = new Array(); // line tty
+
+intATMC= new Array(); //ATM for dsl
+intDialerC = new Array(); // dialer
+intEC = new Array(); // ethernet
+intFC = new Array(); // fast ethernet
+intGC = new Array(); // gigabit ethernet
+intSC = new Array(); // serial
+intBriC = new Array(); // bri
+intLoopBackC = new Array(); // loopback
+intAsyncC = new Array(); // async
+intVlanC = new Array(); // vlan interface
+
+// sub interfaces
+
+subintDialerC = new Array();
+subintEC = new Array();
+subintFC = new Array();
+subintGC = new Array();
+subintSC = new Array();
+subintBriC = new Array();
+subintLoopBackC = new Array();
+subintAsyncC = new Array();
+subintVlanC = new Array();
+
+vlanDBC = new Array(); // vlan database mode
+controllerT1C = new Array(); // T1 controller
+extNaclC = new Array(); // extended named access-list
+mapClassC = new Array(); // map-class
+timeRangeC = new Array(); // time-range
+dhcpC = new Array(); // ip dhcp
+routeMapC = new Array(); // route-map
+classMapC = new Array(); // class-map
+policyMapC = new Array(); // policy-map
+policyMapClassC = new Array(); // policy-map class
+ATMPVCC = new Array(); //atm pvc
+
+correctCommand = null; // This global variable is used to store the function that needs to be run.
+
+completeKeywordneeded = new Array(15); // This global variable is needed for remembering which keyword needs to be checked fully
+fillcompleteKeyword(true);
+
+//begin for the configuration mode of the routers -- suresh
+var configRouterA = String("normal");
+var configRouterB = String("normal");
+var configRouterC = String("normal");
+var configRouterD = String("normal");
+var configRouterE = String("normal");
+
+//end for the configuration mode of the routers -- suresh
+
+// ***** Array.addSC (str, str, bool) *****
+//-----------------------------------------------------------------------------
+//IN: commandName = string, the new subcommand name
+// descript = string, the description of the new subcommand
+// noUse = bool, whether or not the subcommand is there to help
+// people or a real subcommand (zmg: which is T and which is F?) (?)
+//
+// NOTE: Most commands and subcommands are stored as arrays.
+//
+// For example, all the commands in the user mode are stored in
+// the array 'userC'. When the command:
+//
+// userC.add("enable","Turn on privileged commands");
+//
+// is called, the following happens:
+//
+// 1) the "enable" subcommand is added to the 'userC'
+// array (userC[])
+// 2) stores the string "enable" in one of the elements
+// in userC[]
+// 3) userC.enable is created as a new array
+// 4) the description of the new subcommand is stored
+// in 'userC.enable.descript'
+// > if the description is omitted, then the subcommand
+// can still be used, however, it will not show up in
+// partial or full help.
+// > the noUse argument can be omitted (as it is in this
+// example). It then has the value 'null'.
+//
+// zmg: the following is quite possibly the worst comment
+// I have ever read. i dont know how to translate
+// this into usable English, so I'll leave it here
+// for now.
+//
+// > The 'noUse' attribute is only for things like WORD.
+// WORD is something to show the user what to put, but
+// it is not really a subcommand. For subcommands like
+// WORD or LINE, noUse is <true>.
+//DO: add a new subcommand to this command
+//OUT: <none>
+//
+// adds the addSC method for the Array object; assigns commands_addSubCommand function to Array.addSC
+Array.prototype.addSC = commands_addSubCommand;
+//
+function commands_addSubCommand(commandName, descript)
+{
+ this[this.length] = commandName; //this specific command is added to
+ //the current command Array
+
+ this[commandName] = new Array(); //a new subcommand array is created
+ this[commandName].descript = descript; //description is stored
+// this[commandName].noUse = noUse; //'noUse' attribute is stored
+
+ // if the command name is in the format of <xxx-yyy> where xxx and yyy are integers and xxx <= yyy
+ if (commandName.charAt(0) == "<")
+ {
+ var str = commandName.substring(1, commandName.length-1); // take out "<" and ">"
+ var num = str.split("-"); // separate the numbers
+
+ if (num.length == 2)
+ {
+ this[commandName].startNum = Number(num[0]); // assign the starting number to startNum
+ this[commandName].endNum = Number(num[1]); // assign the ending number to endNum
+ }
+ }
+}
+
+/*
+globalC.interface.Serial.addMC("<0-1>", "Serial interface number");
+ globalC.interface.Serial["<0-1>"].addSIC("<0-1>", "Serial interface number");
+ globalC.interface.Serial["<0-1>"]["<0-1>"].addSC("<0-4294967295>");
+
+globalC.interface.Serial["<0-1>"]["<0-1>"].enter = true;
+globalC.interface.Serial["<0-1>"]["<0-1>"]["<0-4294967295>"].enter = true;
+*/
+Array.prototype.addMC = commands_addModuleCommand;
+function commands_addModuleCommand(commandName, descript)
+{
+ this.addSC(commandName, descript);
+ this.isSpecial = true;
+ this.hasModule = true;
+ this[commandName].isSpecial = true;
+ this[commandName].isModule = true;
+}
+
+Array.prototype.addSIC = commands_addSubInterfaceCommand;
+function commands_addSubInterfaceCommand(commandName, descript)
+{
+ this.addSC(commandName, descript);
+ this.isSpecial = true;
+ this.hasSI = true;
+ this[commandName].isSpecial = true;
+ this[commandName].isSI = true;
+}
+
+
+// ***** commands_deleteSubCommand (str, str, bool) *****
+//IN: commandArray = string, name of the command array that contains
+// the subcommand being deleted
+// commandNameToDel = string, name of subcommand that is being deleted
+// all = bool, true: delete every subcommand in 'commandArray'
+// false: delete the subcommand 'commandNameToDel'
+//DO: delete the subcommand 'commandNameToDel' in 'commandArray', or if
+// all==true, all of the subcommands
+//OUT: <none>
+function commands_deleteSubCommand(commandArray, commandName, all)
+{
+ //get a pointer to the command array
+ var commandArray = eval(commandArray);
+
+ if (all == true)
+ {
+ //delete all the subcommands in this command array (all==true),
+ //and reset the command array's length to 0.
+ for (var i=0; i<commandArray.length; i++)
+ delete commandArray[commandArray[i]];
+ commandArray.length = 0;
+ }
+ else
+ {
+ //all == false, we are going to delete the
+ //specific subcommand 'commandNameToDel'
+
+ //for-loop finds the subcommand in question
+ var i = 0;
+ for (var i=0; i<commandArray.length; i++) {
+
+ //search through all subcommands--if there is a match,
+ //then break the loop. after the for-loop, i will be
+ //equal to the subcommand to be deleted
+ if (commandArray[i] == commandName)
+ break;
+ }
+
+ //zmg: I added this line...do we need to just return if
+ //the command doesn't exist?
+ //if (commandArray.length == i) return; //the command to delete DNE in 'captr'
+
+ //remove the ith ('commandNameToDel')
+ //subcommand from the command array
+ commandArray.splice(i,1);
+
+ //delete the subcommand's array from memory
+ delete commandArray[commandName];
+ }
+}
+
+
+
+
+
+
+
+// ***** commands_sortSubCommand(array) *****
+//IN: commandArName = the name of a command array
+//DO: sorts the command array, so when the user presses "?", it will show in
+// alphabetical order. the 'noUse' subcommands will be sorted to the front.
+//OUT: the alpha-sorted command array 'commandArName'
+function commands_sortSubCommand(commandName)
+{
+ // use this as a pointer to the command array
+ var commandArray = eval(commandName);
+
+ // sort this array in alpha order
+ commandArray.sort();
+
+ var noUseElements = 0; //number of 'noUse' commands
+ for (var i=0; i<commandArray.length; i++)
+ {
+ //commands_sortSubCommand(commandName + "." + commandArray[i]);
+ if (commandArray[commandArray[i]].noUse == true)
+ {
+ //if this is a 'noUse' command, then put it in the
+ //front of the sorted list
+ //
+ //zmg: does this put the 'noUse' commands in alpha
+ // order? does it matter? (?)
+ commandArray.splice(noUseElements,0,commandArray.splice(i,1).toString());
+
+ //increment the number of 'noUse' commands
+ noUseElements++;
+ }
+ }
+}
+
+
+
+
+
+// ***** commands_copyCommand(str, str, str, bool) *****
+//DO: copies the 'scArrayName' from 'fromArray' to 'toArray'.
+// ** NOTE: If the 'scArrayName' argument is omitted, then every
+// subcommand will be copied from 'fromArray' to 'toArray'
+//
+//IN: fromArray = string, name of the command array to copy from
+// toArray = string, name of the command array to copy to
+// scArrayName = string, name of the subcommand being copied (if ==null,
+// then all of the attribs of this subcommand are copied)
+// noCommand = boolean, whether the command is "no"
+//OUT: <none>
+function commands_copyCommand(fromArray, toArray, commandArray, noCommand)
+{
+ if (commandArray != null)
+ {
+ // if scArrayName is not omitted, then copy all the attributes of this subcommand
+ eval(toArray)[eval(toArray).length] = commandArray;
+ eval(toArray)[commandArray] = new Array();
+ eval(toArray)[commandArray].descript = eval(fromArray)[commandArray].descript;
+ eval(toArray)[commandArray].enter = eval(fromArray)[commandArray].enter;
+ eval(toArray)[commandArray].mustEnter = eval(fromArray)[commandArray].mustEnter;
+ eval(toArray)[commandArray].mustHelp = eval(fromArray)[commandArray].mustHelp;
+ eval(toArray)[commandArray].noUse = eval(fromArray)[commandArray].noUse;
+
+ // copy all subcommands of this command
+ for (var i=0; i<eval(fromArray)[commandArray].length; i++)
+ {
+ commands_copyCommand((fromArray+"."+commandArray), (toArray+"."+commandArray), eval(fromArray)[commandArray][i]);
+ }
+
+ }
+ else
+ {
+ //if 'scArrayName' is omitted, then copy all subcommands from
+ //'fromArray' to 'toArray'
+ for (var j=0; j<eval(fromArray).length; j++)
+ {
+ commandArray = eval(fromArray)[j];
+
+ if (eval(fromArray)[j] != "no")
+ {
+ //the current subcommand name is not "no",
+ //so copy the subcommand
+ eval(toArray)[eval(toArray).length] = commandArray;
+ eval(toArray)[commandArray] = new Array();
+ eval(toArray)[commandArray].descript = eval(fromArray)[commandArray].descript;
+
+ if (noCommand != true)
+ {
+ //if the from command array is not a "no" command,
+ //then copy the enter and mustEnter functions
+ eval(toArray)[commandArray].enter = eval(fromArray)[commandArray].enter;
+ eval(toArray)[commandArray].mustEnter = eval(fromArray)[commandArray].mustEnter;
+ }
+
+ eval(toArray)[commandArray].mustHelp = eval(fromArray)[commandArray].mustHelp;
+ eval(toArray)[commandArray].noUse = eval(fromArray)[commandArray].noUse;
+
+ // copy all subcommands in this commandArray
+ for (var i=0; i<eval(fromArray)[commandArray].length; i++)
+ {
+ commands_copyCommand((fromArray+"."+commandArray), (toArray+"."+commandArray), eval(fromArray)[commandArray][i]);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+spaces = " ";
+
+// ***** commands_invalidInput(array, int) *****
+//IN: commandArray = the name of a command array
+// subCIndex = int, index of invalid input element
+//DO: prints out the caret (^) and message indicating error
+//OUT: prints out an error message to the user, with a ^ pointing
+// to the first invalid character in the command string
+function commands_invalidInput(commandArray, subCNum)
+{
+ // use this as a pointer to the router object
+ var rptr = eval("_root.r" + _root.active_router);
+
+ //if the input command is only one word long..
+ if (COMMAND.length == 1)
+ {
+ if ((rptr.MODE == "user") || (rptr.MODE == "enable"))
+ {
+ //the router is in user or enable mode, so print out
+ //this error message, and exit the
+ //commands_invalidInput() function
+ output_write("Translating \"" + COMMAND[0] + "\"...domain server (255.255.255.255)\n");
+ output_write("% Unknown command or computer name, or unable to find computer address\n");
+ return;
+ }
+ }
+
+ //this for-loop starts with the first character of the invalid input
+ //element, and determines which character is incorrect
+ for (var j=1; j<=COMMAND[subCNum].length; j++)
+ {
+ match = false; //tmp.flag variable
+
+ //loop through all subcommands in this commmand array
+ for (var i=0; i<commandArray.length; i++)
+ {
+ //this if-statement skips 'noUse' commands
+ if (commandArray[commandArray[i]].noUse != true)
+ {
+ //if the first j characters of the input
+ //element match the first j characters of the
+ //subcommand in this command array, then set
+ //match to 'true'
+ if (COMMAND[subCNum].substring(0,j).toLowerCase() == commandArray[i].substring(0,j).toLowerCase())
+ {
+ match = true;
+ }
+ }
+ }
+
+ //if the first j characters of the input element does not
+ //match with any of the subcommands, then exit this loop
+ if (match == false)
+ break;
+ }
+
+ //get the length of the input before the error character
+ previousEleLength = commands_inputEleTo(subCNum).length - COMMAND[subCNum].length;
+ invalidCharAt = rptr.PROMPT.length + previousEleLength + j - 1;
+
+ //print spaces and error message, alerting the user
+ //to the location of the invalid character
+ output_write(spaces.substring(0,invalidCharAt));
+ output_write("^\n",
+ "% Invalid input detected at '^' marker.\n",
+ "\n");
+}
+
+
+
+
+
+
+// ***** commands_inputEleTo(int) *****
+//IN: subCIndex = int, representing which input element it is to
+//DO: returns the string of the input from beginning to this element
+//OUT: returns the string of the input from beginning to this element
+function commands_inputEleTo(subCNum)
+{
+ // use this as a pointer to the router object
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ //split the command line input at the spaces, and put
+ //the pieces into the elements of 'inputArray'
+ inputArray = rptr.INPUT.split(" ");
+ inputSC = "";
+
+ //this for-loop returns the first 'subCIndex' words from
+ //the rptr.INPUT (command line input) string
+ for (var k=0, inputEle=0; ((k<inputArray.length) && (inputEle<=subCNum)); k++)
+ {
+ if (inputArray[k] != "")
+ inputEle++;
+ inputSC += inputArray[k] + " ";
+ }
+
+ //return the truncated, newly-built string
+ return(inputSC.substring(0,inputSC.length-1));
+}
+
+
+
+
+
+
+
+// ***** commands_useCommand(array, int) *****
+//IN: commandArray = the command array
+// subCIndex = int, representing which input element this fct is interpreting
+//DO: searches through 'commandArray' for a subcommand that matches the
+// subCIndex'th element of the command line input. If it is found, then
+// that subcommand's array will be used to search for the next element
+// of the input. (this is a recursive function)
+//OUT: <none>
+function commands_useCommand(commandArray, subCNum)
+{
+//trace("commandArray = " + commandArray);
+//trace("COMMAND = " + COMMAND);
+//trace("COMMAND.length = " + COMMAND.length);
+//trace("commandArray.length = " + commandArray.length);
+//trace("subCNum = " + subCNum);
+
+ // use this as a pointer to the active router object
+ var rptr = eval("_root.r" + _root.active_router);
+ var vptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+//trace("COMMAND[subCNum] = " + COMMAND[subCNum]);
+//trace("commandArray.length = " + commandArray.length);
+//trace("commandArray.enter = " + commandArray.enter);
+
+ if (commandArray.isSpecial)
+ {
+ // if command has a slot subcommand and this is not the last command part entered
+ if ((commandArray.hasModule) && (subCNum < COMMAND.length))
+ {
+ var parts = COMMAND[subCNum].split("/");
+
+ if (parts.length != 2)
+ {
+ if (!rptr.HELPING)
+ {
+ parsestatus = UNSUCCESSFULregcmd;
+ }
+ else
+ {
+ // show slash
+ if ((subCNum == (COMMAND.length-1)) && (vptr.INPUT.charAt(vptr.INPUT.length-1) != " "))
+ {
+ output_write("/\n", "\n");
+ parsestatus = SUCCESSFULhelpcmd;
+ }
+ else
+ {
+ parsestatus = UNSUCCESSFULhelpcmd;
+ output_write("% Unrecognized command\n");
+ }
+ }
+ return;
+ }
+ else
+ {
+ // trace("COMMAND[] = " + COMMAND.join());
+ COMMAND[subCNum] = parts[1];
+ COMMAND.splice(subCNum, 0, parts[0]);
+ trace("COMMAND[] = " + COMMAND.join());
+ }
+ }
+ else if (commandArray.isModule)
+ {
+// trace("is module " + COMMAND[subCNum]);
+
+ if (COMMAND[subCNum] == "")
+ {
+ if (!rptr.HELPING)
+ {
+ parsestatus = UNSUCCESSFULregcmd;
+ }
+ else
+ {
+ // show help
+ if ((subCNum == (COMMAND.length-1)) && (vptr.INPUT.charAt(vptr.INPUT.length-1) != " "))
+ {
+ commands_helpCommand(commandArray);
+ parsestatus = SUCCESSFULhelpcmd;
+ }
+ else
+ {
+ parsestatus = UNSUCCESSFULhelpcmd;
+ output_write("% Unrecognized command\n");
+ }
+ }
+ return;
+ }
+ }
+
+ if (commandArray.hasSI)
+ {
+// trace("has SI " + COMMAND[subCNum]);
+
+ var parts = COMMAND[subCNum].split(".");
+ if (parts.length == 2)
+ {
+ COMMAND[subCNum] = parts[1];
+ COMMAND.splice(subCNum, 0, parts[0]);
+ trace("COMMAND[] = " + COMMAND.join());
+ }
+ }
+ else if (commandArray.isSI)
+ {
+// trace("is SI " + COMMAND[subCNum]);
+
+ if (COMMAND[subCNum] == "")
+ {
+ if (!rptr.HELPING)
+ {
+ parsestatus = UNSUCCESSFULregcmd;
+ }
+ else
+ {
+ // show help
+ if ((subCNum == (COMMAND.length-1)) && (vptr.INPUT.charAt(vptr.INPUT.length-1) != " "))
+ {
+ output_write(" " + commandArray[0] + " " + commandArray.descript + "\n", "\n");
+// commands_helpCommand(commandArray);
+ parsestatus = SUCCESSFULhelpcmd;
+ }
+ else
+ {
+ parsestatus = UNSUCCESSFULhelpcmd;
+ output_write("% Unrecognized command\n");
+ }
+ }
+ return;
+ }
+ }
+ }
+
+//trace("vptr = " + (vptr.INPUT.charAt(vptr.INPUT.length-1)) + "a");
+ if (subCNum >= COMMAND.length)
+ {
+trace("alternate step: 1");
+//trace("last command " + COMMAND[subCNum]);
+ // 2nd case: subCNum passes command.length, we exhausted the array.
+ // -Helping ver
+ if (rptr.Helping == true)
+ {
+//trace("help for " + COMMAND[subCNum - 1]);
+ //the "?" has been pressed, show full help
+ parsestatus = SUCCESSFULhelpcmd;
+ commands_helpCommand(commandArray);
+ return;
+ }
+ else
+ {
+ // Non-Helping ver
+ if ((typeof(commandArray.enter) != "function") && (commandArray.enter != true))
+ {
+ // the functions for this command does not exist but it works.
+ //return;
+ parsestatus = SUCCESSFULregcmd;
+ return;
+ }
+ else
+ {
+ // the functions for this command exists.
+ parsestatus = SUCCESSFULregcmd;
+ return;
+ }
+ }
+ }
+ else if (commandArray.length == 0)
+ {
+ trace("alternate step: 2");
+ // 1st case: no further command array left.
+ //Non-Helping ver
+ if (rptr.HELPING == false)
+ {
+ if ((typeof(commandArray.enter) != "function") && (commandArray.enter != true))
+ {
+ // the functions for this command does not exist.
+ parsestatus = SUCCESSFULregcmd; // <-- the command is not supported but has to be successful to parse
+ return;
+ }
+ else
+ {
+ // the functions for this command exists.
+ // Note: is there even this case ?
+//trace("Case 1, help = false, functions exists");
+ _root.correctCommand = commandArray.enter;
+ parsestatus = SUCCESSFULregcmd;
+ }
+ }
+ else
+ {
+ //Helping ver
+ parsestatus = UNSUCCESSFULhelpcmd;
+ output_write("% Unrecognized command\n");
+ return;
+/*
+ if ((typeof(commandArray.enter) != "function") && (commandArray.enter != true))
+ {
+ // the functions for this command does not exist. <-- the command is not supported but help might be.
+//trace("Case 1, help = true, functions not exists");
+ parsestatus = UNSUPPORTEDhelpcmd;
+
+ //commands_helpListCommand(commandArray, COMMAND[0]);
+ return;
+ }
+ else
+ {
+ // the functions for this command exists.
+ // Note: is there even this case ?
+//trace("Case 1, help = true, functions exists");
+ parsestatus = UNSUPPORTEDhelpcmd;
+ return;
+ }
+*/
+ }
+ }
+ else
+ {
+ // All other case: More command array to check.
+ // Try to match the commandArray with the command typed (other function)
+//var startTime=getTimer();
+//trace("Matching command - startTime = " + startTime);
+ var matchRet = matchingCommand(commandArray, subCNum);
+//var endTime=getTimer();
+//trace("Matching command - endTime = " + endTime);
+//trace("Matching command - elapsed time = " + ((endTime-startTime)/1000) + "\n");
+
+trace("Match Return = " + matchRet);
+
+ // if it doesn't match, it is an invalid input, incorrect input
+ if (matchRet == -2)
+ {
+ if (rptr.HELPING == true)
+ {
+ parsestatus = UNSUCCESSFULhelpcmd;
+ output_write("% Unrecognized command\n");
+ //trace("COMMAND = " + COMMAND);
+//trace("matchRet = -2, HELPING");
+ }
+ else
+ {
+ parsestatus = UNSUCCESSFULregcmd;
+ }
+ return;
+ }
+ else if ((subCNum == (COMMAND.length-1)) && (rptr.HELPING == true) && (vptr.INPUT.charAt(vptr.INPUT.length-1) != " "))
+ {
+ // else if the cmd line matches valid command
+ //"?" is pressed, and is calling for partial help,
+ //so list out the commands that start with the typed
+ //characters, then list out those commands
+ //commands_helpListCommand(commandArray,COMMAND[subCNum]);
+ parsestatus = SUCCESSFULhelpcmd; // command was successful
+//trace("Case else, help = true, parsestatus =5");
+//trace("list commands for " + COMMAND[subCNum]);
+ commands_helpListCommand(commandArray, COMMAND[subCNum]);
+ return;
+ }
+ else if (matchRet == -1)
+ {
+ // else if match detects ambiguous cmd
+ output_write("% Ambiguous command: \"" + commands_inputEleTo(subCNum) + "\"\n");
+ parsestatus = AMBIGUOUSregcmd;
+ return;
+ }
+ else
+ {
+ // other wise, we recurse the function
+//trace("matchRet = " + matchRet);
+//trace("commandArray[matchRet] = " + matchRet);
+//trace("commandArray[commandArray[matchRet]] = " + commandArray[matchRet]);
+
+ if (commandArray.isSpecial)
+ {
+ if (commandArray.isModule)
+ {
+ COMMAND[subCNum-1] = COMMAND[subCNum-1] + "/" + COMMAND[subCNum];
+ COMMAND.splice(subCNum, 1);
+ subCNum--;
+ }
+ else if (commandArray.isSI)
+ {
+ COMMAND[subCNum-1] = COMMAND[subCNum-1] + "." + COMMAND[subCNum];
+ COMMAND.splice(subCNum, 1);
+ subCNum--;
+ }
+ }
+
+
+ commands_useCommand(commandArray[matchRet],subCNum+1);
+ }
+ }
+}
+
+
+/*
+// IN: commandArray = the array we are checking
+ subCNum = the case we are checking now
+// DO: tries to match the command with a valid command Array
+// OUT: -2 Invalid input
+ -1 Ambiguous command
+ 0
+ +n
+// WORD, LINE, <>, A.B.C.D, H.H.H - added by Kalven
+*/
+
+function matchingCommand(commandArray, subCNum)
+{
+ //var match = -2;
+
+ _root.completeKeywordneeded[subCNum] = false; // does the default step
+
+ //Try to improve this function with Binary Search -Kalven
+//trace("Match Command");
+//trace("Specials");
+//trace("subCNum="+subCNum);
+ if( (typeof(commandArray["WORD"]) == "object") && (commandArray[commandArray["WORD"]].noUse != true) )
+ {
+ _root.completeKeywordneeded[subCNum]= true;
+ return "WORD";
+ }
+ else if( (subCNum > 0) && (typeof(commandArray["LINE"]) == "object") && (commandArray.line.descript.indexOf("line") < 0))
+ {
+
+ _root.completeKeywordneeded[subCNum] = true;
+ return "LINE";
+ }
+ else if( (typeof(commandArray["A.B.C.D"]) == "object") && (commandArray[commandArray["A.B.C.D"]].noUse != true) )
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ if(commands_checkABCD(COMMAND[subCNum]))
+ {
+ return "A.B.C.D";
+ }
+ }
+ else if( (typeof(commandArray["H.H.H"]) == "object") && (commandArray[commandArray["H.H.H"]].noUse != true) )
+ {
+ if(commands_checkHHH(COMMAND[subCNum]))
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ return "H.H.H";
+ }
+ }
+//trace("<>");
+ // check the ranges, first check the front of the list, and then check the end of the list
+ var i = 0;
+ while( (commandArray[i].charAt(0) == "<") && (commandArray[i].charAt(commandArray[i].length-1) == ">"))
+ {
+ if(commandArray[commandArray[i]].noUse != true)
+ {
+ if( commandArray[i].indexOf("-") >= 0)
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ if ((!isNaN(COMMAND[subCNum])) && (Number(COMMAND[subCNum]) >= commandArray[commandArray[i]].startNum) && (Number(COMMAND[subCNum]) <= commandArray[commandArray[i]].endNum))
+ {
+ return commandArray[i];
+ }
+ }
+ else
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ return commandArray[i];
+ }
+ }
+ i++;
+ }
+
+ i = commandArray.length-1;
+ while( (commandArray[i].charAt(0) == "<") && (commandArray[i].charAt(commandArray[i].length-1) == ">"))
+ {
+ if(commandArray[commandArray[i]].noUse != true)
+ {
+ if( commandArray[i].indexOf("-") >= 0)
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ if ((!isNaN(COMMAND[subCNum])) && (Number(COMMAND[subCNum]) >= commandArray[commandArray[i]].startNum) && (Number(COMMAND[subCNum]) <= commandArray[commandArray[i]].endNum))
+ {
+ return commandArray[i];
+ }
+ }
+ else
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ return commandArray[i];
+ }
+ }
+ i--;
+ }
+//trace("Binary Search");
+ // now search for ambiguous or correct command
+ var left = 0; // left side of the array
+ var right = commandArray.length-1; // right side of the array
+ var sw = false; // flag for a match
+ var middle = 0; // middle of the array that we use to check against
+ var word = COMMAND[subCNum].toLowerCase(); //the command we're checking
+ while (sw == false && left <= right)
+ {
+ middle=Math.floor((left+right)/2);
+ trace(commandArray[middle].toLowerCase());
+ if ((word == commandArray[middle].toLowerCase()) && (commandArray[commandArray[middle]].noUse != true) )
+ {
+ // found
+ //msgNotice("FOUND1");
+ trace("found");
+ trace(commandArray[middle].toLowerCase());
+ sw=true;
+ _root.completeKeywordneeded[subCNum] = false;
+ return commandArray[middle];
+ }
+ else if((middle-1 >= 0) && (word == commandArray[middle-1].toLowerCase()) && (commandArray[commandArray[middle-1]].noUse != true))
+ {
+ // found
+ // msgNotice("FOUND2");
+ trace("found");
+ trace(commandArray[middle-1].toLowerCase());
+ sw=true;
+ _root.completeKeywordneeded[subCNum] = false;
+ return commandArray[middle-1];
+
+ }
+ else if( (middle+1 < commandArray.length) && (word == commandArray[middle+1].toLowerCase()) && (commandArray[commandArray[middle+1]].noUse != true) )
+ {
+ //msgNotice("FOUND3");
+ // found
+ trace("found");
+ trace(commandArray[middle+1].toLowerCase());
+ sw=true;
+ _root.completeKeywordneeded[subCNum] = false;
+ return commandArray[middle+1];
+
+ }
+ else if( (word == commandArray[middle].substring(0,word.length).toLowerCase()) && (commandArray[commandArray[middle]].noUse != true))
+ {
+ // the fist j characters of the input element match the first j chars of subcommand
+ // see if word matches with the previous or the next command.
+ if(
+ ( (middle-1 >= 0) && (word == commandArray[middle-1].substring(0,word.length).toLowerCase()) && (commandArray[commandArray[middle-1]].noUse != true))
+ ||
+ ( (middle+1 < commandArray.length) && (word == commandArray[middle+1].substring(0,word.length).toLowerCase()) && (commandArray[commandArray[middle+1]].noUse != true))
+ )
+ {
+ // ambiguous command
+ trace("ambigous command");
+ _root.completeKeywordneeded[subCNum] = false;
+ if ( (commandArray[middle] == "e0") || (commandArray[middle] == "e1") || (commandArray[middle] == "s0") || (commandArray[middle] == "s1") )
+ {
+ trace("ambigous");
+ _root.completeKeywordneeded[subCNum] = true;
+ return -2;
+ }
+ else return -1;
+ }
+ else return commandArray[middle];
+ }
+ else
+ {
+ if (word < commandArray[middle].toLowerCase()) right=middle-1;
+ if (word > commandArray[middle].toLowerCase()) left=middle+1;
+ }
+ }
+ if (sw == false)
+ {
+ // not found
+ trace("not found");
+ _root.completeKeywordneeded[subCNum] = true;
+ return -2;
+ }
+
+/*
+ //this for-loop loops through all subcommands in this 'commandArray'
+ for (var i=0; i<commandArray.length; i++)
+ {
+//trace("commandArray[i] = " + commandArray[i] + ", i = " + i);
+ //this if-statement skips 'noUse' commands
+
+
+ if (commandArray[commandArray[i]].noUse != true)
+ {
+ if ((commandArray[i] == "WORD") || (commandArray[i] == "LINE"))
+ {
+ // if the subcommand is a word or a line that the user can type in,
+ // then use the WORD or LINE command array accordingly.
+ match = i;
+ _root.completeKeywordneeded[subCNum] = true;
+ break;
+ }
+ else if ((commandArray[i].charAt(0) == "<") && (commandArray[i].charAt(commandArray[i].length-1) == ">"))
+ {
+ if (commandArray[i].indexOf("-") >= 0)
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ if ((!isNaN(COMMAND[subCNum])) && (Number(COMMAND[subCNum]) >= commandArray[commandArray[i]].startNum) && (Number(COMMAND[subCNum]) <= commandArray[commandArray[i]].endNum))
+ {
+ match = i;
+ break;
+ }
+ }
+ else
+ {
+ match = i;
+ _root.completeKeywordneeded[subCNum] = true;
+ break;
+ }
+ }
+ else if (commandArray[i].indexOf("A.B.C.D") >= 0)
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+
+ if (commands_checkABCD(COMMAND[subCNum]))
+ {
+ match = i;
+ break;
+ }
+ }
+ else if (commandArray[i] == "H.H.H")
+ {
+ if (commands_checkHHH(COMMAND[subCNum]))
+ {
+ match = i;
+ _root.completeKeywordneeded[subCNum] = true;
+ break;
+ }
+ }
+ else if (COMMAND[subCNum].toLowerCase() == commandArray[i].toLowerCase())
+ {
+ //the command line input element matches the
+ //current (ith) subcommand--set it to match,
+ //then exit the loop
+ match = i;
+
+ _root.completeKeywordneeded[subCNum] = false;
+ break;
+ }
+ else if (COMMAND[subCNum].toLowerCase() == commandArray[i].substring(0,COMMAND[subCNum].length).toLowerCase())
+ {
+ //the first j characters of the input element
+ //match the first j characters of the subcommand
+ if (match == -2)
+ {
+ //if there was no match before this
+ //iteration, so set 'match' to this
+ //iteration's number (i)
+ match = i;
+ }
+ else
+ {
+ //there was a match before this
+ //iteration, so set 'match' to -1
+ //(this means this is an ambiguous
+ //command), and exit the loop
+ //begin condition added by suresh
+ //reason is if the user types "int e ?" in config mode
+ // it was printing ambiguous command as we have both ethernet and e0,e1 in globalC array
+
+ _root.completeKeywordneeded[subCNum] = false;
+
+ if ( (commandArray[i] == "e0") || (commandArray[i] == "e1") || (commandArray[i] == "s0") || (commandArray[i] == "s1") )
+ {
+ }
+ else
+ match = -1;
+ //end condition added by suresh
+ break;
+ }
+ }
+ }
+ }
+
+ // if we still have match = -2, we have to have full check for the keyword
+ if (match == -2)
+ {
+ _root.completeKeywordneeded[subCNum] = true;
+ }
+
+ return match;
+ */
+}
+
+function fillcompleteKeyword(k)
+{
+ for (var i=0; i < _root.completeKeywordneeded.length;i++)
+ _root.completeKeywordneeded[i] = k;
+}
+
+// ***** commands_helpListCommand(array, str) *****
+//IN: commandArray = command array
+// inputCommand = string, the input command
+//DO: lists out all the commands with the same spelling as the given command
+// fragment. (ex: when the user types "t?", all commands that start with
+// "t" will be printed to the console)
+//OUT: list of matching commands printed to the console
+function commands_helpListCommand(commandArray, inputCommand)
+{
+ if (typeof(commandArray["WORD"]) == "object")
+ {
+ output_write("WORD ");
+ }
+
+ else if ((typeof(commandArray["LINE"]) == "object") && (commandArray.line.descript.indexOf("line") < 0))
+ {
+ output_write("LINE ");
+ }
+
+ if (typeof(commandArray["A.B.C.D"]) == "object")
+ {
+ output_write("A.B.C.D ");
+ }
+
+ if (typeof(commandArray["H.H.H"]) == "object")
+ {
+ output_write("H.H.H");
+ }
+
+ if (commandArray.hasSI)
+ {
+ output_write(". ");
+ }
+
+ if ((commandArray[0].charAt(0) == "<") && (commandArray[0].charAt(commandArray[0].length-1) == ">"))
+ {
+ if ((!isNaN(inputCommand)) && (Number(inputCommand) >= commandArray[commandArray[0]].startNum) && (Number(inputCommand) <= commandArray[commandArray[0]].endNum))
+ {
+ output_write(commandArray[0] + " ");
+ }
+ }
+
+ //this for-loop iterates through all of the
+ //subcommands in this 'commandArray'
+ for (var i=0; i<commandArray.length; i++)
+ {
+ //this if-statement will skip 'noUse' commands, and those commands
+ //that do not have descriptions
+ if (commandArray[commandArray[i]].descript != null)
+ {
+ //if the first j characters of the command line input
+ //match the first j characters of the subcommand,
+ //then print that subcommand out in the help listing
+ if (inputCommand.toLowerCase() == commandArray[i].substring(0,inputCommand.length).toLowerCase())
+ {
+ output_write(commandArray[i] + " ");
+ }
+ }
+ }
+ //newlines...
+ output_write("\n","\n");
+}
+
+
+
+
+// ***** commands_tabCompleteCommand(array, str) *****
+//IN: commandArray = command array
+// cmdLineInput = string, the current command line input
+//DO: fills the commandline with the rest of the text of the command that the
+// input matches, or just repeats the current input on the next line if
+// the current input is invalid or ambiguous
+//OUT: <none>
+function commands_tabCompleteCommand(commandArray, cmdLineInput)
+{
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ var matchingCmds = 0; //# matching commands for current part of commandline input
+ var matchingCmdIndex = -1; //index in currentArray of the matching command
+ var error = 0; //flag, to determine if there is a good match (error = 0), or
+ //there is no matching command (error = 1)
+
+ var fullCmdName = ""; //string, after the for-loops contains the string of the valid
+ //command that the command line input matches
+
+
+ //split the command line input into an array, with
+ //each element containing one token (word)
+ //
+ var extraSpaces = 0; //number of extra spaces in the command line input
+ var trailingSpace = 0; //flag, 1 if there is are trailing spaces in the command
+ //line input
+
+ partialInput = new Array();
+ partialInput = cmdLineInput.split(" ");
+ for (var i = 0; i < partialInput.length; i++)
+ {
+ //removes the empty "" elements from
+ //the 'partialInput' array
+ if (partialInput[i] == "")
+ {
+ partialInput.splice(i,1);
+ i--;
+ extraSpaces++;
+
+ if ((i+1) == partialInput.length)
+ {
+ trailingSpace = 1;
+ }
+ }
+ }
+
+
+ //if there is a trailing space in the command line input, then
+ //no command will match. the first part of this if-statement
+ //takes care of that case. if there isn't a trailing space,
+ //then we need to try to match the command.
+ //
+ if (trailingSpace == 1)
+ {
+ //if there is a trailing space, no command will match,
+ //so set the error flag right away
+ error = 1;
+
+ }
+ else
+ {
+ //there is no trailing space in the command line input
+
+ //these doubly nested for-loops compare 'partialInput' to the the
+ //command arrays for the current mode, and determine if there is
+ //a uniquely matching command. if there is, 'error' will be 0, and
+ //'fullCmdName' will hold the name of the matching command.
+ //
+ for (var k = 0; k < partialInput.length; k++)
+ {
+ matchingCmds = 0;
+
+ //this for-loop iterates through all of the
+ //subcommands in this 'commandArray'
+ for (var i = 0; i<commandArray.length; i++)
+ {
+ //this if-statement will skip 'noUse' commands, and those commands
+ //that do not have descriptions
+ if ((commandArray[commandArray[i]].noUse != true) && (commandArray[commandArray[i]].descript != null))
+ {
+ if (partialInput[k].toLowerCase() == commandArray[i].substring(0,partialInput[k].length).toLowerCase())
+ {
+ //if the first j characters of the command line input
+ //match the first j characters of the subcommand,
+
+ // update the necessary 'matchingCmd' counters.
+ matchingCmdIndex = i;
+
+ if (partialInput[k].length == commandArray[i].length)
+ {
+ // if the input matches the whole command array element
+ // then it has an exact match, then break the loop
+
+ matchingCmds = 1;
+ break;
+ }
+ else
+ {
+ matchingCmds += 1;
+ }
+ }
+ }
+ }
+
+ if (matchingCmds != 1)
+ {
+ //if there are 0, or >1 matching commands,
+ //end the search process, this commandline
+ //input already is ambiguous or invalid
+ error = 1;
+ break;
+ }
+
+
+ //keep building up the currently matching command
+ if (fullCmdName != "")
+ fullCmdName += " ";
+ fullCmdName += commandArray[matchingCmdIndex];
+
+ //we have matching possibilities at this token level,
+ //so now set currentArray to the next subarray deeper
+ //(matchedCmd.allOfItsSubCmds[]), and the next iteration
+ //will try to find a match there as well
+ commandArray = commandArray[commandArray[matchingCmdIndex]];
+ } //end k for-loop
+ }
+
+ //
+ //at this point, the 'error' flag has been set, and 'fullCmdName'
+ //contains the full name of the matching command, if applicable
+ //
+
+ if (error == 0)
+ {
+ //the command line input entered so far exactly matches
+ //one command, so complete the input..
+
+ //at this point, fullCmdName is equal to the full name
+ //of the command that is matched, for example, "show running-config",
+ //regardless if the command line input is "show ru", "sh run" or
+ //whatever. this block of code sets 'finalMatch' equal to the
+ //command line input, except it replaces the last token with the
+ //full command. For example, "sh ru" becomes "sh running-config".
+ //this is so, the completed command will be displayed right later.
+ //
+
+ //split the full command name into the array 'fcArray'
+ fcArray = new Array();
+ fcArray = fullCmdName.split(" ");
+
+ //declare the destination string variable
+ var finalMatch = "";
+
+ //iterates through all of the pieces of the full command name
+ for (var ix = 0; ix < fcArray.length-1; ix++)
+ {
+ if (fcArray[ix] == partialInput[ix])
+ {
+ //if the full command name, and the command line
+ //input match, (ex. "show" is on the command line),
+ //then add this token to the final matching string
+ finalMatch += fcArray[ix];
+
+ }
+ else
+ {
+ //if the full command name and the command line
+ //input don't match, add the fragment from the
+ //command line to the final matching string
+ finalMatch += partialInput[ix];
+ }
+ //separate each token with a space
+ finalMatch += " ";
+ }
+
+ //add the full string corresponding to the last token
+ finalMatch += fcArray[fcArray.length-1];
+
+ //determine 'restOfCmd', the rest of the command string
+ //that will be "filled in" by pressing the <Tab> key.
+ var restOfCmd = finalMatch.substring(cmdLineInput.length-extraSpaces,finalMatch.length);
+
+
+ //add the rest of the command to the command line buffer
+ //and to the output, and then refresh the Hyperterminal window
+ rptr.line[rptr.lastLine] += restOfCmd;
+ rptr.INPUT += restOfCmd;
+ output_write();
+
+ //update the cursor pointer to point to the
+ //end of the newly added command
+ rptr.lineIndexCounter += restOfCmd.length;
+
+ }
+ else
+ {
+ //the current command line input is ambiguous, or
+ //doesn't match anything at all...print the same
+ //command line input on the next line.
+ //
+
+ //print a newline, the prompt, and the
+ //same command line input, again.
+ output_write("\n");
+ output_write(rptr.PROMPT);
+
+ rptr.INPUT = cmdLineInput;
+ output_write(rptr.INPUT);
+ }
+}
+
+
+
+
+// ***** commands_helpCommand(array) *****
+//IN: commandArray = command array
+//DO: print all of the subcommands of this command,
+// along with their descriptions
+//OUT: a listing of all available subcommands & their descriptions
+function commands_helpCommand(commandArray)
+{
+ var longest = 0; //tmp.var to hold the length of the
+ //longest command name
+
+
+ //this for-loop iterates through all subcommands in 'commandArray'
+ //to find the longest command name, and stores it in 'longest'
+ for (var i=0; i<commandArray.length; i++)
+ {
+ if (commandArray[i].length > longest)
+ {
+ longest = commandArray[i].length;
+ }
+ }
+
+ //for-loop to iterate through all subcommands in 'commandArray'
+ for (var i=0; i<commandArray.length; i++)
+ {
+ // skip commands with no description
+ if (commandArray[commandArray[i]].descript != null)
+ {
+ //print out the subcommand name and description
+ output_write(" " + commandArray[i] + spaces.substring(0,(longest-commandArray[i].length)));
+ if ((longest + 4 + commandArray[commandArray[i]].descript.length) <= 80)
+ {
+ output_write(" " + commandArray[commandArray[i]].descript + "\n");
+ }
+ else
+ {
+ var cutChar = commandArray[commandArray[i]].descript.substring(0,80-4-longest).lastIndexOf(" ");
+ output_write(" " + commandArray[commandArray[i]].descript.substring(0,cutChar) + "\n");
+ output_write(spaces.substring(0,(longest+4)) + commandArray[commandArray[i]].descript.substring((cutChar+1),commandArray[commandArray[i]].descript.length) + "\n");
+ }
+ }
+ }
+
+ //if the enter function exists for this 'commandArray,'
+ //then print " <cr>"
+ _root.deebug1 = commandArray + ";" + typeof(commandArray.enter);
+ if ((typeof(commandArray.enter) == "function") || (commandArray.enter == true))
+ {
+ output_write(" <cr>\n");
+ }
+
+ //newline
+ output_write("\n");
+}
+
+
+
+
+
+// ***** commands_run(str) *****
+// IN: a string of commands to be ran
+// DO: run this line of command
+// NOTE:
+// this function is for testing only
+function commands_run(commands) {
+
+ // use this as a pointer to the active router object
+ var r = eval("_root.r" + _root.active_router);
+
+ // reset the scroll line; for more function
+ r.scrollStartLine = r.lastDLine - 23;
+
+ r.INPUT = commands;
+ output_write(commands);
+ commandline_parseCommandLine(1,1);
+}
+
+
+// ***** displayProtocolDetail(interfacename) *****
+// IN: interface name
+// DO: to display the protocol details when the user type show protocol command
+// NOTE:
+
+function commands_displayProtocolDetail(interfacename)
+{
+ var rptr = eval("_root.r" + _root.active_router + ".run." + interfaceName );
+ if (rptr.shutdown == true)
+ {
+ output_write(interfacename);
+ output_write(" is administratively down, line protocol is down\n");
+ }
+ else
+ {
+ output_write(interfacename);
+ output_write(" is up, line protocol is up\n");
+ }
+
+ if ( rptr.ip != "")
+ {
+ output_write(" Internet address is ");
+ output_write(rptr.ip);
+ output_write("\n");
+ }
+}
+
+
+// ***** displayInterfaceDetail(interfacename) *****
+// IN: interface name
+// DO: to display the interface details when the user type show interface command
+// NOTE:
+
+function commands_displayInterfaceDetail(interfacename)
+{
+ var rptr = eval("_root.r" + _root.active_router + ".run." + interfaceName );
+
+ if (rptr.shutdown == true)
+ {
+ output_write(" is administratively down, line protocol is down\n");
+ }
+ else
+ {
+ output_write(" is up, line protocol is up\n");
+ }
+
+ if (rptr.mac != "")
+ output_write(" Hardware is Lance, address is " + rptr.mac + "(bia " + rptr.mac + ")\n");
+
+ if ( rptr.ip != "")
+ {
+ output_write(" Internet address is ");
+ output_write(rptr.ip);
+ }
+
+ if ( rptr.subnet != "")
+ {
+ output_write("/" + findOneTotal(rptr.subnet));
+ output_write("\n");
+ }
+}
+
+function commands_displayInterfaceE0()
+{
+ output_write(" MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,\n");
+ output_write(" reliability 252/255, txload 1/255, rxload 1/255\n");
+ output_write(" Encapsulation ARPA, loopback not set\n");
+ output_write(" Keepalive set (10 sec)\n");
+ output_write(" ARP type: ARPA, ARP Timeout 04:00:00\n");
+ output_write(" Last input never, output 00:00:20, output hang never\n");
+ output_write(" Last clearing of \"show interface\" counters never\n");
+ output_write(" Queueing strategy: fifo\n");
+ output_write(" Output queue 0/40, 0 drops; input queue 0/75, 0 drops\n");
+ output_write(" 5 minute input rate 0 bits/sec, 0 packets/sec\n");
+ output_write(" 5 minute output rate 0 bits/sec, 0 packets/sec\n");
+ output_write(" 0 packets input, 0 bytes, 0 no buffer\n");
+ output_write(" Received 0 broadcasts, 0 runts, 0 giants, 0 throttles\n");
+ output_write(" 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored\n");
+ output_write(" 0 input packets with dribble condition detected\n");
+ output_write(" 6 packets output, 360 bytes, 0 underruns\n");
+ output_write(" 6 output errors, 0 collisions, 3 interface resets\n");
+ output_write(" 0 babbles, 0 late collision, 0 deferred\n");
+ output_write(" 6 lost carrier, 0 no carrier\n");
+ output_write(" 0 output buffer failures, 0 output buffers swapped out\n");
+}
+
+function commands_displayInterfaceS0()
+{
+ output_write(" Hardware is HD64570\n");
+ output_write(" MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,\n");
+ output_write(" reliability 255/255, txload 1/255, rxload 1/255\n");
+ output_write(" Encapsulation HDLC, loopback not set\n");
+ output_write(" Keepalive set (10 sec)\n");
+ output_write(" Last input never, output never, output hang never\n");
+ output_write(" Last clearing of \"show interface\" counters never\n");
+ output_write(" Input queue: 0/75/0 (size/max/drops); Total output drops: 0\n");
+ output_write(" Queueing strategy: weighted fair\n");
+ output_write(" Output queue: 0/1000/64/0 (size/max total/threshold/drops)\n");
+ output_write(" Conversations 0/0/256 (active/max active/max total)\n");
+ output_write(" Reserved Conversations 0/0 (allocated/max allocated)\n");
+ output_write(" 5 minute input rate 0 bits/sec, 0 packets/sec\n");
+ output_write(" 5 minute output rate 0 bits/sec, 0 packets/sec\n");
+ output_write(" 0 packets input, 0 bytes, 0 no buffer\n");
+ output_write(" Received 0 broadcasts, 0 runts, 0 giants, 0 throttles\n");
+ output_write(" 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort\n");
+ output_write(" 0 packets output, 0 bytes, 0 underruns\n");
+ output_write(" 0 output errors, 0 collisions, 1 interface resets\n");
+ output_write(" 0 output buffer failures, 0 output buffers swapped out\n");
+ output_write(" 0 carrier transitions\n");
+ output_write(" DCD=down DSR=down DTR=down RTS=down CTS=down\n");
+}
+
+
+// ***** findOneTotal(subnetmask) *****
+// IN: subnetmask
+// DO: find the number of continuous one's in an subnet mask
+// NOTE:
+
+function findOneTotal(subnetmask)
+{
+ var total = 0;
+ var ipArray = subnetmask.split(".");
+ if (ipArray.length == 4)
+ {
+ for (var i = 0; i < 4; i++)
+ {
+ total = total + checkBits(ipArray[i]);
+ if ( ( (total % 8) != 0) || (total == 0) )
+ break;
+ }
+ }
+ else
+ {
+ total = 0;
+ }
+
+ return total;
+}
+
+
+
+function checkBits(num)
+{
+ var remainder = 0;
+ var binaryArray = new Array();
+ ctr = 0;
+ if (num == 0)
+ return_value = 0;
+ else
+ return_value = 8;
+
+ while (num > 0)
+ {
+ remainder = num % 2;
+ num = int( num / 2 );
+ binaryArray[ctr] = remainder;
+ ctr = ctr + 1;
+ }
+
+ for (var i = 0; i < binaryArray.length; i++)
+ {
+ if ( binaryArray[binaryArray.length - 1 - i] == 0)
+ {
+ return_value = i;
+ break;
+ }
+ }
+ return return_value;
+}
+
+
+function commands_checkABCD(abcd)
+{
+ var octet = abcd.split(".");
+
+ if (octet.length != 4)
+ return false;
+
+ for (var i=0; i<4; i++)
+ {
+ if (isNaN(octet[i]))
+ return false;
+
+ if ((Number(octet[i]) < 0) || (Number(octet[i]) > 255))
+ return false;
+ }
+
+ return true;
+}
+
+function commands_checkHHH(hhh)
+{
+ var hexPart = hhh.split(".");
+ var hexValue;
+
+ if (hexPart.length != 3)
+ return false;
+
+ for (var i=0; i<3; i++)
+ {
+ hexValue = parseInt(hexPart[i], 16);
+
+ if (isNaN(hexValue))
+ return false;
+
+ if ((hexValue < 0) || (hexValue > 0xffff))
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_history.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_history.txt
new file mode 100644
index 0000000..a3c0c9c
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_history.txt
@@ -0,0 +1,239 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+
+
+
+// ***** history_setHistory() *****
+//IN: rptr.INPUT = the input from the command line
+//DO: store the current input from the command line in the history buffer,
+// if the history buffer becomes full, the oldest command in the buffer is
+// tossed, and all of the other commands are "slid back" to make room
+// for the new one.
+//OUT: updated history buffer
+function history_setHistory() {
+
+ var r = eval("_root.r" + _root.active_router); //'r' is a "pointer" to the active router object
+ var vr = eval("_root.r" + _root.VISIBLE_ROUTER); //'r' is a "pointer" to the visible router object
+ var history; // a pointer to the history object
+
+ //this if-statement points the 'history' ptr to the correct
+ //history buffer to store the command history into
+ if ((r.MODE == "user") || (r.MODE == "enable")) {
+
+ //we are in either "user" or "enable" mode, so the 'history'
+ //ptr should point to the user mode's history buffer.
+//C history = r.userHistory;
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistory;
+ } else {
+
+ //we're in "config" mode, so the 'history' ptr should
+ //point to the config mode's history buffer.
+//C history = r.configHistory;
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistory;
+ }
+
+
+
+ //if the last entry in the history buffer is different than what
+ //was just entered on the command line, this if-statement will
+ //execute to save this command in the history buffer
+ if (history[history.length-1] != vr.INPUT) {
+
+ //store this most recent command from the command line in
+ //the last position of the history buffer (array)
+ history[history.length] = vr.INPUT;
+
+ //if the buffer is over the declared length, remove the
+ //oldest command in the buffer and "shift" every command
+ //up one slot in the history buffer.
+ if (history.length > _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].historyBufferLength) {
+ history.shift();
+ }
+ }
+
+ //update the current length counter of the history buffer
+ //in the router object
+ if ((r.MODE == "user") || (r.MODE == "enable"))
+ {
+ //r.userHistIndex = history.length;
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistIndex = history.length;
+ }
+ else
+ {
+ //r.configHistIndex = history.length;
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistIndex = history.length;
+ }
+
+}
+
+
+
+
+
+// ***** history_historyBackward() *****
+//IN: <none>
+//DO: print the previous input command from the history buffer to the
+// current command line--called when the user is scrolling "backward"
+// through the history of commands.
+//OUT: console is updated to show the previous command in the history
+function history_historyBackward() {
+
+
+ // pointer to the active router object
+ var r = eval("_root.r" + _root.active_router);
+
+ // pointer to the visible router object
+ var vr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ var history; //"pointer" to the history object
+ var histIndex; //tmp.var, index into the history object
+
+ //this if-statement points the 'history' ptr to the correct
+ //history buffer to read the command history from
+ if ((r.MODE == "user") || (r.MODE == "enable")) {
+
+ //we are in either "user" or "enable" mode, so the 'history'
+ //ptr should point to the user mode's history buffer.
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistory;
+
+ //point 'histIndex' to the current element
+ //in the history buffer
+ histIndex = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistIndex;
+
+ } else {
+
+ //we're in "config" mode, so the 'history' ptr should
+ //point to the config mode's history buffer.
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistory;
+
+ //point 'histIndex' to the current element
+ //in the history buffer
+ histIndex = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistIndex;
+ }
+
+
+
+ //this if-statement executes if there are commands left
+ //in the history buffer (before the current one) to display.
+ //if not, then this function simply returns.
+ if (histIndex > 0) {
+
+ //"back up" the current history buffer ptr to the previous command
+ histIndex--;
+
+ //"back up" the current history buffer index to the previous
+ //command in the appropriate router area as well.
+ if ((r.MODE == "user") || (r.MODE == "enable")) {
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistIndex--;
+ } else {
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistIndex--;
+ }
+
+ //replace the last line w/a prompt: remove all characters
+ //displayed on the last line, except for the prompt, and leave
+ //the cursor right after the prompt
+ r.line[r.lastLine] = r.line[r.lastLine].substring(0,r.PROMPT.length);
+
+ //fill the current router's input buffer (rptr.INPUT) with
+ //the previous command from the history buffer...
+ vr.INPUT = history[histIndex];
+
+ //...and print it to the Hyperterminal console.
+ r.lineIndexCounter = r.INPUT.length;
+ output_write(vr.INPUT);
+
+ }
+}
+
+
+
+
+
+// ***** history_historyForward() *****
+//IN: <none>
+//DO: print the next input command from the history buffer to the
+// current command line--called when the user is scrolling "forward"
+// through the history of commands.
+//OUT: console is updated to show the next command in the history
+function history_historyForward() {
+
+
+ var r = eval("_root.r" + _root.active_router); //'rptr' is a "pointer" to the active router object
+ var vr = eval("_root.r" + _root.VISIBLE_ROUTER); //'rptr' is a "pointer" to the visible router object
+ var history; //"pointer" to the history object
+ var histIndex; //tmp.var, index into the history object
+
+ //this if-statement points the 'history' ptr to the correct
+ //history buffer to read the command history from
+ if ((r.MODE == "user") || (r.MODE == "enable")) {
+
+
+ //we are in either "user" or "enable" mode, so the 'history'
+ //ptr should point to the user mode's history buffer.
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistory;
+
+ //point 'histIndex' to the current element
+ //in the history buffer
+ histIndex = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistIndex;
+
+ } else {
+
+ //we're in "config" mode, so the 'history' ptr should
+ //point to the config mode's history buffer.
+ history = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistory;
+
+ //point 'histIndex' to the current element
+ //in the history buffer
+ histIndex = _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistIndex;
+ }
+
+
+
+ //this if-statement executes if there are commands left
+ //in the history buffer (after the current one) to display.
+ //if not, then this function simply returns.
+ if (histIndex < history.length) {
+
+
+ //"advance" the current history buffer ptr to the previous command
+ histIndex++;
+
+ //"back up" the current history buffer index to the previous
+ //command in the appropriate router area as well.
+ if ((r.MODE == "user") || (r.MODE == "enable")) {
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].userHistIndex++;
+ } else {
+ _root.devCmdHist[routerUsedForThisStep[_root.stepnum]].configHistIndex++;
+ }
+
+ //replace the last line w/a prompt: remove all characters
+ //displayed on the last line, except for the prompt, and leave
+ //the cursor right after the prompt
+ r.line[r.lastLine] = r.line[r.lastLine].substring(0,r.PROMPT.length);
+
+ if (histIndex != history.length) {
+
+ //there are more commands following this one in the
+ //history buffer, so fill the current router's input
+ //buffer (rptr.INPUT) with the next command from the
+ //history buffer...
+ vr.INPUT = history[histIndex];
+
+ } else {
+
+ //there are no more commands, print nothing to
+ //the command line
+ vr.INPUT = "";
+ }
+
+
+ //...print the router object command line input buffer
+ //(set by the if-statement above) to the Hyperterminal
+ //console...
+ r.lineIndexCounter = vr.INPUT.length;
+ output_write(vr.INPUT);
+ }
+} \ No newline at end of file
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_manual_scrolling.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_manual_scrolling.txt
new file mode 100644
index 0000000..823022a
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_manual_scrolling.txt
@@ -0,0 +1,176 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+// Modified by Dean Wood 05.10.01
+// Changed hard-coded 7s to cursorXOffset.
+// Changed active_router references to VISIBLE_ROUTER
+// This allows scrolling during telnet sessions
+// Added manual_scrolling_setSlider()
+// Added manual_scrolling_setConent()
+
+// Modified by Dean Wood 05.29.01
+// Added kludge to fix a bug in output_writeOut()
+
+
+// Manual Scrolling
+
+//manual_scrolling_scrollUp()
+//IN: <none>
+//DO: scrolls the current Hyperterminal screen "up" 1 line
+//OUT: the console's output has been scrolled up 1 line
+function manual_scrolling_scrollUp() {
+
+
+ var r = eval("_root.r" + _root.VISIBLE_ROUTER); //ptr to active router object
+ var optr = eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER); //ptr to output (hyperterminal console)
+
+ //r.indexLine = the number of the first line that is showing on the screen.
+ //if it is less than 1 (all of the lines are showing on the screen), then
+ //we can return because there is no need to scroll up.
+ if (r.indexLine < 1) {
+ return;
+ }
+
+
+ //kluge to fix a bug in output_writeOut()
+ if(r.indexLine == r.stopLine)
+ r.indexLine--;
+
+ //decrement the indexLine counter (the lowest line number
+ //currently visible on the screen)
+ r.indexLine--;
+
+ //hide the cursor in the console window, and clear the output.
+ _root.HyperTerminal.cursor._visible = false;
+ optr.output = "";
+
+ //_root.message = _root.VISIBLE_ROUTER + " (Scroll Up):\n";
+ //_root.message += " indexLine = " + r.indexLine + "\n";
+ //_root.message += " lastDLine = " + r.lastDLine + "\n";
+ //_root.message += " lastLine = " + r.lastLine + "\n";
+
+ //output the 24 lines that now fit on the screen (given the updated
+ //indexLine) via optr, the pointer to the Hyperterminal console
+ for (var j = r.indexLine; j < (r.indexLine+24); j++) {
+ //_root.message += " line[" + j + "] = " + r.line[j];
+ optr.output += r.line[j];
+ }
+
+ manual_scrolling_setSlider();
+}
+
+
+
+// manual_scrolling_scrollDown()
+//IN: <none>
+//DO: scrolls the current Hyperterminal screen "down" 1 line
+//OUT: the console's output has been scrolled down 1 line
+function manual_scrolling_scrollDown() {
+
+
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); //ptr to active router object
+ var optr = eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER); //ptr to output (Hyperterminal console)
+
+ //if we are at the last line of the display buffer (we can't scroll down
+ //anymore because we're already at the bottom of the output) then
+ //return.
+ if (rptr.indexLine > rptr.lastDLine-24) {
+ return;
+ }
+
+ //increment the indexLine counter (the lowest line number
+ //currently visible on the screen), and (temporarily) clear
+ //the Hyperterminal output
+ rptr.indexLine++;
+ optr.output = "";
+
+ //_root.message = _root.VISIBLE_ROUTER + " (Scroll Down):\n";
+ //_root.message += " indexLine = " + rptr.indexLine + "\n";
+ //_root.message += " lastDLine = " + rptr.lastDLine + "\n";
+ //_root.message += " lastLine = " + rptr.lastLine + "\n";
+
+ //output the 24 lines that now fit on the screen (given the updated
+ //indexLine) via optr, the pointer to the Hyperterminal console
+ for (var j = rptr.indexLine; j < (rptr.indexLine+24); j++) {
+ //_root.message += " line[" + j + "] = " + rptr.line[j];
+ optr.output += rptr.line[j];
+ }
+
+ manual_scrolling_setSlider();
+
+ if (rptr.indexLine == (rptr.lastDLine-23)) {
+
+ //set the x-position of the cursor to the end of the
+ //last line of displayed output
+ rptr.cursorX = rptr.line[rptr.lastDLine].length;
+
+ // (?)
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+
+ //set the now correctly positioned Hyperterminal cursor to visible
+ _root.HyperTerminal.cursor._visible = true;
+ }
+}
+
+
+// manual_scrolling_setSlider()
+//IN: <none>
+//DO: positions the scroll bar's slider.
+//OUT: the scroll bar's slider has been positioned.
+function manual_scrolling_setSlider() {
+
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); //ptr to active router object
+ var sptr = _root.HyperTerminal.ScrollBar.Slider; //ptr to scroll bar slider
+
+
+ //kluge to fix a bug in output_writeOut()
+ if(rptr.indexLine == rptr.stopLine)
+ rptr.indexLine--;
+
+ var percentage = rptr.indexLine / (rptr.lastDLine - 23);
+ sptr._y = sptr.range * percentage + sptr.min;
+}
+
+
+// manual_scrolling_setContent()
+//IN: <none>
+//DO: positions the content based on the scroll bar's slider position.
+//OUT: the content has been positioned.
+function manual_scrolling_setContent() {
+
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); //ptr to active router object
+ var optr = eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER); //ptr to output (Hyperterminal console)
+ var sptr = _root.HyperTerminal.ScrollBar.Slider; //ptr to scroll bar slider
+
+ var percentage = (sptr._y - sptr.min) / sptr.range;
+ rptr.indexLine = Math.round((rptr.lastDLine - 23) * percentage);
+
+ //temporarily clear the Hyperterminal output
+ optr.output = "";
+
+ //output the 24 lines that now fit on the screen (given the updated
+ //indexLine) via optr, the pointer to the Hyperterminal console
+ for (var i = rptr.indexLine; i < (rptr.indexLine + 24); i++) {
+ optr.output += rptr.line[i];
+ }
+
+ if(rptr.indexLine == (rptr.lastDLine - 23)) {
+
+ //set the x-position of the cursor to the end of the
+ //last line of displayed output
+ rptr.cursorX = rptr.line[rptr.lastDLine].length;
+
+ // (?)
+ _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX;
+
+ //set the now correctly positioned Hyperterminal cursor to visible
+ _root.HyperTerminal.cursor._visible = true;
+ }
+ else {
+
+ //hide the cursor in the console window.
+ _root.HyperTerminal.cursor._visible = false;
+ }
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_output.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_output.txt
new file mode 100644
index 0000000..56b421c
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_output.txt
@@ -0,0 +1,548 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+// Modified by Dean Wood 05.10.01
+// Changed hard-coded 7s to cursorXOffset
+// Changed hard-coded 15s to cursorYOffset
+// Added call to manual_scrolling_setSlider() in output_writeOut()
+// Added call to manual_scrolling_setSlider() in output_writeOneMore()
+
+// output_setCursor()
+// IN : None
+// DO : Sets the cursor placement of the cursor object in the HyperTerminal movieclip
+// OUT: None
+function output_setCursor() {
+
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+ _root.HyperTerminal.cursor._x = (cx + (cursorX * cursorXOffset));
+ }
+}
+
+
+// output_initCursor()
+// IN : None
+// DO : Sets the cursor to invisible and moves it to the correct line
+// OUT: None
+function output_initCursor() {
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+ // set the y position of cursor -> should always be this value
+ _root.HyperTerminal.cursor._y = cy + cursorYOffset * cursorY;
+
+ // set the starting visibility of cursor to false
+ _root.HyperTerminal.cursor._visible = false;
+ }
+}
+
+
+// ***** output_processMore(int) *****
+// IN : An integer representing the key pressed
+// DO : Interpret the key and decide how to continue with the --More--
+// OUT: None
+function output_processMore(keycode) {
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+ // resets the scroll to print more lines
+ scrollStartLine = lastDLine - 23;
+ }
+
+
+ if (commandline_matchKey(keycode," ")) {
+
+ // SPACE is pressed
+ // write one more page
+ output_writeMore();
+
+ } else if (keycode == 13) {
+
+ // ENTER is pressed
+ // write one more line
+ output_writeOneMore();
+
+ } else {
+
+ // all other keys
+ // exit the more state
+ output_exitMore();
+ }
+}
+
+
+
+
+
+// ***** output_writeMore () *****
+// IN : None
+// DO : Write one more page when SPACE is pressed
+// OUT: None
+function output_writeMore() {
+
+
+ // pointer to active router object
+ var r = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // remove the last display line, which is " --More-- "
+ r.line.splice(r.lastDLine,1);
+
+ // let the counter know that a line has been removed
+ r.lastLine--;
+
+
+ if ((r.lastDLine+23) < r.lastLine) {
+
+ // if there is one more page after this page
+ output_write();
+
+ } else {
+
+ //else change the process back to
+ //commandline_processCommandLine and print out
+ //the command prompt
+ commandline_changeProcess("commandline_processCommandLine");
+ commandline_commandLine();
+ }
+}
+
+
+
+
+// ***** output_exitMore () *****
+// IN : None
+// DO : Exits the more state and changes back to the command line
+// OUT: None
+function output_exitMore() {
+
+
+ // change process back to commandline_processCommandLine
+ commandline_changeProcess("commandline_processCommandLine");
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+
+ // turn the more flag off
+ MORE = false;
+
+ // remove the last display line, which is " --More-- "
+ line.splice(lastDLine,1);
+
+ // move the display line back to make up for the removal of " --More-- "
+ lastDLine--;
+
+ // set the current line to the last display line + 1
+ line.length = lastDLine+1;
+ lastLine = lastDLine+1;
+ }
+
+ // put a line of space between the printed info and the command line
+ output_write("\n");
+
+ // print out the command line
+ commandline_commandLine();
+}
+
+
+
+
+
+// ***** output_writeOneMore () *****
+// IN : None
+// DO : Set up the correct printing operations
+// OUT: Write out one line of text and then the " --More-- " cursor
+function output_writeOneMore() {
+
+
+ // pointer to active router object
+ var r = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // remove the last display line, which is " --More-- "
+ r.line.splice(r.lastDLine,1);
+
+ // let the counter know that a line has been removed
+ r.lastLine--;
+
+ // turn the 'one at a time printing method' flag on
+ r.oneMoreLine = true;
+
+ if ((r.lastDLine+1) < r.lastLine) {
+
+ // if there is another line to print, print it
+ output_write();
+
+ } else {
+
+ //else change the process back to
+ //commandline_processCommandLine and print out
+ //the command prompt
+ commandline_changeProcess("commandline_processCommandLine");
+ commandline_commandLine();
+ }
+
+ manual_scrolling_setSlider();
+}
+
+
+
+
+
+// ***** output_write(strings) *****
+// IN : Any number of strings; provided that every argument can only contain
+// ONE "\n" character that must be at the end of the argument.
+// DO : Store the arguments to <line>
+// OUT: None
+function output_write() {
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+
+
+ // if the screen is not already writing
+ if (WRITING == false) {
+
+ // go back to the last screen if user has scrolled to another
+ indexLine = lastDLine - 23;
+
+ // update the new start line for scrolling
+ scrollStartLine = indexLine;
+ }
+
+
+
+ // store each line of text to the line buffer
+ var i=0;
+ var o_f = output_feed;
+ var len = arguments.length
+ for (i=0; i<len; i++) {
+ o_f(arguments[i]);
+ }
+
+
+ // if no more than one page of text
+ if (MORE == false) {
+
+ // set the last display line to the last line in the buffer
+ lastDLine = lastLine;
+
+ // linesToMore is the number of lines to trigger the more function
+ var linesToMore = 46;
+ if (oneMoreLine == true) {
+ linesToMore = 24;
+ }
+
+ // if the number of lines is enough to trigger the More function
+ if ((lastLine-scrollStartLine) > linesToMore) {
+
+ // set the last display line to the starting line of this page plus linesToMore
+ lastDLine = scrollStartLine + linesToMore;
+
+ // add the " --More-- " line to the last display line
+ line.splice(lastDLine,0," --More-- \n");
+
+ // let the counter know you've added a line
+ lastLine++;
+
+ // turn the More function on
+ MORE = true;
+
+ // change process to intepret keys for the more function
+ commandline_changeProcess("output_processMore");
+ }
+ }
+ // if the screen is not already writing..
+ if (WRITING == false) {
+
+ // turn writing on, then call the writeOut function
+ WRITING = true;
+ output_writeOut();
+ }
+ }
+}
+
+
+
+// ***** output_writeOut() *****
+// IN : None
+// DO : Write one line at a time from the line buffer to the screen
+// then scroll down. Plays <delay> movie, and the movie calls
+// this function to print the next line
+// OUT: Writes the line buffer to the HyperTerminal screen
+function output_writeOut() {
+//var startTime = getTimer();
+//trace("startTime = "+ startTime);
+
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+
+
+ // set stop line to different situations
+ if (MORE == true) {
+
+
+ if (oneMoreLine == true) {
+
+ // if we're scrolling one at a time only go forward 2
+ stopLine = scrollStartLine + 2;
+
+ } else {
+
+ // else we're scrolling a page at a time
+ stopLine = scrollStartLine + 24;
+ }
+
+
+ } else {
+
+ // else leave some space from the bottom when we're done
+ stopLine = lastDLine - 22;
+ }
+
+ // if this is before the last line to be printed
+ if (indexLine < stopLine) {
+
+ // first, clear the screen
+ eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER + ".output") = String(""); // clear screen
+
+ // print out 24 lines starting from <indexLine>
+ var i=0;
+ var target_time =0;
+ var i_L = indexLine;
+ for (i=i_L; i<(i_L+24); i++) {
+
+ //looking for PAUSE flag
+ if (line[i] == "PAUSE\n") {
+
+ // replace PAUSE flag with empty line to maintain line cohesion
+ line.splice(i,1,"\n");
+
+ target_time = (getTimer()/1000) + 5; // the time at which to continue
+
+ // waiting for the right time
+ for(;target_time>(getTimer()/1000);){
+ // trying to update clock during wait
+ timer_timeCompute();
+ }
+ }
+
+ // checking for telnet complication
+// if(_root.active_router.isTelnetedInto == false) {
+ eval("_root.HyperTerminal.s" + _root.active_router + ".output") += line[i];
+// } else {
+// eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER + ".output") += line[i];
+// }
+ }
+
+
+ // if this is the last line, then display the cursor
+ if (indexLine == (stopLine-1)) {
+
+ if (MORE == true) {
+ // if we are printing the More cursor, offset it
+ cursorX = 10;
+ } else {
+ //else the cursor is at the normal position
+ cursorX = line[stopLine+22].length;
+ }
+
+ _root.HyperTerminal.cursor._x = cx + cursorXOffset * cursorX;
+
+ // show the cursor
+ _root.HyperTerminal.cursor._visible = true;
+
+ } else {
+
+ // else we hide the cursor
+ _root.HyperTerminal.cursor._visible = false;
+ }
+
+ // check for the possible positions of the index line and correct it
+ if (indexLine == (stopLine-1)) {
+ indexLine++;
+ } else if ((indexLine+3) >= stopLine) {
+ indexLine = stopLine-1;
+ } else {
+ indexLine+=3;
+ }
+
+ // call the delay movie, and the movie will call back this function
+ // to print out the rest of the data
+ tellTarget (delay) {
+ gotoAndPlay(2);
+ }
+
+
+ } else {
+
+ // else everything has been printed and we can stop this loop
+ MORE = false;
+ oneMoreLine = false;
+ WRITING = false;
+
+ manual_scrolling_setSlider();
+ }
+ }
+//var endTime = getTimer();
+//trace("endTime = "+ endTime);
+//trace("elapsed time = " + (endTime-startTime)/1000 + "\n");
+}
+
+
+
+
+
+
+// ***** output_erase(int) *****
+// IN : One integer that is the number of characters to be erased
+// DO : Erase that number of characters
+// OUT: The modified line
+function output_erase(leng) {
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+
+ // take out the specified # of characters from the last element in line
+ line[lastLine] = line[lastLine].substring(0,line[lastLine].length-leng);
+
+ // write out the buffer
+ output_write();
+ }
+}
+
+
+
+
+// ***** output_feed(string) *****
+// IN : 1 line of text from output_write()
+// DO : Store the text to <line>
+// OUT: None
+function output_feed(content) {
+
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+
+
+ //if the line has over 80 characters, it will split
+ //it up into multiple lines.
+
+ while((line[lastLine].length+content.length) > 80) {
+
+ // get the number of characters available on the last line
+ feedLength = 80 - line[lastLine].length;
+
+ // add as much as you can of the input text to the line
+ line[lastLine] += content.substring(0,feedLength) + "\n";
+
+ // subtract the amount given to line from the input
+ content = content.substring(feedLength,content.length);
+
+ // tell the line array that it had another line of text added
+ lastLine++;
+ }
+
+ // add the remaining text to the line buffer
+ line[lastLine] += content;
+
+ // if the last character is "\n", then go to next line
+ if (content.charAt(content.length-1) == "\n") {
+ lastLine++;
+ }
+
+
+ // if buffer is full, then take out first line in buffer
+ while (lastDLine > bufferLength) {
+
+ line.shift();
+ lastLine--;
+ indexLine--;
+ scrollStartLine--;
+ lastDLine--;
+ }
+ }
+}
+
+
+
+
+// NEW BY ZMG
+// ***** output_write2(array[]) *****
+// IN : Any number of strings; provided that every argument can only contain
+// ONE "\n" character that must be at the end of the argument.
+// DO : Store the arguments to <line>
+// OUT: None
+function output_write2(hostname,address,arrayOfStrings) {
+
+ with(eval("_root.r" + _root.VISIBLE_ROUTER)) {
+ var o_f = output_feed;
+ // if the screen is not already writing
+ if (WRITING == false) {
+
+ // go back to the last screen if user has scrolled to another
+ indexLine = lastDLine - 23;
+
+ // update the new start line for scrolling
+ scrollStartLine = indexLine;
+ }
+
+ o_f("\n");
+ if (hostname == "") {
+ o_f("Tracing route to ["+address+"]\n");
+ } else {
+ output_feed("Tracing route to "+hostname+" ["+address+"]\n");
+ }
+ o_f("over a maximum of 30 hops:\n");
+ o_f("\n");
+
+ // store each line of text to the line buffer
+ var i =0;
+ var aos = arrayOfStrings.length
+ for (i=0; i < aos; i++) {
+
+ o_f(arrayOfStrings[i]);
+ }
+
+ o_f("\n");
+ o_f("Trace complete.\n");
+ o_f("\n");
+
+
+ // if no more than one page of text
+ if (MORE == false) {
+
+ // set the last display line to the last line in the buffer
+ lastDLine = lastLine;
+
+ // linesToMore is the number of lines to trigger the more function
+ var linesToMore = 46; //this is an initial value
+ if (oneMoreLine == true) {
+ linesToMore = 24;
+ }
+
+ // if the number of lines is enough to trigger the More function
+ if ((lastLine-scrollStartLine) > linesToMore) {
+
+ // set the last display line to the starting line of this page plus linesToMore
+ lastDLine = scrollStartLine + linesToMore;
+
+ // add the " --More-- " line to the last display line
+ line.splice(lastDLine,0," --More-- \n");
+
+ // let the counter know you've added a line
+ lastLine++;
+
+ // turn the More function on
+ MORE = true;
+
+ // change process to intepret keys for the more function
+ commandline_changeProcess("output_processMore");
+
+ }
+ }
+
+ // if the screen is not already writing..
+ if (WRITING == false) {
+
+ // turn writing on, then call the writeOut function
+ WRITING = true;
+ output_writeOut();
+ //output_setCursor();
+ }
+ }
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_password.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_password.txt
new file mode 100644
index 0000000..6521a86
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_password.txt
@@ -0,0 +1,238 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+
+
+
+// File: actions_password.txt
+// Description: Router password related functions
+
+
+
+
+// password_processPassword(Keycode)
+// IN : Takes one key input from user
+// DO : String together input keys as the password, and give the entered
+// password to password_parsePassword() when <enter> is depressed
+// OUT: None
+function password_processPassword(keycode) {
+
+ // get the active router object
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+
+ if (keycode == 8) {
+
+ // if the key code is BACKSPACE
+ // delete 1 character if INPUT has characters to delete
+ if (rptr.INPUT.length > 0) {
+ rptr.INPUT = rptr.INPUT.substring(0,rptr.INPUT.length-1);
+ }
+
+ } else if (keycode == 13) {
+
+ // if the keycode is ENTER
+ // parse the password in INPUT
+ password_parsePassword();
+
+ } else {
+
+ // else the keycode is part of the password so add it to INPUT
+ rptr.INPUT += chr(keycode);
+ }
+}
+
+
+
+
+// password_parsePassword()
+// IN : active_router.INPUT
+// DO : Takes the input and checks against the password.
+// for line con 0 and enable, parses password
+// OUT: None
+function password_parsePassword() {
+
+ // get the active router object
+ var rptr = eval("_root.r" + _root.active_router);
+
+ // get the visible router object
+ var visrptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // space off the output
+ output_write("\n");
+
+
+ if (rptr.MODE == "startUp") {
+
+ // if we are still in startup mode
+
+
+ //if ((visrptr.INPUT == rptr.run.line.con_password)) {
+ // modified : Sitaram
+ // checking for the vty_password instead of con_password
+ // For telnet, Based on the Real Router, validation of password is done
+ //through vty_passwword
+ if ((visrptr.INPUT == rptr.run.line.vty_password)) {
+ // if the entered password matches the saved password
+ // allow user to have access the router
+ // end of modification : sitaram
+ rptr.passcount = 0;
+
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_setMode("user", _root.active_router);
+ _root.commandline_commandLine();
+
+ } else if ((rptr.passcount == 2)) {
+
+ // else if the user has tried to gain access three times
+ // unsuccessfully, exit the user, return to startup mode
+
+ rptr.passcount = 0;
+
+ var vr = eval("_root.r" + _root.VISIBLE_ROUTER);
+ var r = eval("_root.r" + _root.active_router);
+
+ if(vr.isTelnetingOut == true) {
+ output_write("% Bad passwords\n", "\n");
+ output_write("[Connection to " + TELNET_ADDRESS + " closed by foreign host]\n");
+
+
+ // if we are telneting out
+ // get the variables to reinstate the router
+ var tempmode = vr.telnetPath.pop();
+ var tempname = vr.telnetPath.pop();
+ var tempptr = eval("_root.r" + tempname);
+
+ // resetting the router we came from
+ if(r.wasntStartUp == true) {
+ r.router_startup = false;
+ r.wasntStartUp = false;
+ r.oldMode = "";
+ } else {
+ commandline_setMode(r.oldMode, _root.active_router);
+ r.oldMode = "";
+ }
+
+ _root.active_router = tempname;
+ tempptr.MODE = tempmode;
+
+ if(_root.VISIBLE_ROUTER == tempname) {
+ vr.isTelnetingOut = false;
+ }
+
+ _root.active_router.INPUT = "";
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_commandLine();
+
+ } else {
+ _root.commandline_changeProcess("router_startup_processStartUp");
+ rptr.router_startup = false;
+ _root.router_startup_checkStartUp();
+ }
+ }
+
+
+
+ } else if (rptr.MODE == "user") {
+
+ // modified by sitaram
+ // checking for the enable password also.
+ // user entered both enable and secret password's,
+ // secret password take prescendence over enable
+ // if we are in user mode trying for enable mode
+
+
+ // if the entered password matches the saved password
+ // allow user to have access to enable mode
+
+ if (rptr.run.secret != "") {
+
+ if (visrptr.INPUT == rptr.run.secret) {
+ rptr.passcount = 0;
+
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_setMode("enable", _root.active_router);
+ _root.commandline_commandLine();
+ //added by suresh on 29 march 2002
+ stepnum = stepnum + 1;
+ loadImage(stepnum,stepnum-1);
+ goToNextStep(stepnum, stepnum-1);
+
+
+ } else if (rptr.passcount == 2) {
+
+ // else if the user has tried to gain access three times
+ // unsuccessfully, exit the user, return to user mode
+
+ rptr.passcount = 0;
+
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_setMode("user", _root.active_router);
+ _root.output_write("% Bad secrets\n");
+ _root.commandline_commandLine();
+ }
+ }
+ else if (rptr.run.password != "")
+ {
+
+ if (visrptr.INPUT == rptr.run.password) {
+
+ rptr.passcount = 0;
+
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_setMode("enable", _root.active_router);
+ _root.commandline_commandLine();
+ //added by suresh on 29 march 2002
+ stepnum = stepnum + 1;
+ loadImage(stepnum,stepnum-1);
+ goToNextStep(stepnum, stepnum-1);
+
+
+ } else if (rptr.passcount == 2) {
+
+ // else if the user has tried to gain access three times
+ // unsuccessfully, exit the user, return to user mode
+
+ rptr.passcount = 0;
+
+ _root.commandline_changeProcess("commandline_processCommandLine");
+ _root.commandline_setMode("user", _root.active_router);
+ _root.output_write("% Bad secrets\n");
+ _root.commandline_commandLine();
+ }
+ }
+ }
+
+
+ // print the password prompt again if the user has not entered the
+ // correct password for the first or second time
+ if (processName == "password_processPassword") {
+ rptr.passcount++;
+ password_passwordLine();
+ }
+}
+
+
+
+
+
+// password_passwordLine()
+// IN : None
+// DO : Prompts the user for a password
+// OUT: Password prompt
+function password_passwordLine() {
+
+ // get the active router object
+ var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
+
+ // clear the input buffer for the router
+ rptr.INPUT = "";
+
+ // print the password prompt
+ output_write("Password:");
+
+ // create the global COMMAND array
+ COMMAND = new Array();
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router.txt
new file mode 100644
index 0000000..aeea2f8
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router.txt
@@ -0,0 +1,257 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+// Modified by Dean Wood 05.10.01
+// Changed cursor initialization.
+// Added cursorXOffset and cursorYOffset.
+
+
+
+// ROUTER CONFIGURATION FILES
+// FILE: actions_router_object.txt
+// description: objects for a Router
+
+// Router Object Hierarchy
+/* Router
+ ___|____
+ / \
+ / \
+ / \
+ / \
+ / \
+ / \
+ / \
+ / \
+ run startup_file
+ ___|______ _____|______
+ / | | | | \ / | | | | \
+ / | | | | \ / | | | | \
+ / | | | | \ / | | | | \
+ / / | \ \ \ / / | \ \ \
+ / / | \ \ \ / / | \ \ \
+ / / | \ \ \ / / | \ \ \
+ / / | \ \ \ / / | \ \ \
+line global e0 e1 s0 s1 line global e0 e1 s0 s1
+
+*/
+
+// line configuration
+// IN : None
+// DO : Initialize logins and passwords for aux, con, and vty
+// OUT: None
+function router_line() {
+ this.aux_login = false; //auxiliary login
+ this.aux_password = ""; //auxiliary password
+ this.con_login = false; // console login
+ this.con_password = ""; //console password
+ this.vty_login = false; //virtual terminal login
+ this.vty_password = ""; //virtualterminal password
+}
+
+
+
+// global configuration
+// IN : None
+// DO : Initializes the RIP and IGRP networks and the ipHost
+// OUT: None
+function router_global() {
+
+ // creating the RIP network
+ this.RIP = false;
+ this.RIP_network = new Array();
+
+ // creating the IGRP network
+ this.IGRP = false;
+ this.IGRP_network = new Array();
+ this.IGRP_AS = "";
+
+ // creating the ip host table
+
+ //The ip Host Table for the router, the 2-D array of IP addresses
+ this.ipHostAddressTable = new Array();
+
+ //The ip Host Table for the router, the 1-D array of host names
+ this.ipHostNameTable = new Array();
+
+ // temporary string, used to help fill elements for ipHostNameTable
+ this.ipHostNameTableTemp = "";
+
+ // a true/false state variable
+ this.errorCondition = false;
+
+ // counter for # of hosts in ip host table
+ this.hostCounter = 0;
+
+ // setting ip routing
+ this.ip_routing = true;
+
+ // initializing banner motd variables
+ this.bannermotd = "";
+ this.bannerdelimit = "";
+
+}
+
+
+
+
+// interface configuration
+// IN : None
+// DO : Initialize the interface
+// OUT: None
+function router_interface() {
+ this.exist = false; // determine if interface is there or not
+ this.description = ""; // interface description
+ this.mac = "";//utility_randomMAC(); -- commented by suresh as mac is burnt into the hardware and not a random number
+ this.ip = ""; //ip address of interface
+ this.subnet = ""; // subnet mask
+ this.networkBits = 0 // number of network bits
+ this.subnetted = false; // has the interface been subnetted
+ this.netPart = ""; // The network this interface belongs to
+ this.subnetPart = ""; // the subnetwork this interface belongs to
+ this.shutdown = true; // shutdown ?
+ this.clockrate = ""; // used only by serial 0
+
+}
+
+
+
+
+// router_configFile()
+// IN : None
+// DO : Configure the router
+// OUT: None
+function router_configFile() {
+
+ this.hostname = "Router"; //Router hostname
+ this.secret = ""; // secret password (enable secret)
+// modified : Sitaram
+// for As per the suggestions made by Ray, along with secret password
+// storing the information of enable password
+// added for storing the enable password
+ this.password = "";//password
+// end of modification : Sitaram
+
+ // Link all together for usage
+ this.line = new router_line();
+ this.global = new router_global();
+
+ // initialize the interfaces
+ this.e0 = new router_interface();
+ this.e1 = new router_interface();
+ this.s0 = new router_interface();
+ this.s1 = new router_interface();
+}
+
+
+
+
+// Router object
+// Router()
+// IN : None
+// DO : Create a router object
+// OUT: None
+function Router() {
+
+ // make this router's current process the command line
+ this.processCurrent = "commandline_processCommandLine";
+ this.passcount = 0;
+
+ this.current_num = -1; // current interface number
+
+ this.router_startup = false; // if false, start router
+
+ //Router related items
+ this.copied = false; //running copied to startup ? true or false
+ this.MODE = ""; // Router mode (user, enable, global, line, interface, router)
+ this.stat = ""; // Router status (password, normal)
+
+ // Router's current window
+ //this.LineLength = 0;
+ //this.LineNumber = 0;
+ //this.Length = 0;
+ //this.PromptLength = 0;
+ //this.Prompt = "";
+ //this.CL = ""; // command line
+ //this.output = "";
+
+ // need cursor status here
+ //this.cx = -364.4; // initial place
+ //this.cy = -124.2; // initial place
+ this.cx = _root.HyperTerminal.cursor._x; // initial place
+ this.cy = _root.HyperTerminal.cursor._y; // initial place
+
+ // cursor offset
+ this.cursorXOffset = 6.6; // x position increment value
+ this.cursorYOffset = 13.6; // y position increment value
+
+ // cursor
+ this.cursorX = 0; // x position of cursor from 0 to 79
+ this.cursorY = 23; // y position of cursor from 0 to 23
+
+ //added for commandline enhancements
+ this.controlCharPressed = 0;
+ this.lineIndexCounter = 0;
+
+ // creating buffer
+ this.bufferLength = 500; // length of buffer for hyperterminal
+ this.line = new Array(bufferLength); // an array containing all the text that showed up on screen up to bufferLength of lines
+ this.lastLine = 24; // the last line number of the buffer; NOT the same as line.length
+ this.indexLine = 0; // the starting line number that is currently on screen
+ this.lastDLine = 24;
+ this.stopLine = 0;
+
+ // at the start the MORE functions are off
+ this.oneMoreLine = false;
+ this.MORE = false;
+ this.scrollStartLine = 0;
+ this.WRITING = false; // true if it is autoscroll printing
+ this.HELPING = false; // true if user typed "?"
+
+ // initial prompt
+ this.PROMPT = this.run.hostname + ">";
+
+ // string of input from the user
+ this.INPUT = ""; // input at the command line; the whole string including all spaces
+
+ // History Command Settings and initialization
+ this.historyBufferLength = 10;
+ this.userHistory = new Array();
+ this.configHistory = new Array();
+ this.userHistIndex;
+ this.configHistIndex;
+ this.histcurrent = histIndex+1;
+
+ this.run = new router_configFile();
+ this.startup_file = new router_configFile();
+
+ // Telnet variables
+ this.isTelnetingOut = false;
+ this.oldMode = "";
+ this.telnetSessions = new Array("","","","","");
+ this.telnetPath = new Array();
+ this.wasntStartup = false;
+ // modified : Sitaram
+ // Before configuration show startup, shouldn't show any information
+ // eraseFlag is used for validating whether user has configured the router.
+ this.eraseFlag = false;
+}
+
+
+
+// router_createRouter(r)
+// IN : The router's name
+// DO : Creates a router depending on name of 'r'
+// OUT: A route object with the name "rRoutername"
+function router_createRouter(r) {
+
+ // initialize the router
+ eval("r" + r) = new Router();
+
+ // line buffer init -
+ // initialize the first 24 lines to be blank
+ var rptr = eval("_root.r" + r);
+ for (var ijk=0; ijk<24; ijk++) {
+ rptr.line[ijk] = "\n";
+ }
+} \ No newline at end of file
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router_startup.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router_startup.txt
new file mode 100644
index 0000000..96b909a
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router_startup.txt
@@ -0,0 +1,173 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+
+
+
+// File: actions_router_startup.txt
+// Description: Functions related to when a router is starting up
+
+// router_startup_checkStartUp()
+// IN : None
+// DO : See if we need the active router needs to be started
+// OUT: None
+function router_startup_checkStartUp() {
+
+ // get active router
+ var rptr = eval("_root.r" + _root.active_router);
+
+ // see if the router has been started
+ if (rptr.router_startup == false && !_root.isComputer())
+ {
+ // if it hasn't been started, start it
+ rptr.MODE = "startUp";
+ commandline_changeProcess("router_startup_processStartUp");
+
+ // update startup flag
+ rptr.router_startup = true;
+
+ // go to the start up routine
+ _root.router_startup_startUp();
+
+ }
+ else if (_root.isComputer())
+ {
+ rptr.MODE = "startUp";
+ commandline_changeProcess("computer_startup_processStartUp");
+ rptr.router_startup = true;
+ _root.computer_startup_startUp();
+ }
+ else
+ {
+ // else the router has been started and we can continue
+ commandline_changeProcess(rptr.processCurrent);
+ }
+
+}
+
+
+
+
+
+// ***** router_startup_processStartUp(int) *****
+// IN: 1 int representing the keycode of the key pressed
+// DO: if ENTER, then go to command line, else do nothing
+// OUT: Possibly a 'User Access Verification' message
+function router_startup_processStartUp(keycode) {
+
+ // get the active router
+ var rptr = eval("_root.r" + _root.active_router);
+
+ // if ENTER, go to command line
+ if (keycode == 13) {
+
+ rptr.scrollStartLine = rptr.lastLine-22; // for more function
+
+ // get the MOTD
+ //_root.CheckBannerMOTD();
+ _root.banner_checkBannerMOTD();
+
+ // if the router requires a password and one has been specified
+ if ((rptr.run.line.con_password != "") && (rptr.run.line.con_login == true)) {
+
+ // print the user access message and go to password prompt
+ output_write("User Access Verification\n",
+ "\n");
+ _root.commandline_changeProcess("password_processPassword");
+ password_passwordLine();
+
+ } else {
+
+ // else no password is required, so go to user command line
+// commandline_setMode("user", _root.active_router);
+ commandline_changeProcess("commandline_processCommandLine");
+// output_write("\n");
+// commandline_commandLine();
+ }
+ //calling the lab-drill object step 1
+ loadImage(1,_root.stepnum);
+ _root.goToNextStep(1,0);
+
+ //code added 3 Lines below on April 11 2002 just in case if we need to go a particulat step right in the begining...
+// if (stepModeArray[1] != "user")
+// {
+ commandline_setMode(stepModeArray[1], _root.active_router);
+ output_write("\n");
+ commandline_commandLine();
+// }
+ }
+}
+
+function computer_startup_processStartUp(keycode)
+{
+ // get the active router
+ var rptr = eval("_root.r" + _root.active_router);
+
+ // if ENTER, go to command line
+ if (keycode == 13)
+ {
+ rptr.scrollStartLine = rptr.lastLine-22; // for more function
+
+ //calling the lab-drill object step 1
+ loadImage(1,_root.stepnum);
+ _root.goToNextStep(1,0);
+
+ commandline_changeProcess("commandline_processCommandLine");
+ commandline_setMode(stepModeArray[1], _root.active_router);
+ output_write("\n");
+ commandline_commandLine();
+ }
+}
+
+function computer_startup_startUp()
+{
+ var rptr = eval("_root.r" + _root.active_router);
+
+ output_write("\n");
+ rptr.scrollStartLine++; // increment the start line
+
+ output_write("\n",
+ "Starting Computer...","\n","\n","\n","\n");
+}
+
+
+
+
+// ***** router_startup_startUp() *****
+// IN : None
+// DO : Prints out the start up screen
+// OUT: The start up screen
+function router_startup_startUp() {
+
+ // get the active router
+ var rptr = eval("_root.r" + _root.active_router);
+
+ output_write("\n");
+ rptr.scrollStartLine++; // increment the start line
+
+ // print the start screen
+ output_write("\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ rptr.run.hostname + " con0 is now available\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "Press RETURN to get started.\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n");
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_scenario.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_scenario.txt
new file mode 100644
index 0000000..90ae742
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_scenario.txt
@@ -0,0 +1,176 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+// File modified by Ryley Gahagan 3.7.01
+
+
+// File: actions_scenario.txt
+// Description: SCENARIO functions
+
+// scenario_startScenario()
+// IN : None
+// DO : Creates the 5 Routers and its checklist then starts everything running with RouterA
+// OUT: None
+function scenario_startScenario() {
+
+ // pointer that will be assigned to the various routers
+ // used in this function
+ var rptr = null;
+
+ // **** create RouterA ****
+ router_createRouter("RouterA");
+// commandline_setMode(StepModeArray[0], "RouterA");
+/*
+ // create interfraces for running-config
+ rptr = eval("_root.rRouterA.run");
+ rptr.e0.exist = true;
+ rptr.e1.exist = true;
+ rptr.s0.exist = true;
+
+ // create interfaces for startup-config
+ rptr = eval("_root.rRouterA.startup_file");
+ rptr.e0.exist = true;
+ rptr.e1.exist = true;
+ rptr.s0.exist = true;
+
+ // create the routing table
+ rptr = eval("_root.rRouterA");
+ rptr.routingtable = new routing_table_tableA();
+
+ // setting the mac addresses
+ rptr.run.e0.mac = "0010.7b81.4e2c";
+ rptr.run.e1.mac = "0010.7b81.4e2d";
+*/
+ // **** end RouterA ****
+
+ // **** create RouterB ****
+ router_createRouter("RouterB");
+/* commandline_setMode("user", "RouterB");
+
+ // create interfraces for running-config
+ rptr = eval("_root.rRouterB.run");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+
+ // create interfaces for startup-config
+ rptr = eval("_root.rRouterB.startup_file");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+
+ // create the routing table
+ rptr = eval("_root.rRouterB");
+ rptr.routingtable = new routing_table_tableB();
+
+ // setting the mac addresses
+ rptr.run.e0.mac = "00d0.58ac.ec1f";
+
+ // **** end RouterB ****
+
+ // **** create RouterC ****
+ router_createRouter("RouterC");
+ commandline_setMode("user", "RouterC");
+
+ // create interfraces for running-config
+ rptr = eval("_root.rRouterC.run");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+
+ // create interfaces for startup-config
+ rptr = eval("_root.rRouterC.startup_file");
+ rptr.e0.exist = true;
+ rptr.s0.exist = true;
+ rptr.s1.exist = true;
+
+ // create the routing table
+ rptr = eval("_root.rRouterC");
+ rptr.routingtable = new routing_table_tableC();
+
+ // setting the mac addresses
+ rptr.run.e0.mac = "00d0.58ac.ec1c";
+
+ // **** end RouterC ****
+
+ // **** create RouterD ****
+ router_createRouter("RouterD");
+ commandline_setMode("user", "RouterD");
+
+ // create interfraces for running-config
+ rptr = eval("_root.rRouterD.run");
+ rptr.e0.exist = true;
+ rptr.s1.exist = true;
+
+ // create interfaces for startup-config
+ rptr = eval("_root.rRouterD.startup_file");
+ rptr.e0.exist = true;
+ rptr.s1.exist = true;
+
+ // create the routing table
+ rptr = eval("_root.rRouterD");
+ rptr.routingtable = new routing_table_tableD();
+
+ // setting the mac addresses
+ rptr.run.e0.mac = "00d0.58ac.ec25";
+
+ // **** end RouterD ****
+
+ // **** create RouterE ****
+ router_createRouter("RouterE");
+ commandline_setMode("user", "RouterE");
+
+ // create interfraces for running-config
+ rptr = eval("_root.rRouterE.run");
+ rptr.e0.exist = true;
+
+ // create interfaces for startup-config
+ rptr = eval("_root.rRouterE.startup_file");
+ rptr.e0.exist = true;
+
+ // create the routing table
+ rptr = eval("_root.rRouterE");
+ rptr.routingtable = new routing_table_tableE();
+
+ // setting the mac addresses
+ rptr.run.e0.mac = "00d0.58ac.ec28";
+
+ // **** end RouterE ****
+*/
+ // **** Checklist Creation ****
+ router_createRouter("CheckRouterA");
+ router_createRouter("CheckRouterB");
+// router_createRouter("CheckRouterC");
+// router_createRouter("CheckRouterD");
+// router_createRouter("CheckRouterE");
+// checklist_setChecklist();
+ // **** end Checklist ****
+
+ // **** Create default router ****
+ router_createRouter("default");
+
+ // set RouterA as the starting router
+ _root.Menu.mRouterA._visible = false;
+ _root.HyperTerminal.sRouterA._visible = true;
+ _root.active_router = "RouterA"; // Current ROUTER
+ _root.VISIBLE_ROUTER = "RouterA";
+
+ changeRouterInformation(routerUsedForThisStep[0]); //setting the router information is done here
+
+ _root.output_initCursor();
+
+ _root.router_startup_checkStartUp();
+
+ //copy the below information from data.txt file 29 March 2002
+
+ //Router Name
+ //_root.rRouterA.run.hostname = "Lab_A";
+
+ //Enable Password
+ //_root.rRouterA.run.password = "class";
+
+ //Enable Secret
+ //_root.rRouterA.run.secret = "";
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt
new file mode 100644
index 0000000..909b3b7
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt
@@ -0,0 +1,30 @@
+// Timing Functions
+
+StartTime = null; // this variable is set when the start button is pressed
+ // so that the user is not penalized for the loading time of flash
+
+// timer_timeCompute()
+// IN : none
+// DO : calculates the minutes and seconds elapsed since the user began the simulation
+// OUT: print it out into a text field
+
+function timer_timeCompute()
+{
+ var CurrentTime = (getTimer()-StartTime)/1000; // gets the current time in milliseconds, subtracts the starttime,
+ // and converts it into seconds.
+
+ var Minute = Math.floor(CurrentTime/60); // get # of minutes in current time
+ var Second = Math.floor(((CurrentTime/60) - Minute) * 60); // get # of seconds in current time
+
+ if ((Minute.toString()).length == 1) {
+ // adding a zero to # of minutes if it is less than 10 for correct display
+ Minute = "0" + Minute;
+ }
+
+ if ((Second.toString()).length == 1) {
+ // adding a zero to # of seconds if it is less than 10 for correct display
+ Second = "0" + Second;
+ }
+
+ _root.Menu.Clock.TIME = Minute + ":" + Second; // display time elapsed
+} \ No newline at end of file
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_utility.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_utility.txt
new file mode 100644
index 0000000..5cc85ac
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_utility.txt
@@ -0,0 +1,178 @@
+//zmg, 03.01.01
+//this file needs a better description!
+//
+//
+
+
+
+
+
+// Utility functions
+
+
+
+
+// FIle: actions_misc.txt
+// Description: Miscellenous functions
+
+
+// utility_hideAll()
+// IN : None
+// DO : Hide all unutilized movie clips
+// OUT: None
+function utility_hideAll() {
+ _root.Instructions._visible = false;
+ _root.Topology._visible = false;
+ _root.Done._visible = false;
+}
+
+
+
+
+// utility_updateText()
+// IN : None
+// DO : Updates text for Menu buttons (i.e. hide/show instructions, toplogy, done)
+// OUT: None
+function utility_updateText() {
+
+
+ tellTarget("Menu") {
+
+ instructiontext = "Show Instructions";
+ topologytext = "Show Topology";
+ donetext = "Show Done";
+ }
+}
+
+
+
+
+// utility_setVisible(b)
+// IN : The router object that is to be set
+// DO : Sets visibility of buttons for Routers and the screen
+// OUT: None
+function utility_setVisible(b) {
+
+ // set the visibility of the router's menu button to true
+ with(eval("_root.Menu.m" + b)) {
+ _visible = true;
+ }
+
+ // set the visibility of the router's hyperterminal to false
+ with(eval("_root.HyperTerminal.s" + b)) {
+ _visible = false;
+ }
+}
+
+
+
+
+// ***** utility_randomMAC() *****
+// IN : None
+// DO : Calculates a random 12-digit MAC address in the following hex format:
+// 0060.5cf4.c677
+// OUT: Returns the random address generated
+function utility_randomMAC() {
+
+
+ // an array of possible hex numerals
+ var hex = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
+
+ var mac = ""; // container for the random address
+
+ // pull 12 random elements out of the hex array
+ // put a '.' seperator between each group of four
+ for (var i=0; i<12; i++)
+ {
+ mac += hex[Math.round(Math.random()*15)];
+
+ // adding the '.' seperator after the 4th and 8th numerals
+ if(i == 3 || i == 7)
+ mac += ".";
+ }
+
+ return mac;
+}
+
+
+
+function utility_switchToNewRouter() {
+
+ //the visible router isnt telnetted anywhere,
+ //switch over to this new router like normal
+
+ // turning on the correct router
+ if (BUTTONROUTER == "RouterA") {
+
+ // turn visibility to nil
+ _root.Menu.mRouterA._visible = false;
+ _root.HyperTerminal.sRouterA._visible = true;
+ _root.utility_setVisible(_root.VISIBLE_ROUTER);
+
+ _root.active_router = "RouterA";
+ _root.VISIBLE_ROUTER = "RouterA";
+ _root.utility_hideAll();
+ _root.utility_updateText();
+
+ _root.router_startup_checkStartUp();
+ _root.output_setCursor();
+
+ } else if (BUTTONROUTER == "RouterB") {
+ // turn visibility to nil
+ _root.Menu.mRouterB._visible = false;
+ _root.HyperTerminal.sRouterB._visible = true;
+ _root.utility_setVisible(_root.VISIBLE_ROUTER);
+
+ _root.active_router = "RouterB";
+ _root.VISIBLE_ROUTER = "RouterB";
+ _root.utility_hideAll();
+ _root.utility_updateText();
+
+ _root.router_startup_checkStartUp();
+ _root.output_setCursor();
+
+ } else if (BUTTONROUTER == "RouterC") {
+ // turn visibility to nil
+ _root.Menu.mRouterC._visible = false;
+ _root.HyperTerminal.sRouterC._visible = true;
+ _root.utility_setVisible(_root.VISIBLE_ROUTER);
+
+ _root.active_router = "RouterC";
+ _root.VISIBLE_ROUTER = "RouterC";
+ _root.utility_hideAll();
+ _root.utility_updateText();
+
+ _root.router_startup_checkStartUp();
+ _root.output_setCursor();
+
+ } else if (BUTTONROUTER == "RouterD") {
+ // turn visibility to nil
+ _root.Menu.mRouterD._visible = false;
+ _root.HyperTerminal.sRouterD._visible = true;
+ _root.utility_setVisible(_root.VISIBLE_ROUTER);
+
+ _root.active_router = "RouterD";
+ _root.VISIBLE_ROUTER = "RouterD";
+ _root.utility_hideAll();
+ _root.utility_updateText();
+
+ _root.router_startup_checkStartUp();
+ _root.output_setCursor();
+
+ } else if (BUTTONROUTER == "RouterE") {
+ // turn visibility to nil
+ _root.Menu.mRouterE._visible = false;
+ _root.HyperTerminal.sRouterE._visible = true;
+ _root.utility_setVisible(_root.VISIBLE_ROUTER);
+
+ _root.active_router = "RouterE";
+ _root.VISIBLE_ROUTER = "RouterE";
+ _root.utility_hideAll();
+ _root.utility_updateText();
+
+ _root.router_startup_checkStartUp();
+ _root.output_setCursor();
+ }
+
+}
+
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/answer.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/answer.txt
new file mode 100644
index 0000000..808e24a
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/answer.txt
@@ -0,0 +1,190 @@
+var currentAnswerPtr = 1;
+var showAns = false;
+var stepBeforeAnswer = 0;
+
+function showAnswer(stepNum)
+{
+ var indexvalue = 0;
+ var ptr = null;
+ var prompt = "";
+ var ctr = 0;
+
+ if (showAns == true)
+ {
+
+ answerInitialize(true);
+
+ goToNextStep(stepNum, stepNum);
+
+/*
+ for (i=0;i<AnswerArray.length;i++)
+ {
+ if (AnswerArray[i].stepnum == stepNum)
+ {
+ indexvalue = i;
+ break;
+ }
+ }
+*/
+ indexvalue = stepnum;
+
+ /* We don't have sub command anymores
+ //check to see if it has subcommands
+ if (AnswerArray[indexvalue].substep == true)
+ {
+ var ctr = indexvalue;
+ while ((AnswerArray[ctr].stepnum == stepNum) && (AnswerArray[ctr].substep == true) )
+ {
+ expandCommand(stepNum,ctr);
+ ctr = ctr + 1;
+ }
+ }
+ else
+ {
+ expandCommand(stepNum,indexvalue);
+ }
+ */
+ expandCommand(stepNum,indexvalue);
+ }
+}
+
+function expandCommand(stepNum,index)
+{
+ prompt = getPrompt(StepModeArray[stepNum]);
+ writeToRouter(prompt);
+ writeToRouter(AnswerArray[index][0].commandName);
+ for (i=1; i < 16; i++)
+ {
+ ptr = AnswerArray[index][0];
+ if ( eval("ptr.param" + i).length > 0)
+ writeToRouter(" " + eval("ptr.param" + i));
+ }
+ writeToRouter("\n");
+
+ if(AnswerArray[index+1][0].stepnum == AnswerArray[index][0].stepnum
+ && AnswerArray[index+1][0].matrixCheck == True
+ && AnswerArray[index][0].matrixCheck == True)
+ {
+ expandCommand(stepNum, index + 1); //recursion to show all answers (it works :P)
+ //Tony's answer to solve missing show answer steps 2/07/03
+ }
+}
+
+function writeToRouter(Str)
+{
+ _root.HyperTerminal.sRouterB.output += Str;
+}
+
+function answerInitialize(flag)
+{
+ if (flag)
+ {
+ _root.HyperTerminal.sRouterB.output = "";
+ _root.HyperTerminal.sRouterB._visible = true;
+ _root.HyperTerminal.sRouterA._visible = false;
+ _root.HyperTerminal.cursor._visible = false;
+ }
+ else
+ {
+ _root.HyperTerminal.sRouterB.output = "";
+ _root.HyperTerminal.sRouterB._visible = false;
+ _root.HyperTerminal.sRouterA._visible = true;
+ _root.HyperTerminal.cursor._visible = true;
+ }
+}
+
+function getPrompt(arg1)
+{
+var stepDevice = _root.routerInfoArray[_root.routerUsedForThisStep[_root.stepnum]].deviceType;
+ //holds the string that is the new prompt
+ var p = "";
+ if (arg1 == "user") {
+
+ if (stepDevice != "Switch 4006 Sup 2")
+ p = ">";
+ else
+ p = "> ";
+
+ } else if (arg1 == "enable") {
+
+ if (stepDevice != "Switch 4006 Sup 2")
+ p = "#";
+ else
+ p = "> (enable) ";
+
+ } else if (arg1 == "global") {
+
+ p = "(config)#";
+
+ }
+
+ else if (arg1.substr(0, 3) == "int") {
+ p = "(config-if)#";
+ }
+
+ else if (arg1.substr(0, 3) == "sub") {
+ p = "(config-subif)#";
+ }
+
+ else if (arg1.substr(0, 4) == "line") {
+ p = "(config-line)#";
+ }
+
+ else if (arg1.substr(0, 6) == "router") {
+ p = "(config-router)#";
+ }
+
+ else if (arg1.indexOf("controller") == 0) {
+ p = "(config-controller)#";
+ }
+
+ else if (arg1.indexOf("extNacl") == 0) {
+ p = "(config-ext-nacl)#";
+ }
+
+ else if (arg1.indexOf("mapClass") == 0) {
+ p = "(config-map-class)#";
+ }
+
+ else if (arg1.indexOf("timeRange") == 0) {
+ p = "(config-time-range)#";
+ }
+
+ else if (arg1.indexOf("dhcp") == 0) {
+ p = "(dhcp-config)#";
+ }
+
+ else if (arg1.indexOf("routeMap") == 0) {
+ p = "(config-route-map)#";
+ }
+
+ else if (arg1.indexOf("classMap") == 0) {
+ p = "(config-cmap)#";
+ }
+
+ else if (arg1.indexOf("policyMap") == 0) {
+ p = "(config-pmap)#";
+ }
+
+ else if (arg1.indexOf("policyMapClass") == 0) {
+ p = "(config-pmap-c)#";
+ }
+
+ else if (arg1 == "vlanDB") {
+ p = "(vlan)#";
+ }
+ else if (arg1 == "ATMPVC") {
+ p = "(config-if-atm-vc)#";
+ }
+ else if (arg1 == "DOS")
+ {
+ p = " C:\\>";
+ }
+ else if (arg1 == "NameOnly")
+ {
+ p = "";
+ }
+trace("p = " + p);
+ //set the new prompt and mode on the router in question
+ return _root.rRouterA.run.hostname + p;
+}
diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.bak2.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.bak2.txt
new file mode 100644
index 0000000..e1cdecd
--- /dev/null
+++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.bak2.txt
@@ -0,0 +1,1039 @@
+/***********************
+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 steps
+
+ // check if matrix check is on, if it is, check the answer with all relevent substeps
+ if(matrix != null)
+ {
+ if(labDrill == "False")
+ {
+ // find the correct indexvalue that matches this substep
+ for(matrixOffset = 0; (matrixOffset < matrix.length); matrixOffset++)
+ {
+ // go through all the alternate steps
+ for(var i = alternateOffset; (i< AnswerArray[_root.stepnum + matrixOffset].length) && (AnswerArray[_root.stepnum + matrixOffset][i].matrixCheck == true) && (AnswerArray[_root.stepnum+matrixOffset][i].stepnum == AnswerArray[_root.stepnum][i].stepnum); i++)
+ {
+
+ if(matrix[matrixOffset] == false)
+ {
+ 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
+ {
+ for(matrixOffset = 0; (matrixOffset < matrix.length); matrixOffset++)
+ {
+ for(var i =alternateOffset; (i<AnswerArray[_root.stepnum+matrixOffset].length)&&(AnswerArray[_root.stepnum + matrixOffset][i].matrixCheck == true)&&(AnswerArray[_root.stepnum+matrixOffset][i].stepnum == AnswerArray[_root.stepnum][i].stepnum);i++)
+ {
+
+ if(matrix[matrixOffset] == false)
+ {
+ 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")
+ {
+ 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
+ {
+ 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)
+ if(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;
+ }
+ }
+ }
+ if(found == true)
+ {
+ snum = _root.stepnum + matrixOffset;
+ //msgNotice("found =true");
+ alternateOffset = i;
+ break;
+ }
+ }
+ if(found == true)
+ {
+ break;
+ }
+ }
+ }
+
+ // 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
+ {
+ errorstring = rptr.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();
+ }
+ }
+ }
+}
+
+
+// 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)
+{
+
+ // miwang
+ 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;
+
+
+ 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 + chapterCovered +"/"+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
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