var kalpaxml = null ; // holds our binary component. var PAGE_SIZE; // number of records in a page. var PAGES_IN_DATA = 3; //number of pages in the table var DATA_SIZE = 500; // number of records in the table var INDEX_DATA = 0; // do not hard-code var ROW_HEIGHT = 20; var INDEX_NEXT_TOP = 0 ; // index of EEL data in cache that is at the top of eelData island var OLD_PAGE_SIZE; var MAX_ROWS = 50; var fResizing = false; var fScrollChange = false; var numEELRecords = 0 ; // max. number of records in eelDataCache var fRecordPresent = false; var fLogTypePresent = false ; var arrayProp = new Array( ); var viewingNTEventLog = false ; // true only for NT Event Log. var typePos = null; var valuePos = null; var classificationPos = null; var valNumClassification = new Array("","discovery","inventory","configuration", "operation/availablity","problem management", "threshold crossings", "Performance and Capacity","Billing"); var valNumLogType=new Array("","System","Application","Security"); var valImageSrc= new Array("images/high_imp.gif","images/error.gif","images/alert.gif","images/info.gif","images/key.gif","images/lock.gif","images/garbage.gif"); var valType = new Array("red alert","error","warning","information","security audit success","security audit failure","garbage"); var valNTImageSrc = new Array(); valNTImageSrc["error"] = "images/error.gif"; valNTImageSrc["warning"] = "images/alert.gif"; valNTImageSrc["information"] = "images/info.gif"; valNTImageSrc["audit success"] = "images/key.gif"; valNTImageSrc["audit failure"] = "images/lock.gif"; var valType1=new Array(); valType1["red alert"]=0; valType1["error"]=1; valType1["warning"]=2; valType1["information"]=3; valType1["security audit success"]=4; valType1["security audit failure"]=5; valType1["garbage"]=6; var arrAMPM = Array("AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","AM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM","PM"); var arrHours = Array("00","01","02","03","04","05","06","07","08","09","10","11", "00","01","02","03","04","05","06","07","08","09","10","11"); // this parameter is used to set the scrollbar. var maxRecords = 1000000; window.onerror = fnErrorTrap ; var numColumns = 0; var cache = new Array(6000); var record = new Array(500); var logfilearray = new Array(500); var RECORDNUMBER_INDEX = 0; var LOGFILE_INDEX = 0 ; var maxNTRecords = 1000; // BugBug - Adjustment to get alignment correct function fnErrorTrap (sMsg, sUrl, sLine) { alert (sMsg + sUrl + sLine) ; } //------------------------------------------------------------------------------- // onload // This function will be executed when viewer window is first loaded. //-------------------------------------------------------------------------------- function window.onresize() { document.recalc (true) ; if(fMadeConnection == true) { fResizing = true; OLD_PAGE_SIZE = PAGE_SIZE; calcPageSize(); setScrollBarParameters(); pageInRange(); fResizing = false; } else calcPageSize(); fillTable(); } function window.onload () { wmiInit () ; init () ; tableDiv.style.setExpression ("height", "mainBody.clientHeight - taskDiv.offsetHeight - drillDownDiv.style.pixelHeight - TABLE0.style.pixelHeight") ; tableDiv.style.setExpression("width", "mainBody.clientWidth - scrollBar.clientWidth"); customizeDiv.style.setExpression ("height", "mainBody.clientHeight") ; scrollBar.style.setExpression ("top", "tableDiv.offsetTop") ; scrollBar.style.setExpression ("left", "mainBody.clientWidth-scrollBar.clientWidth") ; scrollBar.style.setExpression ("pixelHeight", "tableDiv.style.pixelHeight") ; document.recalc(true); calcPageSize(); setScrollBarParameters(); scrollBar.style.visibility = 'visible'; fillTable(); // this is because the document.location.search also returns the '?' var tempStr = document.location.search.substring(1); argv = tempStr.split(","); if(argv.length >= 2) startUpConnectionFromMMC(argv); } function window.onunload () { close() ; } function handleScroll(){ // this is to prevent cascading events if(fScrollChange== true) return; else { fScrollChange = true; pageInRange(); fScrollChange = false; } } function cacheAway() { var k = 0; var d = new Date(); var numberToGet = Math.min (DATA_SIZE, (numEELRecords - INDEX_NEXT_TOP)) ; var numberGot = 0; var i,j; for (i = 0; i < numberToGet; i++) { try { kalpaxml.wmiGetNextObject(); } catch (e) { // try to update count. // BUGBUG! what query to use? // BUGBUG! logic for updating number of records since we cannot get it from // WMI yet. numEELRecords = kalpaxml.wmiGetCount ("") ; setScrollBarParameters () ; scrollBar.value = Math.max(numEELRecords - PAGE_SIZE,0); numberGot = i; convertCacheDateTime(numberGot); return; } for(j = 0; j < numColumns; j++) { if( (j!=typePos)&&(j!=classificationPos)&&(j!=valuePos ) ) { cache[k++] = kalpaxml.wmiGetPropertyText(arrayProp[j]); } else { if(j==classificationPos) { cache[k++] = valNumClassification [kalpaxml.wmiGetPropertyText(arrayProp[j])]; } else if(j==typePos) { if(viewingNTEventLog == true) { var temp = kalpaxml.wmiGetPropertyText(arrayProp[j]); cache[k++] = "" + temp; } else { var temp = kalpaxml.wmiGetPropertyText(arrayProp[j]); cache[k++] = "" + valType[temp]; } } else { cache[k++] = valNumLogType[kalpaxml.wmiGetPropertyText(arrayProp[j])] } } } //this is for drillDown - we always put the RecordNumber for EEL case //and RecordNumber+LogType in NT Case; if(fRecordPresent == false) { record[INDEX_NEXT_TOP + i] = kalpaxml.wmiGetPropertyText("RecordNumber"); } if(fLogTypePresent == false && viewingNTEventLog) { logfilearray[INDEX_NEXT_TOP + i] = kalpaxml.wmiGetPropertyText("Logfile"); } } numberGot = i; convertCacheDateTime(numberGot); } function convertCacheDateTime(numberGot) { var i,j; for(j=0;j" ; drillDownTemp.loadXML (xmlStr) ; var node = drillDownTemp.selectSingleNode("INSTANCE"); return (node); } function toDrillDownXML (s) { var start,end; //Saving the value as it will be required later sT=s; //The next three lines get the part required by drilldown part. //The remaining is type, priority and severity. start = s.indexOf ("instance") ; end = s.indexOf ("Priority", start) ; s= s.slice (start, end-1) ; // replace new line a = s.replace (/[\s\n]/g," ") ; b = a.replace (/(\s\S)*\s(\w+)\s*=\s*(instance of)\s*(\w+)(\s*{ )/g, "$1") c = b.replace (/\s*(\w+)(\s*=\s*)"*([\w\s]*)"*;/g,"$3") ; d = c.replace (/};/g, "") ; //Getting the part which contains priority, type and severity fields start = sT.indexOf ("Priority") ; end = sT.indexOf ("Type", start) ; g= sT.slice (start, end+9) ; h = g.replace (/[\s\n]/g," ") ; //Getting the Severity value start = h.indexOf ("Sev") ; end = h.indexOf ("Typ") ; d=d+""+h.slice(end-4,end-3)+""; //Getting priority value start = h.indexOf ("Pri") ; end = h.indexOf ("Sev") ; d=d+""+h.slice(end-4,end-3)+""; //Getting type value start = h.indexOf ("Ty") ; end = h.indexOf ("}") ; d=d+""+h.slice(start+7,start+8)+""; return d ; } function toDrillDownXMLNT (s) { var start,end; //Next 4 lines get the value of the type field start = s.indexOf ("Type = \"") ; end = s.indexOf ("\";", start) ; sT = s.slice (start+8, end) ; sType=valType1[sT]; //Next three lines get the part which is for the drilldown start = s.indexOf("inst"); end = s.indexOf("Ty"); s = s.slice(start,end -1); s=s+"};" ; // replace new line a = s.replace (/[\s\n]/g," ") ; a = s.replace (/\\n/g, "") ; // find the message part. start = a.indexOf ("Message = \"") ; end = a.indexOf ("\";", start) ; message = a.slice (start+11, end) ; // find data. data = "" ; ds = a.indexOf ("Data = {") ; if (ds !=-1) { de = a.indexOf ("}", ds) ; data = a.slice (ds+8,de) + ","; } if (data != "") { //break it up into nodes as we want. datax = data.replace(/\s*(\d+),/g,"$1.") ; } else{ datax = ""; } datax = ""+datax+"" ; // build the xml s1 = ""+sType+"" +"" +"" +"1" +"" +""+message+"" +datax +"" ; return s1 ; } //----------------------------------------------------------------------------- // Respositions the forward only enumerator to the required position //----------------------------------------------------------------------------- function positionEnumerator (index) { try { kalpaxml.wmiGoTo(index); } catch (e) { // the failure will be caught in the // cacheAway function } } //----------------------------------------------------------------------------- // pageInRange () // // displays the page in specified range //----------------------------------------------------------------------------- function pageInRange() { //This function is called when you scroll and when you resize if(fMadeConnection == false) return; var prev_INDEX_NEXT_TOP = INDEX_NEXT_TOP; INDEX_NEXT_TOP = scrollBar.value; if( (numEELRecords INDEX_DATA + DATA_SIZE) && (INDEX_NEXT_TOP + PAGE_SIZE <= numEELRecords) ) || ( INDEX_NEXT_TOP < INDEX_DATA) ) { // should we let this code be as it is // that should be done if the strategy is always to straddle, // which seems to be the best thing to do // check with AmitC // we do not have the required data with us // now get the appropriate data page if (INDEX_NEXT_TOP + DATA_SIZE > numEELRecords) INDEX_DATA = numEELRecords - DATA_SIZE; else INDEX_DATA = Math.max(INDEX_NEXT_TOP - Math.floor(DATA_SIZE/2),0); var tmpINDEX_NEXT_TOP = INDEX_NEXT_TOP; INDEX_NEXT_TOP = INDEX_DATA; // BUGBUG! Trying to counter the fact that we don't have the right count var tmp = numEELRecords ; positionEnumerator( INDEX_NEXT_TOP ); getNextDataPage (); if (tmp != numEELRecords) { // This means we just realized that we did not have the right count. // we have adjusted the scroll bar params, but values like INDEX_NEXT_TOP are wrong. // we will call getNextDataPage again with a corrected INDEX_NEXT_TOP tmpINDEX_NEXT_TOP = scrollBar.value; INDEX_NEXT_TOP = Math.max(tmpINDEX_NEXT_TOP - Math.floor(DATA_SIZE/2),0); INDEX_DATA = INDEX_NEXT_TOP; positionEnumerator( INDEX_NEXT_TOP ); getNextDataPage () ; } INDEX_NEXT_TOP = tmpINDEX_NEXT_TOP; } else { //optimise for //a)resizing - put data into table only for OLD_PAGE_SIZE to new PAGE_SIZE; //b)scroll by 1 - try using insertCell and deleteCell - this will give the required effect as well //the function fillUpTableFromCache // is very generic for doing that if(INDEX_NEXT_TOP+PAGE_SIZE>numEELRecords) { INDEX_NEXT_TOP = Math.max(numEELRecords - PAGE_SIZE,0); } fillUpTableFromCache(0,PAGE_SIZE+1,(INDEX_NEXT_TOP-INDEX_DATA)* numColumns); } if(numEELRecords > 0) { if(selectedRecord == selectedRow+INDEX_NEXT_TOP) { highlightRow(); //TABLEBODY1.rows(selectedRow-1).cells(0).focus(); } else { for (j=0; j < TABLE1.rows(selectedRow).cells.length; j++) TABLE1.rows(selectedRow).cells(j).style.background="rgb(255,255,255)" ; } } getCurrentRecords(); //ResultSetCache.ReportStatistics(); } function startTimer() { date0 = new Date(); } function endTimer() { date1 = new Date(); alert("Time for your function - " + (date1.getTime() - date0.getTime() )/1000 + "seconds") }