/*********************** 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 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 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 = "

" + str + "

"; _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 = "

" + str + "

"; _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 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 0) stepStr = "" + AnswerArray[num][0].stepnum + "." + substepNumber + "
"; } // initialize the menu instructions if(matrix != null) { _root.menu.instr = "" + stepStr; for(var i = 0; i

"; else if(matrix[i] == false) _root.menu.instr += instructionArray[num+i] + "

"; } _root.menu.instr += "
"; } else _root.menu.instr = "" + stepStr + instructionArray[num] + ""; /*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; }