////////////////////////////////////////////////////////////////////////// // monitor.html ////////////////////////////////////////////////////////////////////////// // Global Variables var GetNetper_request = createXMLHttpRequest(); var monitorTimer; var stopmonitorTimer; var bIsMonitorRunning; var bIsMonitorRunningFirstTime; var RoomTagging_Index_HashTable; /********************************************************************************************** * Init() * * * * * **********************************************************************************************/ function Init_monitor() { LoadConfiguration(); InitTranslation(); InitOUIList(); InitRoomTaggingList(); Refresh_Page(); bIsMonitorRunning = false; bIsMonitorRunningFirstTime = false; } /********************************************************************************************** * Fini() * * * **********************************************************************************************/ function Fini_monitor() { if (GetLocalDevices_request.readyState != 0 && GetLocalDevices_request.readyState != 4) { KillProcess("hpna_address"); } if (GetNetper_request.readyState != 0 && GetNetper_request.readyState != 4) { KillProcess("hpna_netper"); } } /********************************************************************************************** * Refresh_Page() * * * * * **********************************************************************************************/ function Refresh_Page() { InitConnection(); } /********************************************************************************************** * Refresh_Page_After_InitConnection() * * * * * **********************************************************************************************/ function Refresh_Page_After_InitConnection(Success) { if (Success) { // -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Update the Monitor buttons // -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- var bodyContent = ""; bodyContent = bodyContent + "
\n"; bodyContent = bodyContent + "
\n"; if(CMS_Configuration_Language == "fr"){ bodyContent = bodyContent + " "; bodyContent = bodyContent + " \n"; bodyContent = bodyContent + "
\n"; bodyContent = bodyContent + "
\n"; bodyContent = bodyContent + " \n"; bodyContent = bodyContent + " \n"; } else { bodyContent = bodyContent + " "; bodyContent = bodyContent + " \n"; bodyContent = bodyContent + "
\n"; bodyContent = bodyContent + "
\n"; bodyContent = bodyContent + " \n"; bodyContent = bodyContent + " "; } bodyContent = bodyContent + "
"; document.getElementById('spnButton').innerHTML = bodyContent; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // HpnaInit(false); getoldmonitor(); } else { Update_Refresh_Button(false); } } /********************************************************************************************** * SetBusy() * * * * 1. Enable/Disable some elements on GUI * * 2. Start/Stop "Please-Wait" animation * * * **********************************************************************************************/ function SetBusy(state) { if (state == true) { //document.getElementById('DeviceTable').innerHTML = ""; //document.getElementById('DeviceTableSummary').innerHTML = ""; document.body.style.cursor = "wait"; if (Element = document.getElementById('start_stop_button')) { Element.disabled = true; } if (Element = document.getElementById('clear_button')) { Element.disabled = true; } if (Element = document.getElementById('save')) { Element.disabled = true; } } else //(state == false) { UpdateStatusLine("

" + _T("HPNA - ready") + ""); document.body.style.cursor = "default"; if (Element = document.getElementById('start_stop_button')) { Element.disabled = false; } if (Element = document.getElementById('clear_button')) { Element.disabled = false; } if (Element = document.getElementById('save')) { Element.disabled = false; } } } /********************************************************************************************** * SaveResults() * * * * Save the result into new HTML file * **********************************************************************************************/ function SaveResults() { var str = ""; var strPage = ""; strPage = strPage + ""; str = "

" + _T("Monitor (Netper)") + "

"; strPage = strPage + str; strPage = strPage + "\n

\n"; strPage = strPage + new Date(); strPage = strPage + "\n

\n"; str = document.getElementById('DeviceTableSummary').innerHTML; str=str_replace_All_Instance(str,"border=0","border=1"); str=str_replace_All_Instance(str," class=TableProperties",""); str=str_replace_All_Instance(str," class=TableTitle",""); str=str_replace_All_Instance(str," class=TableRow",""); strPage = strPage + str; strPage = strPage + "\n

\n"; str = document.getElementById('DeviceTable').innerHTML; str=str_replace_All_Instance(str,"border=0","border=1"); str=str_replace_All_Instance(str," class=TableProperties",""); str=str_replace_All_Instance(str," class=TableTitleEnd",""); str=str_replace_All_Instance(str," class=TableTitle",""); str=str_replace_All_Instance(str," class=TableRow",""); strPage = strPage + str; strPage = strPage + ""; SaveNewHTMLPage(strPage); } function getoldmonitor() { UpdateStatusLine("

" + _T("Netper - Get old information...") + ""); SetBusy(true); GetNetper_request.open('GET', '/index.cgi?script=cms_cgi&action=GetNetper'); GetNetper_request.onreadystatechange = handleMonitorControl; GetNetper_request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); GetNetper_request.send(null); } function clear_table() { UpdateStatusLine("

" + _T("Netper - Clearing the table...") + ""); SetBusy(true); GetNetper_request.open('GET', '/index.cgi?script=cms_cgi&action=GetNetper&Type=clear'); GetNetper_request.onreadystatechange = handleMonitorControl; GetNetper_request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); GetNetper_request.send(null); } function start_monitor() { bIsMonitorRunning = true; if(bIsMonitorRunningFirstTime == false) { // HpnaInit(false); bIsMonitorRunningFirstTime = true; StopMonitorTimeout = CMS_Configuration_netper_test_length * 60 * 1000; stopmonitorTimer = setTimeout("stop_monitor()", StopMonitorTimeout); } document.getElementById('start_stop_span').innerHTML = ""; UpdateStatusLine("

