From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../Engine/originaltexts/Copy of drillObject.txt | 1041 +++++++++++++ .../Engine/originaltexts/DeviceModeMatrix.txt | 45 + .../elabs/Engine/originaltexts/actions_buttons.txt | 317 ++++ .../Engine/originaltexts/actions_commandline.txt | 1168 ++++++++++++++ .../Engine/originaltexts/actions_commands.txt | 1592 ++++++++++++++++++++ .../elabs/Engine/originaltexts/actions_history.txt | 239 +++ .../originaltexts/actions_manual_scrolling.txt | 176 +++ .../elabs/Engine/originaltexts/actions_output.txt | 548 +++++++ .../Engine/originaltexts/actions_password.txt | 238 +++ .../elabs/Engine/originaltexts/actions_router.txt | 257 ++++ .../originaltexts/actions_router_startup.txt | 173 +++ .../Engine/originaltexts/actions_scenario.txt | 176 +++ .../elabs/Engine/originaltexts/actions_timer.txt | 30 + .../elabs/Engine/originaltexts/actions_utility.txt | 178 +++ .../elabs/Engine/originaltexts/answer.txt | 190 +++ .../Engine/originaltexts/drillObject.bak2.txt | 1039 +++++++++++++ .../elabs/Engine/originaltexts/drillObject.txt | 1067 +++++++++++++ 17 files changed, 8474 insertions(+) create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/Copy of drillObject.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/DeviceModeMatrix.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_buttons.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commandline.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_commands.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_history.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_manual_scrolling.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_output.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_password.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_router_startup.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_scenario.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_utility.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/answer.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.bak2.txt create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/drillObject.txt (limited to 'Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts') 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 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; + +} \ 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 +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) { + + // key is pressed + + //set the rptr.controlCharPressed switch so that the + //next key to be pressed, becomes part of a + //-something sequence + rptr.controlCharPressed = 1; + return; + + } else { + + //the key pressed was anything but , 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) { + + // 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 key + //has been pressed--the next character matched will complete + //a control key sequence to be interpreted as a command + // + //currently supported control sequences: + //----------------------------------------------------------- + // = move cursor one character to the left + // = move cursor one character to the right + // = move cursor to beginning of command line input + // = move cursor to end of command line input + // = shortcut for "end" (exits config modes) + // = move to prev line in the command history + // = move to next line in the command history + // = [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)) { + + // or detected + + //move cursor one character left + commandline_arrowLeft(); + + + } else if ((keycode == 102) || (keycode == 70)) { + + // or detected + + //move cursor one character right + commandline_arrowRight(); + + + } else if ((keycode == 97) || (keycode == 65)) { + + // or 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 + /* + // or 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)) { + + // or 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)) { + + // or detected + + //move to previous line in command history (same + //routine as pressing up arrow + _root.history_historyBackward(); + + + } else if ((keycode == 110) || (keycode == 78)) { + + // or detected + + //move to next line in command history (same + //routine as pressing down arrow) + _root.history_historyForward(); + + + } else if ((keycode == 99) || (keycode == 67)) { + + // or 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: +//DO: moves the cursor one character to the left +//OUT: +// +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: +//DO: moves the cursor one character to the right +//OUT: +// +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: +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 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 . +//DO: add a new subcommand to this command +//OUT: +// +// 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 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: +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 +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 +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")) + { + 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 +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; i1 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 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 longest) + { + longest = commandArray[i].length; + } + } + + //for-loop to iterate through all subcommands in 'commandArray' + for (var i=0; i" + _root.deebug1 = commandArray + ";" + typeof(commandArray.enter); + if ((typeof(commandArray.enter) == "function") || (commandArray.enter == true)) + { + output_write(" \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: +//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: +//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: +//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: +//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: +//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: +//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 +// 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 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 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 + 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 +// 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 +// 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 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 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 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 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; + +} \ 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 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 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 = "

" + 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) +{ + 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 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 + _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 -- cgit v1.2.3