//modified by Bargavi //to be compatible with flashMX /*********************** 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 = "" // Commented out by Dean Wood 2/4/2003 // Changing the step image to be viewed as the topology. //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 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 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 successfully 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 successfully completed the e-Lab Activity.\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) { return; } } // unload the commands because there are no later steps that use it. // eval(CurrentMode +"C") = new Array(); createArray(currentMode);//Bargavi with ( 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 = "Step " + AnswerArray[num][0].stepnum + "." + substepNumber + "

"; else stepStr = "Step " + AnswerArray[num][0].stepnum + "

"; } // Modified by Dean Wood 2/6/2003 - removed bold tags. // initialize the menu instructions if(matrix != null) { _root.menu.instr.htmlText = stepStr; //Bargavi for Mx for(var i = 0; i" + instructionArray[num+i] + "

"; //Bargavi for Mx else if(matrix[i] == false) _root.menu.instr.htmlText += instructionArray[num+i] + "

"; //Bargavi for Mx } } else _root.menu.instr.htmlText = stepStr + instructionArray[num];//Bargavi for Mx _root.menu.instr.scroll = 1; _root.menu.ScrollBar.Slider._y = _root.menu.ScrollBar.Slider.min; /*var i = 0; while (outputString != "") { if (outputString.length > 21) { i = i + 21; _root.menu.instr.htmlText += "\n" + outputString.substr(0,21); outputString = instructionArray[num].substring(i); } else { _root.menu.instr.htmlText += "\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) { // Modified by Dean Wood 2/4/2003 // Changing the step image to be viewed as the topology. if (_level0.LabDataDir == "") loadMovie((_level0.LabDataDir +graphicImage), _root.Topology.realImage); else loadMovie((_level0.LabDataDir + chapterCovered +"/"+graphicImage), _root.Topology.realImage); /* 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) { _root.stepnum = num; _root.showInstruction(_root.stepnum); //Begin modification by Bargavi //to modify the topology button for different cases //general property //if the topology button is disabled at any cause hide the topology window if (_root.menu.toolbar.button_topology._visible==true) { _root.topology._visible=false ; _root.menu.toolbar.marker_topology._visible=false; } if (topo==true && graphicArray[_root.stepnum]=="" && _root.menu.toolbar.marker_help._visible==false ) { _root.menu.toolbar.marker_type._visible =true; } //case 1: topology button enabled when any step has image otherwise disabled if (graphicArray[_root.stepnum] !="") { _root.menu.toolbar.button_topology._visible=true; } else { _root.menu.toolbar.button_topology._visible=false; _root.menu.toolbar.marker_topology._visible=false; _root.menu.toolbar.button_topology_disabled.enabled=false; } //case 2 : only step 0 has image and the defualt is set to true if ( graphicArray[_root.stepnum] =="" && graphicArray[0]!="" ) { if (_root.hasDefaultGraphic == true ) { if (_root.menu.toolbar.marker_type._visible==false && _root.menu.toolbar.marker_help._visible==false ) //if not in type button previsiously selected { _root.menu.toolbar.button_topology._visible=true; _root.menu.toolbar.marker_topology._visible=true; _root.menu.toolbar.marker_type._visible=false; _root.topology._visible=true;} else {_root.menu.toolbar.button_topology._visible=true; } } //case 3 : only step 0 has image and the defualt is set to false else { if (_root.menu.toolbar.marker_help._visible==false) { _root.menu.toolbar.button_topology._visible=false; _root.menu.toolbar.marker_topology._visible=false; _root.menu.toolbar.marker_type._visible=true; _root.topology._visible=false ; } } } //case 4: step 0 has no image but others may have //&& _root.menu.toolbar.marker_type._visible==false && _root.menu.toolbar.marker_help._visible==false if ( graphicArray[0] =="" && graphicArray[_root.stepnum] !="" ) {topo=true; if( _root.menu.toolbar.button_topology._visible==true && _root.menu.toolbar.current == "topology" ) { _root.topology._visible=true ; _root.menu.toolbar.marker_topology._visible=true; _root.menu.toolbar.marker_type._visible=false; _root.menu.toolbar.merker_help._visible=false; } } //case 5: step 0 has image and default and others too may have if ( graphicArray[0] !="" && graphicArray[_root.stepnum] !="" ) { if (_root.menu.toolbar.current == "topology" && _root.menu.toolbar.button_topology._visible==true) { _root.topology._visible=true ; _root.menu.toolbar.marker_topology._visible=true; _root.menu.toolbar.marker_type._visible=false; _root.menu.toolbar.marker_help._visible=false; } } //End of Modification by Bargavi // Added by Dean Wood 2/6/2003 adjustStepButtons(AnswerArray[num][0].stepnum); // 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); } // Added by Dean Wood 2/6/2003 function adjustStepButtons(n) { // 2 is the vertical space between step buttons // 12 is the height of the step button // 14 is 12 + 2 // 15 is the last completely visible step number // 16 is 12 + 2 + 2 // 235 is the height of the step button area less the height of the scroll buttons. if(totalsteps < 18) return; if(blank.buttonlist._y + (n * 14) + 16 > 235) blank.buttonlist._y = (15 - n) * 14; else if(blank.buttonlist._y + (n * 14) + 2 < 0) blank.buttonlist._y = -(n * 14); } function isComputer() { 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; } //Bargavi function CreateArray(CurrentMode) { if (CurrentMode == "ATMPVC") { ATMPVCC = new Array(); } else if (CurrentMode == "classMap") { classMapC = new Array(); } else if (CurrentMode == "controllerT1") { controllerT1C = new Array(); } else if (CurrentMode == "dhcp") { dhcpC = new Array(); } else if (CurrentMode == "enable") { enableC = new Array(); } else if (CurrentMode == "extNacl") { extNaclC = new Array(); } else if (CurrentMode == "global") { globalC = new Array(); } else if (CurrentMode == "intAsync") { intAsyncC = new Array(); } else if (CurrentMode == "intATM") { intATMC= new Array(); } else if (CurrentMode == "intBri") { intBriC = new Array(); } else if (CurrentMode == "intDialer") { intDialerC = new Array(); } else if (CurrentMode == "intE") { intEC = new Array(); } else if (CurrentMode == "intF") { intFC = new Array(); } else if (CurrentMode == "intG") { intGC = new Array(); } else if (CurrentMode == "intLoopBack") { intLoopBackC = new Array(); } else if (CurrentMode == "intVlan") { intVlanC= new Array(); } else if (CurrentMode == "intS") { intSC= new Array(); } else if (CurrentMode == "lineaux") { lineauxC = new Array(); } else if (CurrentMode == "linecon") { lineconC = new Array(); } else if (CurrentMode == "linetty") { linettyC = new Array(); } else if (CurrentMode == "linevty") { linevtyC = new Array(); } else if (CurrentMode == "mapClass") { mapClassC = new Array(); } else if (CurrentMode == "policyMap") { policyMapC = new Array(); } else if (CurrentMode == "policyMapClass") { policyMapClassC = new Array(); } else if (CurrentMode == "routeMap") { routeMapC= new Array(); } else if (CurrentMode == "routerAF") { routerAFC = new Array(); } else if (CurrentMode == "routerBGP") { routerBGPC = new Array(); } else if (CurrentMode == "routerEIGRP") { routerEIGRPC = new Array(); } else if (CurrentMode == "routerIGRP") { routerIGRPC = new Array(); } else if (CurrentMode == "routerISIS") { routerISISC = new Array(); } else if (CurrentMode == "routerOSPF") { routerOSPFC = new Array(); } else if (CurrentMode == "routerRIP") { routerRIPC = new Array(); } else if (CurrentMode == "stdNacl") { stdNaclC= new Array(); } else if (CurrentMode == "subintATM") { subintATMC= new Array(); } else if (CurrentMode == "subintBri") { subintBriC= new Array(); } else if (CurrentMode == "subintDialer") { subintDialerC= new Array(); } else if (CurrentMode == "subintE") { subintEC= new Array(); } else if (CurrentMode == "subintF") { subintFC= new Array(); } else if (CurrentMode == "subintG") { subintGC= new Array(); } else if (CurrentMode == "subintS") { subintSC= new Array(); } else if (CurrentMode == "subintVlan") { subintVlanC= new Array(); } else if (CurrentMode == "timeRange") { timeRangeC= new Array(); } else if (CurrentMode == "user") { userC = new Array(); } else if (CurrentMode == "vlanDB") { vlanDBC = new Array(); } } //end Bargavi