" + _T("Running Test...") + ""); SetBusy(true); GetNetper_request.open('GET', '/index.cgi?script=cms_cgi&action=GetNetper&Type=new'); GetNetper_request.onreadystatechange = handleMonitorControl; GetNetper_request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); GetNetper_request.send(null); } function stop_monitor() { bIsMonitorRunning = false; bIsMonitorRunningFirstTime = false; document.getElementById('start_stop_span').innerHTML = ""; clearTimeout(monitorTimer); clearTimeout(stopmonitorTimer); // HpnaInit(true); } function handleMonitorControl() { if (GetNetper_request.readyState != 4) { return; } SetBusy(false); var response = GetNetper_request.responseText; var linesArray = new Array(); if (response.indexOf('\n') != -1) { linesArray = response.split('\n'); } var modifiedResponse = ""; var previouseSpace = false; var tableresponse = ""; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Build Summary Section //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- var Total_X = 0; var Total_RX = 0; var Total_CRC = 0; var Total_DROPPED = 0; var Total_LOSS = 0; var Time_First = ""; var Time_Last = ""; tableresponse = "" + _T("Summary Table") + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; for (y = (linesArray.length - 1); y >= 0; y--) { response = linesArray[y]; // Extract time stamp time = response.substr(0, 24); response = response.substr(25); modifiedResponse = ""; previouseSpace = true; for (x = 0; x < response.length - 1; x++) { if (response.indexOf("EMPTY") != -1) { continue; } if (response.charAt(x) == ' ') { if (previouseSpace == false) { modifiedResponse = modifiedResponse + response.charAt(x); } previouseSpace = true; } else { modifiedResponse = modifiedResponse + response.charAt(x); previouseSpace = false; } } var update = new Array(); if (modifiedResponse.length > 0) { if (Time_Last == "") { Time_Last = time; } Time_First = time; if (modifiedResponse.indexOf(' ') != -1) { update = modifiedResponse.split(' '); Total_X+= Number(update[0]); Total_RX+= Number(update[1]); Total_CRC+= Number(update[2]); Total_DROPPED+= Number(update[3]); Total_LOSS+= Number(update[4]); } } } var TimeDiffFormat; if (Time_Last == "") { TimeDiffFormat = "N/A"; } else { var Date1 = new Date(Time_First); var Date2 = new Date(Time_Last); // Calculate time difference //var TimeDiff = Math.ceil((Date2.getTime()-Date1.getTime()) /1000); var TimeDiffMin = Math.floor((Date2.getTime()-Date1.getTime()) / (1000*60)); var TimeDiffSec = (Date2.getTime()-Date1.getTime()) % (1000*60) / (1000); TimeDiffFormat = TimeDiffMin + " min, " + TimeDiffSec + " sec"; } tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + "
" + _T("Time Delta") + "" + _T("Total Tx") + "" + _T("Total Rx") + "" + _T("Total CRC") + "" + _T("Total Dropped") + "" + _T("Total Loss") + "
" + TimeDiffFormat + "" + Total_X + "" + Total_RX + "" + Total_CRC + "" + Total_DROPPED + "" + Total_LOSS + "
"; document.getElementById('DeviceTableSummary').innerHTML = tableresponse; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Build Details Section //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- tableresponse = "" + _T("Detailed Table") + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; //alert("length = " + linesArray.length); //for(y=2; y<(linesArray.length-1); y++) for (y = (linesArray.length - 1); y >= 0; y--) { response = linesArray[y]; // Extract time stamp time = response.substr(0, 24); response = response.substr(25); modifiedResponse = ""; previouseSpace = true; for (x = 0; x < response.length - 1; x++) { if (response.charAt(x) == ' ') { if (previouseSpace == false) { modifiedResponse = modifiedResponse + response.charAt(x); } previouseSpace = true; } else { modifiedResponse = modifiedResponse + response.charAt(x); previouseSpace = false; } } var update = new Array(); if (modifiedResponse.indexOf(' ') != -1) { update = modifiedResponse.split(' '); tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; tableresponse = tableresponse + ""; } } tableresponse = tableresponse + "
" + _T("Time") + "TxRxCRC" + _T("Dropped") + "" + _T("Loss") + "PER%" + _T("Idle Time") + "
" + time + "" + update[0] + "" + update[1] + "" + update[2] + "" + update[3] + "" + update[4] + "" + update[5] + "" + update[6] + "
"; document.getElementById('DeviceTable').innerHTML = tableresponse; //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (bIsMonitorRunning == true) { AutoUpdateTimeout = CMS_Configuration_netper_timeout - 3; AutoUpdateTimeout = AutoUpdateTimeout * 1000; //if (AutoUpdateTimeout < 2000) AutoUpdateTimeout = 2000; monitorTimer = setTimeout("start_monitor()", AutoUpdateTimeout); } }