home *** CD-ROM | disk | FTP | other *** search
- /* Global Varibles */
- var g_G1Connected = false;
- var g_G2Connected = false;
-
- function OnloadHome(){
- CommonOnload();
- }
-
-
- /*
- * function: GetNetworkStatusFunction
- * Description: The following function called by the program.
- * Use it to retrieves information about the network status and update the GUI.
- */
- function GetNetworkStatusFunction()
- {
- /*
- * Calling the IsConnected function for connection status of both G1 and G2:
- * 0 - Connecting
- * 1 - Connected
- * 2 - Disconnected
- * Set the result in an Object with the ID = IsConnectedID
- */
- ExecuteCommand("IsConnected|SEPERATOR|IsConnectedID");
-
- /* Get the connection status for G1 and G2 */
- ExecuteCommand("IsConnectedG1|SEPERATOR|IsConnectedG1ID");
- ExecuteCommand("IsConnectedG2|SEPERATOR|IsConnectedG2ID");
-
- /* Get the "Known Nodes" information */
- ExecuteCommand("GetKnownNodes|SEPERATOR|<NodeIP><br>|SEPERATOR|KnownNodesID");
- /* Get cache nodes information */
- ExecuteCommand("GetCacheInfo|SEPERATOR|CachedPercentID");
-
- /* Get connected nodes information */
- //ExecuteCommand("GetConnectedNodes|SEPERATOR|<NodeIP><br>|SEPERATOR|ConnectedNodesID");
-
-
- ExecuteCommand("GetConnectedG1Nodes|SEPERATOR|<span onmouseover=GetNodeInfo(<NodeID>) style='color:#838383'><NodeIP> (Gnutella1)</span> - <span class='SmallCommandLink' onclick=RemoveNode(<NodeID>)>Remove</span><br>|SEPERATOR|ConnectedG1NodesID");
- ExecuteCommand("GetConnectedG2Nodes|SEPERATOR|<span onmouseover=GetNodeInfo(<NodeID>) style='color:#46CCEF'><NodeIP> (Gnutella2)</span> - <span class='SmallCommandLink' onclick=RemoveNode(<NodeID>)>Remove</span><br>|SEPERATOR|ConnectedG2NodesID");
-
- SetNetworkStatusText();
- }
-
- /*
- * function: SetNetworkStatusText
- * Description: The following function is responsible for handling any interface
- * update
- */
- function SetNetworkStatusText()
- {
- /* According to the result of GetNetworkStatus set the status text on the interface */
- SetConnectionStatusText();
-
- /* Take the hidden connected nodes text for G1 + G2 and present them together */
- SetConnectedG1G2NodesText()
-
- /* Set the text of the connection buttons (G1/G2)*/
- SetG1ConnectionButtonStyle();
- SetG2ConnectionButtonStyle();
-
- }
-
- function SetConnectedG1G2NodesText()
- {
- var lsConnectedNodesStatus = ConnectedG1NodesID.innerHTML + ConnectedG2NodesID.innerHTML;
- ConnectedNodesID.innerHTML = lsConnectedNodesStatus;
-
- }
- /*
- * function: SetConnectionStatusText
- * Description: Set the text for the connection status: Connecting/Connected/Disconnected
- */
- function SetConnectionStatusText()
- {
-
- if(document.all.IsConnectedID.innerHTML == "0")
- {
- document.all.StatusTextID.innerHTML = "Status: Connecting...";
- return;
- }
-
- if(document.all.IsConnectedID.innerHTML == "1")
- {
- document.all.StatusTextID.innerHTML = "Status: Connected";
- return;
- }
-
- if(document.all.IsConnectedID.innerHTML == "2")
- {
- document.all.StatusTextID.innerHTML = "Status: Disconnected";
- return;
- }
-
- // In case none of the above set the status to unknown
- document.all.StatusTextID.innerHTML = "Status: Unknown";
- return;
-
- }
-
- /*
- * function: SetG1ConnectionButtonText
- * Description: Set the text for the G1 connection Button and sets the status of
- * the G1 global variable: g_G1Connected
- */
- function SetG1ConnectionButtonStyle()
- {
- if(document.all.IsConnectedG1ID.innerHTML == "2")
- {
- ConnectButtonG1ID.style.border = '0px';
- ConnectButtonG1ID.style.backgroundColor = "#E6E6E6";
- g_G1Connected = false;
-
- }else
- {
-
- ConnectButtonG1ID.style.border = '1px solid black';
- ConnectButtonG1ID.style.backgroundColor = "#D2DEF2";
- g_G1Connected = true;
- }
-
-
- }
-
- /*
- * function: SetG2ConnectionButtonText
- * Description: Set the text for the G2 connection Button and sets the status of
- * the G1 global variable: g_G2Connected
- */
- function SetG2ConnectionButtonStyle()
- {
-
- if(document.all.IsConnectedG2ID.innerHTML == "2")
- {
- ConnectButtonG2ID.style.border = '0px';
- ConnectButtonG2ID.style.backgroundColor = "#E6E6E6";
- g_G2Connected = false;
-
- }else
- {
-
- ConnectButtonG2ID.style.border = '1px solid black';
- ConnectButtonG2ID.style.backgroundColor = "#D2DEF2";
- g_G2Connected = true;
- }
-
-
- }
-
- /*
- * function: ToggleConnection
- * Parameters:
- * Network - The network ID: 0 = G1, 1= G2
- * Description: Toggle connection status of the network according to the global variable g_G2Connected
- */
-
- function ToggleConnection(Network)
- {
-
- if(Network == 0) //G1
- {
- if(g_G1Connected)
- {
- ExecuteCommand("DisconnectG1");
- ConnectButtonG1ID.style.border = '0px';
- ConnectButtonG1ID.style.backgroundColor = "#E6E6E6";
-
- }
- else
- {
-
- ExecuteCommand("ConnectG1");
- ConnectButtonG1ID.style.border = '1px solid black';
- ConnectButtonG1ID.style.backgroundColor = "#D2DEF2";
- }
- }
-
- if(Network == 1) //G2
- {
- if(g_G2Connected)
- {
- ExecuteCommand("DisconnectG2");
- ConnectButtonG2ID.style.border = '0px';
- ConnectButtonG2ID.style.backgroundColor = "#E6E6E6";
- }
- else
- {
- ExecuteCommand("ConnectG2");
- ConnectButtonG2ID.style.border = '1px solid black';
- ConnectButtonG2ID.style.backgroundColor = "#D2DEF2";
- }
- }
- }
- /*
- * function: RefreshCache
- * Description: This function call the webcache to get more nodes
- */
- function RefreshCache()
- {
- ExecuteCommand("RefreshCache");
- }
-
- /*
- * function: ShowNodeInfo
- * Parameters:
- * NodeID: The ID of the node - a reference number to it.
- * Description: This function shows more information on a specific connected node.
- */
- function GetNodeInfo(NodeID)
- {
- var lsCommand;
- lsCommand = "GetNodeInfo|SEPERATOR|" + NodeID + "|SEPERATOR|";
- lsCommand += "IP: <IP><BR>\
- Time Connected: <TimeConnected><BR>\
- Bandwidth: <BandWidth> KB/s<BR>\
- Efficiency: <Efficiency><BR>\
- Agent: <Agent><BR>\
- Mode: <Mode><BR>";
-
- lsCommand += "|SEPERATOR|NodeInfoID";
-
- ExecuteCommand(lsCommand);
- }
-
- /*
- * function: RemoveNode
- * Parameters:
- * NodeID: The ID of the node - a reference number to it.
- * Description: This function disconnects a node.
- */
- function RemoveNode(NodeID)
- {
- var lsCommand;
- lsCommand = "RemoveNode|SEPERATOR|" + NodeID;
- ExecuteCommand(lsCommand);
- }
-
- /*
- * function: ConnectNode
- * Parameters:
- * IP: IP string in the format of xxx.xxx.xxx.xxx
- * Port: The port of the node
- * Description: This function Connects to a node.
- */
- function ConnectNode(IP,Port)
- {
- var lsCommand;
- lsCommand = "ConnectNode|SEPERATOR|" + IP + "|SEPERATOR|" + Port;
- ExecuteCommand(lsCommand);
- }