2024-04-17 17:14:07 -05:00
|
|
|
//This file contains the information about the puzzle (network)
|
|
|
|
//Each puzzle is stored in the allpuzzles variable. We need to select one and use it
|
|
|
|
|
|
|
|
var puzzle=networkFromName("Level0-Ping");
|
|
|
|
//var puzzle=networkFromName("Level0-NeedsLink");
|
|
|
|
//var puzzle=networkFromName("Level0_NetworkLoop");
|
|
|
|
//var puzzle=networkFromName("Level0_NetworkLoop2");
|
|
|
|
//var puzzle=networkFromName("Level0-SimpleDHCP");
|
|
|
|
//console.log(puzzle.name);
|
|
|
|
|
|
|
|
var device=deviceFromName("laptop0");
|
|
|
|
if(device !== null) {console.log("We found laptop0");}
|
|
|
|
else { console.log("Seems to be null"); }
|
|
|
|
|
2024-04-19 12:11:46 -05:00
|
|
|
function switchPuzzle(target)
|
|
|
|
{
|
|
|
|
var newpuzzle=null;
|
|
|
|
if(typeof(target)==="string") newpuzzle = networkFromName(target);
|
|
|
|
if(typeof(target)==="number") newpuzzle = networkFromIndex(target);
|
|
|
|
if(newpuzzle!= null)
|
|
|
|
{
|
|
|
|
puzzle = newpuzzle;
|
|
|
|
PrintScreen();
|
|
|
|
}
|
|
|
|
}
|
2024-04-17 17:14:07 -05:00
|
|
|
|
|
|
|
function networkFromName(what)
|
|
|
|
{
|
|
|
|
let index=0;
|
|
|
|
while (index < allpuzzles.length) {
|
|
|
|
//console.log(allpuzzles[index].EduNetworkBuilder.Network.name);
|
|
|
|
if(allpuzzles[index].EduNetworkBuilder.Network.name == what)
|
|
|
|
{
|
|
|
|
console.log("Found " + what + " at index " + index);
|
|
|
|
return structuredClone(allpuzzles[index].EduNetworkBuilder.Network);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
2024-04-19 12:11:46 -05:00
|
|
|
function networkFromIndex(what)
|
|
|
|
{
|
|
|
|
if(typeof(what)==="number" && what >= 0 && what < allpuzzles.length){
|
|
|
|
return structuredClone(allpuzzles[what].EduNetworkBuilder.Network);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2024-04-17 17:14:07 -05:00
|
|
|
|
2024-04-19 11:02:46 -05:00
|
|
|
function networkNamesMatchingText(textToMatch)
|
|
|
|
{
|
|
|
|
var list = [];
|
|
|
|
var re = new RegExp(textToMatch);
|
|
|
|
|
|
|
|
let index=0;
|
|
|
|
while (index < allpuzzles.length) {
|
|
|
|
//console.log(allpuzzles[index].EduNetworkBuilder.Network.name);
|
|
|
|
if(re.test(allpuzzles[index].EduNetworkBuilder.Network.name))
|
|
|
|
{
|
|
|
|
//console.log("Found " + textToMatch + " at index " + index + " " + allpuzzles[index].EduNetworkBuilder.Network.name);
|
|
|
|
list.push(allpuzzles[index].EduNetworkBuilder.Network.name);
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2024-04-17 17:14:07 -05:00
|
|
|
function deviceFromName(what)
|
|
|
|
{
|
|
|
|
if (puzzle == null) return null; //If the puzzle has not been set, return a null
|
|
|
|
|
|
|
|
let index=0;
|
|
|
|
while (index < puzzle.device.length) {
|
|
|
|
if (puzzle.device[index].hostname == what) return puzzle.device[index]; //return the device that matches
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return null; //No match. return a null value
|
|
|
|
}
|
|
|
|
|
|
|
|
function deviceFromID(what)
|
|
|
|
{
|
|
|
|
if (puzzle == null) return null; //If the puzzle has not been set, return a null
|
|
|
|
|
|
|
|
let index=0;
|
|
|
|
while (index < puzzle.device.length) {
|
|
|
|
if (puzzle.device[index].uniqueidentifier == what) return puzzle.device[index]; //return the device that matches
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return null; //No match. return a null value
|
|
|
|
}
|