// Global Variables var OUI_HashTable; var RoomTagging_HashTable; // InitConnection var GetNICs_request = createXMLHttpRequest(); var GetLocalDevices_request = createXMLHttpRequest(); var NICs_Array; var LocalDevices_Array; /********************************************************************************************** * LoadTextFile() * * * * Gets the contents of text file * * * **********************************************************************************************/ function LoadTextFile(filename) { var oRequest = new createXMLHttpRequest(); oRequest.open('GET', '/index.cgi?script=cms_cgi&action=LoadTextFile&File_name=' + filename,false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Error Reading the file if (oRequest.status!=200) { //alert("" + ("load text file") + " (" + filename + ") " + ("failed") + " !!"); return null; } var response = oRequest.responseText; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (response.indexOf("ERROR") != -1) { //alert("" + ("load text file") + " (" + filename + ") " + ("failed") + " !!!"); return null; } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- return response; } function createXMLHttpRequest() { var ua; if (window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if (window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var reqKillProcess = createXMLHttpRequest(); function KillProcess(processname) { reqKillProcess.abort(); reqKillProcess.open('GET', '/index.cgi?script=cms_cgi&action=KillProcess' + '&PrcessName=' + processname); reqKillProcess.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); reqKillProcess.send(null); var response = reqKillProcess.responseText; } /********************************************************************************************** * removeNL() * * * * Remove NewLine, CarriageReturn from a String * * Cut Terminal of End-Of-Line * * * **********************************************************************************************/ function removeNL(s) { r = ""; for (i=0; i < s.length; i++) { if ((s.charAt(i) != '\n') && (s.charAt(i) != '\r')) { r += s.charAt(i); } } return r; } /********************************************************************************************** * InitOUIList() * * * * OUI (Organizationally Unique Identifier) 24-bit number * * * * Load the table form file * * * **********************************************************************************************/ function InitOUIList() { var oRequest = new createXMLHttpRequest(); oRequest.open("GET","js/oui.conf",false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Empty Hash Table OUI_HashTable = new Array(); // Error Reading the file if (oRequest.status!=200) { return; } // Parse all Lines // Build OUI Hash Table Lines = oRequest.responseText.split('\n'); var Index = 0; while (Index < Lines.length) { if (Lines[Index].length > 1) { var OUI_Element = Lines[Index].split(' '); OUI_HashTable[OUI_Element[0].toUpperCase()] = OUI_Element[1]; } Index+=1; } } /********************************************************************************************** * ReplaceMAC_OUI() * * * * Replace the MAC address to MAC address with prefix of OUI * * * **********************************************************************************************/ function ReplaceMAC_OUI(MacAddress) { /*MacAddress_OUI = MacAddress.substring(0, 8); if (OUI_HashTable[MacAddress_OUI.toUpperCase()] != null) { // Found in Hash Table return (OUI_HashTable[MacAddress_OUI.toUpperCase()] + "_" + MacAddress); } else { // Not Found return MacAddress; }*/ return MacAddress; } /********************************************************************************************** * InitRoomTaggingList() * * * * Load the table form file * * * **********************************************************************************************/ function InitRoomTaggingList() { var oRequest = new createXMLHttpRequest(); oRequest.open("GET","RoomTagging.conf",false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Empty Hash Table RoomTagging_HashTable = new Array(); // Error Reading the file if (oRequest.status!=200) { return; } // Parse all Lines // Build Room Tagging Hash Table Lines = oRequest.responseText.split('\n'); var Index = 0; while (Index < Lines.length) { if (Lines[Index].length > 1) { var MacAddress = Lines[Index].substring(0,17); var Tagging = Lines[Index].substring(18); RoomTagging_HashTable[MacAddress.toUpperCase()] = unescape(Tagging); //alert(MacAddress.toUpperCase() + " === " + Tagging); } Index+=1; } } /********************************************************************************************** * Get_RoomTagging() * * * * Get the Room Tagging from "RoomTagging_HashTable" * * * **********************************************************************************************/ function Get_RoomTagging(MacAddress) { if (RoomTagging_HashTable[MacAddress.toUpperCase()] != null) { // Found in Hash Table return (RoomTagging_HashTable[MacAddress.toUpperCase()]); } else { // Not Found return ""; } } /********************************************************************************************** * Set_RoomTagging() * * * * Save the Room Tagging into File "RoomTagging.conf" * * * **********************************************************************************************/ function Set_RoomTagging(MacAddress,RoomTagging) { //alert("Set_RoomTagging(" + MacAddress + "," + escape(RoomTagging) + ")"); //alert("Set_RoomTagging(" + MacAddress + "," + unescape(RoomTagging) + ")"); var oRequest = new createXMLHttpRequest(); oRequest.open('GET', '/index.cgi?script=cms_cgi&action=SetRoomTagging' + '&MacAddress='+ MacAddress + '&RoomTagging=' + escape(RoomTagging),false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Error Reading the file if (oRequest.status!=200) { //alert("Set_RoomTagging() failed !!!") ; return; } } /********************************************************************************************** * GetLocalDevices_Parsing * * * * Extract Local Devices * * Update Local Devices Settings * * * **********************************************************************************************/ function GetLocalDevices_Parsing(lines) { LocalDevices_Array = new Array(); var LocalDeviceFound = 0; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Extract Local Devices //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (x = 0; x < lines.length; x++) { lines[x] = removeNL(lines[x]); if (lines[x].length == 17) { LocalDevices_Array[LocalDeviceFound++] = lines[x]; } } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Update Local Devices Settings //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- var responseString = ""; document.getElementById('localdevices').innerHTML = responseString; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } /********************************************************************************************** * GetLocalDevices_Parsing_Error() * * * **********************************************************************************************/ function GetLocalDevices_Parsing_Error() { //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Update Local Devices Settings //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- var responseString = ""; document.getElementById('localdevices').innerHTML = responseString; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } /********************************************************************************************** * SelectLocalDevice() * * * * The user selected new Local-Device * * * **********************************************************************************************/ function SelectLocalDevice(localdevice) { SetLocalDevice(localdevice); Refresh_Page(); } /********************************************************************************************** * SetLocalDevice() * * * * Save the selected Local-Device in Configuration-file * * * **********************************************************************************************/ function SetLocalDevice(NewLocalDevice) { var oRequest = new createXMLHttpRequest(); oRequest.open('GET', '/index.cgi?script=cms_cgi&action=SetLocalDevice'+'&NewLocalDevice=' + NewLocalDevice,false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Error Reading the file if (oRequest.status!=200) { return; } } /********************************************************************************************** * GetNICs_Parsing * * * * Extract NICs * * Update NIC (IP) Settings * * * **********************************************************************************************/ function GetNICs_Parsing(lines) { NICs_Array = new Array(); var NICsFound = 0; //alert(lines); //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Extract NICs //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (x = 0; x < lines.length; x++) { // Sanity for valid IP address if (lines[x].length > 0) { NICs_Array[NICsFound++] = removeNL(lines[x]); } } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Update NICs Settings //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //var responseString = "

IP