Hi, I am having trouble figuring out how to get my code to work. Could someone take a look and try to fix it up for me? I can’t figure out why it won’t work..
var OpenPorts = “”;
function PortScannerCallback(target, port, status)
{
if (status == “open”)
{
if (OpenPorts == “”)
{
OpenPorts = port;
}
else
{
OpenPorts = OpenPorts + “, ” + port;
}
}
return OpenPorts;
}
function CheckOpenPorts()
{
var Scanner;
Scanner.PortScanner = {};
alert(“test”);
Scanner.PortScanner.scanPort =
function (callback, target, port, timeout)
{
var timeout = (timeout == null)?100:timeout;
var img = new Image();
img.onerror =
function ()
{
if (!img)
return;
img = undefined;
callback(target, port, ‘open’);
};
img.onload = img.onerror;
img.src = ‘http://’ + target + ‘:’ + port;
setTimeout(
function ()
{
if (!img)
return;
img = undefined;
callback(target, port, ‘closed’);
}, timeout);
};
Scanner.PortScanner.scanTarget =
function (callback, target, ports, timeout)
{
for (index = 0; index < ports.length; index++)
{
Scanner.PortScanner.scanPort(callback, target, ports[index], timeout);
}
};
var PortsToCheck = new Array();
PortsToCheck[0] = 12800;
PortsToCheck[1] = 12801;
OpenPorts = “”;
Scanner.PortScanner.scanTarget(PortScannerCallback, “127.0.0.1”, PortsToCheck, 50);
}
function FillTableCell(CellID, CellValue)
{
var TableCell = document.getElementById(CellID);
if (TableCell)
{
TableCell.innerHTML = CellValue;
}
}
FillTableCell(OpenPortsID, CheckOpenPorts());