//-------------------------------------------------------------------------------
// onload
// This function will be executed when viewer window is first loaded.
//--------------------------------------------------------------------------------
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 () ;
if (true == fScrollChange)
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 3 lines get the value of the TimeGenerated field
start = s.indexOf ("TimeGenerated = \"") ;
end = s.indexOf ("\";", start) ;
sTG = s.slice (start+17, end) ;
sTimeGenerated = convertDateTime(sTG);
//Next 3 lines get the value of the User field
start = s.indexOf ("User = \"") ;
end = s.indexOf ("\";", start) ;
if( start != -1 ){
sUser = s.slice (start+8, end) ;
}else {
sUser="";
}
//Next 3 lines get the value of the ComputerName field
start = s.indexOf ("ComputerName = \"") ;
end = s.indexOf ("\";", start) ;
sComputerName = s.slice (start+16, end) ;
//Next 3 lines get the value of the SourceName field
start = s.indexOf ("SourceName = \"") ;
end = s.indexOf ("\";", start) ;
sSourceName = s.slice (start+14, end) ;
//Next 3 lines get the value of the Category field
start = s.indexOf ("Category = ") ;
end = s.indexOf (";", start) ;
sCategory = s.slice (start+11, end) ;
//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+""
+""+sTimeGenerated+""
+""+sUser+""
+""+sComputerName+""
+""+sSourceName+""
+""+sCategory+""
+""
+""
+""
+"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,(INDEX_NEXT_TOP-INDEX_DATA)* numColumns);
}
if(numEELRecords > 0)
{
if(selectedRecord == selectedRow+INDEX_NEXT_TOP)
{
highlightRow();
//TABLEBODY1.rows(selectedRow-1).cells(0).focus();
}
else
{
if (selectedRow != -1)
for (j=0; j < TABLE1.rows(selectedRow).cells.length; j++)
TABLE1.rows(selectedRow).cells(j).style.background="rgb(255,255,255)" ;
}
}
getCurrentRecords();
}
function startTimer()
{
date0 = new Date();
}
function endTimer()
{
date1 = new Date();
alert("Time for your function - " + (date1.getTime() - date0.getTime() )/1000 + "seconds")
}
//-------------------------------------------------------------------------
// viewEELPrelude ()
//
// Called from the task frame
//-------------------------------------------------------------------------
function viewEELPrelude ( actionId, classView, machineName, query, nameSpace, sortFields, queryCols ) {
// build name space
if (machineName != "") {
machineName = "\\\\" + machineName + "\\" ;
}
nameSpace = machineName + nameSpace;
// make sure queryCols has the key, else append it.
if (queryCols.indexOf ("RecordNumber") == -1)
queryCols = queryCols + ", RecordNumber" ;
if(actionId == "NT")
{
if (queryCols.indexOf ("Logfile") == -1)
queryCols = queryCols + ", Logfile" ;
}
var query = buildQuery( actionId, classView, query, queryCols );
return viewEEL( machineName, nameSpace, query, actionId );
}
//------------------------------------------------------------------------
//
//
//
//------------------------------------------------------------------------
function buildQuery( actionId, classview, query, queryCols ) {
var s1;
// BUGBUG : handle the case when query is empty string
if( actionId == "EEL" )
{
s1 = "SELECT " + queryCols + " FROM Microsoft_EELEntry ";
queryCount = "SELECT __NAMESPACE FROM Microsoft_EELEntry ";
}
else if( actionId == "NT" )
{
if (classview != "All") {
if (query != "")
query = query + ' and (LogFile= "' + classview +'")';
else
query = '(LogFile= "' + classview +'")';
}
s1 = "SELECT " + queryCols + " FROM Win32_NTLogEvent";
queryCount = "SELECT __NAMESPACE FROM Win32_NTLogEvent";
}
if (query != "")
{
s1 = s1 + " WHERE (" + query + ")" ;
queryCount = queryCount + " WHERE (" + query + ")" ;
}
return s1;
}
//-------------------------------------------------------------------------------
// viewEEL
// This function will be executed when a EEL viewing task is selected from tasks.
//--------------------------------------------------------------------------------
function viewEEL (machineName, namespace, query, actionId) {
//this is required as the rows might have display off for a small query
// if that's not the spec, then remove the lines as display will always be
// on - check with AmitC
// optimise this by remembering which row onwards the
// display is off!
for(i=0;i