home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- DESC: Common Report Functions for the Administer Operations
-
- PLATFORMS: >= MS IE 4.0
-
- USAGE NOTES:
- ====================================================================== */
- var RMode = ""; // Mode of Operation, New, Edit, Delete, Lookup
- var RptSelectIdx = 0; // Report select index
- var RptLupRecCount = 0; // Report Lookup record count
- var SALupRecCount = 0; // SA Lookup record count
- var CmpLupRecCount = 0; // Computer Lookup record count
- var ReportRecLength = 7; // Report Lookup record length
- var CmpRecLth = 7; // Computer Loopkup record length
- var SaRecLth = 6; // Analysis Loopkup record length
- var needSA = true; // Lookup required
- var needComputer = true; // Lookup required
- var needGroup = true; // Lookup required
- var CurSaStoreIdx = 0; // index into Sa Store for current Selected entry
- var CurCmpStoreIdx = 0; // index into Computer Store for Selected Computer Name
- var CidCTab = new Array("","000000","00000","0000","000","00","0","");
- var CidSortArray = null; // Array of sorted Computer IDs
- var BinSearchThresh = (15*CmpRecLth); // Threshold for doing Binary search
- var ReconnectEvent = false;
- var Hp = 82;
- var AR_SaStoreArr = new Array();
- var AR_CmpStoreArr = new Array();
- var AR_RptStoreArr = new Array();
-
- /* On Load tell the Comm control to Connect to the Server */
- function InitRpmCC_AR() {
- top.MainLoaded = true; // Flag loaded
- initButtonState(); // set initial button state for all buttons
- Hp = parseInt(document.body.RPMHostPort,10);
- RpmCC_AR.Connect(document.body.RPMHostIP,Hp, "");
- }
- function processRepReconnect() {
- Tid = null;
- if ( RpmCC_AR.IsConnected() ) {
- Tid = setTimeout("processRepConnectionCheck()",30000); // Delay 30 secs then check connection
- return;
- }
- RpmCC_AR.Connect(document.body.RPMHostIP,Hp, "");
- }
- function processRepConnectConfirmed() {
- // Restore Filter and Computer Store
- if ( ReconnectEvent == false ) {
- RpmCC_AR.GetGlobalSMTP(); // Request Global SMTP address
- RpmCC_AR.GetGlobalSMTPAuth(); // Request Global SMTP authorization status
- processReportsLookupReset(); // go do Reports Lookup
- ReconnectEvent = true;
- }
- top.Rstatus.Pstat("Connected");
- if ( Tid != null ) {
- clearTimeout(Tid); // stop timeout routine
- }
- Tid = setTimeout("processRepConnectionCheck()",30000); // Delay 30 secs then check connection
- }
- function processRepConnectionCheck() {
- Tid = null;
- RpmCC_AR.SendKeepAlive("Check");
- Tid = setTimeout("processRepConnectionCheck()",30000); // Delay 30 secs then check connection
- }
-
- /* On Unload tell the Comm control to Disconnect from the Server */
- function DiscoRpmCC_AR() {
- RpmCC_AR.Disconnect();
- top.banner.processStopCommX();
- if ( Tid != null ) {
- clearTimeout(Tid); // stop timeout routine
- }
- }
-
- /* Initial Reports Lookup Request */
- function processReportsLookupReset() {
- /* Make sure Report Store and Report Name combo are flushed */
- lth = document.all.AR_RptSel.length;
- for (i=0; i < lth; ++i)
- document.all.AR_RptSel.remove(0);
-
- AR_RptStoreArr.length = 0;
- RptLupRecCount = 0; // clear Lookup record counter
- processSpecialReportHandling();
-
- if ( RpmCC_AR.AdminReportsLookup("*") ) {
- RMode = "";
- top.Rstatus.Pstat("Unable to start the REPORT LOOKUP request",true);
- }
- else {
- RMode = "LookupReport"; // set Mode of operation
- top.Rstatus.Pstat("One moment while REPORT LOOKUP request completes");
- }
- }
-
- /* Process Combo Report Name Change Event */
- function processReportName() {
- Nobj = document.all.AR_RptSel; // get object
- for (i=0; i < Nobj.length; ++i) {
- if ( Nobj.options[i].selected ) {
- RptSelectIdx = i;
- populateInput(ReportRecLength*i);
- break;
- }
- }
- }
-
- /* Get SA "Name" string based on SA ID and set Selected Bool */
- function getSelectSaName_Desc(Sid) {
- N_D = "";
- for (var i=0; i < AR_SaStoreArr.length; i+=SaRecLth) {
- if ( AR_SaStoreArr[i+1] == Sid ) {
- N_D = AR_SaStoreArr[i];
- CurSaStoreIdx = i; // save index to Store for Selected entry
- break;
- }
- }
- return N_D;
- }
-
- /* Get Computer "Name : Description" string based on Computer ID and set Selected Bool */
- function getSelectCmpName_Desc(Cid) {
- var i;
- N_D = "";
- if ( AR_CmpStoreArr.length < BinSearchThresh ) { // if less than threshold, use For loop
- for ( i=0; i < AR_CmpStoreArr.length; i+=CmpRecLth) {
- if ( AR_CmpStoreArr[i+3] == Cid )
- break;
- }
- }
- else { // set up and do a binary search
- var SAr = new Array();
- sbase = 0; // initial base
- ecid = parseFloat(Cid); // get numeric value
- sl = CidSortArray.length >>> 1; // initial index is half the length
- while ( true ) { // do binary search
- if ( (sbase+sl) >= CidSortArray.length ) { // don't let index exceed length
- --sl
- continue;
- }
- SAr = CidSortArray[sbase+sl].split("~");
- ccid = parseFloat(SAr[0]); // numeric Cid
- if ( ecid == ccid ) // if match
- break;
- if ( sl == 0 ) { // not found
- return "";
- }
- nbase = sbase + sl; // create new base
- nsl = sl >>> 1; // halve length of index
- sl = (sl > 2) ? nsl+1 : nsl; // round index when > 2
- if ( ecid > ccid ) // keep searching
- sbase = nbase;
- }
- i = parseFloat(SAr[1]) * CmpRecLth;
- }
- if ( i < AR_CmpStoreArr.length ) { // if found
- AR_CmpStoreArr[i+5] = 1; // set Selected
- N_D = AR_CmpStoreArr[i] + " / " + AR_CmpStoreArr[i+2];
- CurCmpStoreIdx = i;
- }
- return N_D;
- }
-
- /* Process Report LOOKUP RECORD Event */
- function processReportLookupRecord(Rid,RptName,RptDesc,RptD_T,AIA,CIA,MaxIntv) {
- RNameObj = document.all.AR_RptSel; // Report Name Combo box
- addElementToSelect(RNameObj,RptName);
- // Update Storage
- i = ReportRecLength * RptLupRecCount;
- AR_RptStoreArr[i+0] = RptName;
- AR_RptStoreArr[i+1] = Rid;
- AR_RptStoreArr[i+2] = RptDesc;
- AR_RptStoreArr[i+3] = RptD_T;
- AR_RptStoreArr[i+4] = AIA;
- AR_RptStoreArr[i+5] = CIA;
- AR_RptStoreArr[i+6] = MaxIntv;
- ++RptLupRecCount; // bump record received counter
- ReportRecLength = 7; // length of a Storage record
- }
-
- /* Process DB Error in Report Lookup Operation */
- function processReportOpError() {
- top.Rstatus.Pstat("An error occurred during Report LOOKUP operation",true);
- processResetButton(); // reset
- }
-
- /* Get Report Name from Store based on Report ID */
- function getReportName(RID) {
- RptName = "";
- for (var i=0, j=0; i < AR_RptStoreArr.length; ++j, i+=ReportRecLength) {
- if ( AR_RptStoreArr[i+1] == RID ) {
- RptName = AR_RptStoreArr[i];
- RptSelectIdx = j;
- document.all.AR_RptSel.options[j].selected = "selected";
- break;
- }
- }
- return RptName;
- }
-
- /* Get Report ID from Store based on Report Name */
- function getReportID(RNM) {
- RID = 0;
- for (var i=0, j=0; i < AR_RptStoreArr.length; ++j, i+=ReportRecLength) {
- if ( AR_RptStoreArr[i] == RNM ) {
- RptSelectIdx = j;
- RID = AR_RptStoreArr[i+1];
- break;
- }
- }
- return RID;
- }
-
- function processSupportAnalysisLookupRecord(Aid,ANme,ADesc,OCXNme,CntArr,OSverArr) {
- var i = SaRecLth * SALupRecCount;
- AR_SaStoreArr[i+0] = ANme;
- AR_SaStoreArr[i+1] = Aid;
- AR_SaStoreArr[i+2] = ADesc;
- AR_SaStoreArr[i+3] = OCXNme;
- AR_SaStoreArr[i+4] = CntArr;
- AR_SaStoreArr[i+5] = OSverArr;
- ++SALupRecCount; // bump record received counter
- SaRecLth = 6; // Storage record length
- }
-
- /* Process Support Analysis OP Complete Event */
- function processSupportAnalysisOpComplete() {
- top.Rstatus.Pstat("Request Completed");
- if (RMode == "TLookupSA") {
- processTemplateLookupComplete();
- return;
- }
- if (SALupRecCount == 0) { // check if any records found
- top.Rstatus.Pstat("No record matches found for Template LOOKUP request",true);
- processResetButton();
- }
- needSA = false;
- if ( needComputer ) {
- CmpLupRecCount = 0; // initialize record counter
- AR_CmpStoreArr.length = 0;
- CidSortArray = new Array();
-
- if ( RpmCC_AR.ComputerLookup("*","*") ) {
- top.Rstatus.Pstat("Unable to start the COMPUTER LOOKUP request",true);
- processResetButton();
- }
- else { // waiting for OperationCompleteEvent
- SetCursor("wait");
- C_CommBusy = 1; // set Comm busy flag
- top.Rstatus.Pstat("One moment while COMPUTER LOOKUP request completes");
- }
- }
- else {
- processResetButton();
- }
- }
-
- /* Process DB Error in Support Analysis Lookup Operation */
- function processSupportAnalysisOpError() {
- top.Rstatus.Pstat("An error occurred during Template LOOKUP operation",true);
- processResetButton(); // reset
- }
-
- /* Process Computer Lookup Op Complete Event */
- function processComputerOpComplete() {
- SetCursor("auto");
- top.Rstatus.Pstat("Request Completed");
- if (CmpLupRecCount == 0) { // check if any records found
- top.Rstatus.Pstat("No record matches found for COMPUTER LOOKUP request",true);
- processResetButton();
- }
- needComputer = false;
- CidSortArray.sort();
- if ( needGroup ) {
- GrpLupRecCount = 0; // initialize record counter
- if ( RpmCC_AR.GroupLookup("","","") ) {
- top.Rstatus.Pstat("Unable to start the GROUP LOOKUP request",true);
- processResetButton();
- }
- else { // waiting for OperationCompleteEvent
- C_CommBusy = 1; // set Comm busy flag
- top.Rstatus.Pstat("One moment while GROUP LOOKUP request completes");
- }
- }
- else {
- processResetButton();
- }
- }
-
- /* Process DB Error in Computer Lookup Operation */
- function processComputerOpError() {
- top.Rstatus.Pstat("An error occurred during COMPUTER LOOKUP operation",true);
- SetCursor("auto");
- processResetButton(); // reset
- }
-
- /* Process Computer LOOKUP RECORD Event */
- function processComputerLookupRecord(Cid,Gid,Name,Desc,OSVer) {
- CmpRecLth = 7; // Storage record length
- var i = CmpLupRecCount * CmpRecLth;
- AR_CmpStoreArr[i] = Name;
- AR_CmpStoreArr[i+1] = Gid;
- AR_CmpStoreArr[i+2] = Desc;
- AR_CmpStoreArr[i+3] = Cid;
- AR_CmpStoreArr[i+4] = OSVer;
- AR_CmpStoreArr[i+5] = 0; // Selected Bool
- OSVer = mapOSVer(OSVer); // map OS version to Generic OS types
- AR_CmpStoreArr[i+6] = OSVer;
- var i = CidCTab[Cid.length] + Cid + "~" + CmpLupRecCount;
- CidSortArray[CmpLupRecCount++] = i;
- }
-
- /* Process Group Lookup Op Complete Event */
- function processGroupOpComplete() {
- top.Rstatus.Pstat("Request Completed");
- if (GrpLupRecCount == 0) { // check if any records found
- top.Rstatus.Pstat("No record matches found for GROUP LOOKUP request",true);
- }
- needGroup = false;
- processResetButton();
- }
-
- function processKeyPress() {
- /* get KeyCode and check if invalid */
- kc = event.keyCode;
- stat = 1; // default to OK
-
- // Keys: ~ % [ ] # !
- if (kc == 126 || kc == 37 || kc == 91 || kc == 93 || kc == 35 || kc == 33) { // Not acceptable
- stat = 0;
- } // Keys: * ?
- else if ( (kc == 42 || kc == 63) && event.srcElement.name != "AR_Rpt" ) { //Not acceptable
- stat = 0;
- }
- if (stat == 0) { // if Not Acceptable
- event.returnValue=false;
- top.Rstatus.Pstat("Keys ~%*?[]#! are not accepted for this field");
- alert("Keys ~%*?[]#! are not accepted for this field");
- }
- else {
- top.Rstatus.Pstat(""); // clear status line
- }
- }
-
-