home *** CD-ROM | disk | FTP | other *** search
Wrap
//********************************************************************************** //** //** File Name: activator.js //** //** Summary: SupportSoft Activator Support JavaScript File //** //** Description: This file contains global functions and structures used by //** serveral pages to make HTTP POST calls with the SI information //** to communicate with backend systems via activators. //** //** Copyright SupportSoft Inc. 2003, All rights reserved. //** //********************************************************************************** //********************************************************************************** // Constants //********************************************************************************** // Values for index, tracking ID, sequence ID on submission of SmartIssue var SI_USERNAME_INDEX = "100"; var SI_THANKYOU_INDEX = "200"; var SI_USERNAME_SEQUENCE_ID = "1"; var SI_THANKYOU_SEQUENCE_ID = "2"; var SI_USERNAME_TRACKING_ID = "1"; var SI_THANKYOU_TRACKING_ID = "2"; // Custom error message var MSG_CUSTOM_ERROR = "We were unable to connect you to the server. Please check all your network connections and try again. If you continue to get this error, please contact Road Runner.<br>"; // If we fail basic connectivity test message var MSG_CONNECTIVITY_ERROR = "We were unable to establish basic network connection. Please check all your network connections and try again. If you continue to get this error, please contact BellSouth.<br>"; //********************************************************************************** // Functions //********************************************************************************** //******************************* // Name: ssDisplayStatus // Purpose: Hides buttons and shows status bar. Used with ssSendXml //******************************* function ssDisplayStatus() { document.all.error.style.display = "none"; document.all.main.style.display = "none"; document.all.status.style.display = "block"; document.all.buttons.style.visibility = "hidden"; setTimeout('ssSendXml(gGlobalServer)',1000); } //******************************* // Name: ssSendXml // Purpose: Submit SmartIssue to specified server to communicate with // backend servers via activators // Parameter: server -- The remote server to which the SmartIssue will be submitted // Return: boolean //******************************* function ssSendXml(strServer) { // Get date and format it var objDate = new Date(); var strDate = objDate.getDate(); var strYear = objDate.getFullYear(); var strMonth = objDate.getMonth(); var strHour = objDate.getHours(); var strMinutes = objDate.getMinutes(); var strSeconds = objDate.getSeconds(); var formattedDate = new Date(strYear,strMonth,strDate,strHour,strMinutes,strSeconds); var strFullDate = strMonth + "/" + strDate + "/" + strYear + " " + strHour + ":" + strMinutes + ":" + strSeconds; ssSetReg("timeFlow", ssGetReg("timeFlow") + strFullDate + "<br>"); // Begin submission stuff var strErrorMessage = ""; var issueId = ssGetIssueID(); var issueFile = document.si.GetIssueFile(issueId); var displayMain; var stat = false; if (strServer == "") { strServer = " "; } // Check basic connection before submitting SI if (!ssTestConnection(TEST_CONNECT_INT_ADD,TEST_CONNECT_INT_PORT)) { strErrorMessage = "<b>Error:</b> " + MSG_CONNECTIVITY_ERROR; if (ssGetCurrentPage() != "devices.htm") { document.all.main.style.display = "block"; document.all.status.style.display = "none"; document.all.error.style.display = "block"; document.all.buttons.style.visibility = "visible"; } stat = false; } // We have connectivity, so go ahead with SI submission else { document.si.EnableErrorExceptions(false); ssSetReg('CurrentSubmittedSI',issueId); var errCode = 0, stat = false; // Error handling if server is not found if (document.si.GetLastError() == 536870965) { var fullError = document.si.GetLastErrorMsg(); var errorSplit = fullError.split("="); strErrorMessage = errorSplit[1]; // Display the page properly if (ssGetCurrentPage() != "devices.htm") { document.all.main.style.display = "block"; document.all.status.style.display = "none"; document.all.error.style.display = "block"; document.all.buttons.style.visibility = "visible"; } } else { // Update the SmartIssue with new key/values document.si.StartXMLIO(issueFile); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "LastStep", ssGetNameIndex(ssGetCurrentPage()), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "LastPage", ssGetCurrentPage(), ""); // Break SI fields into chucks smaller than 300 characters to accommodate dynamic table limitations // on the server var pflowLength = ssGetReg("pageFlow").length; var pflowString = ssGetReg("pageFlow"); var trimmedString, className, pageIndex; var startIndex = 0; var endIndex = 294; if (pflowLength > 295) { var counter = Math.ceil(pflowLength/295); for (i=0; i<=counter-1; i++) { className = "PageFlow" + i; if (endIndex > pflowLength-1) { endIndex = pflowLength; } trimmedString = pflowString.slice(startIndex,endIndex); document.si.UpdateXMLFile("PageFlow", i, "PageFlow", trimmedString, ""); startIndex = endIndex; endIndex += 295; pageIndex = i; } } // if data is <= 295 characters else { document.si.UpdateXMLFile("PageFlow", 0, "PageFlow", ssGetReg("pageFlow"), ""); pageIndex = 0; } // Break SI fields into chucks smaller than 300 characters to accommodate dynamic table limitations // on the server var tflowLength = ssGetReg("timeFlow").length; var tflowString = ssGetReg("timeFlow"); var tTrimmedString, tclassName, timeIndex; var tstartIndex = 0; var tendIndex = 294; if (tflowLength > 295) { var counter = Math.ceil(tflowLength/295); for (j=0; j<=counter-1; j++) { className = "TimeFlow" + j; if (tendIndex > tflowLength) { tendIndex = tflowLength; } tTrimmedString = tflowString.slice(tstartIndex,tendIndex); document.si.UpdateXMLFile("TimeFlow", j, "TimeFlow", tTrimmedString, ""); tstartIndex = tendIndex; tendIndex += 295; timeIndex = j; } } // if data is <= 295 characters else { document.si.UpdateXMLFile("TimeFlow", 0, "TimeFlow", ssGetReg("timeFlow"), ""); timeIndex = 0; } document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "Language", ssGetReg("language"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "PageIndex", pageIndex, ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "TimeIndex", timeIndex, ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "Adapter", ssGetReg("SelectedAdapter"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "AdapterName", ssGetReg("AdapterName"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "AdapterType", ssGetReg("ModemType"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "FilterDemo", ssGetReg("FilterDemo"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "ModemDemo", ssGetReg("ModemDemo"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "provider", ssGetReg("provider"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "state", ssGetReg("state"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "division", ssGetReg("division"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "city", ssGetReg("city"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "firstname", ssGetReg("firstname"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "lastname", ssGetReg("lastname"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "zip", ssGetReg("zip"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "phone_num", ssGetReg("phone_num"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "workorder", ssGetReg("workorder"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "userid", ssGetReg("username"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "selfinstall", ssGetReg("selfinstall"), ""); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "ModemDemo", ssGetReg("ModemDemo"), ""); // Did technician do install var techdata = window.external.QueryRegValue("HKLM", "Software\\support.com", "TechData"); document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "TechData", techdata, ""); document.si.UpdateXMLFile("SDC_Connectivity", "ConnectionData", "PostToQueue", "0", ""); var pages = ssGetReg("pageFlow"); var times = ssGetReg("timeFlow"); var arrayPageFlow = pages.split("<br>"); var arrayTimeFlow = times.split("<br>"); var objDateOne, objDateTwo, dif, pageFormatted var elapsedTime = ""; for (k=0; k < arrayPageFlow.length-1; k++) { objDateOne = new Date(arrayTimeFlow[k]); objDateTwo = new Date(arrayTimeFlow[k+1]); dif = objDateTwo.getTime()-objDateOne.getTime(); // time on page in milliseconds dif = dif/1000; // time on page in seconds pageFormatted = arrayPageFlow[k].substring(0, arrayPageFlow[k].indexOf(".")) document.si.UpdateXMLFile("SDC_SAPages", k, "Page", pageFormatted, ""); document.si.UpdateXMLFile("SDC_SAPages", k, "Time", dif, ""); } var objDateStart, objDateEnd; objDateStart = new Date(arrayTimeFlow[0]); objDateEnd = new Date(arrayTimeFlow[arrayTimeFlow.length-2]); var milliseconds = objDateEnd.getTime()-objDateStart.getTime(); // elapsed time in milliseconds elapsedTime = milliseconds/1000; // elapsed time in seconds var elapsedSeconds, elapsedMinutes, elapsedHours; elapsedMinutes = elapsedTime/60; elapsedMinutes = Math.floor(elapsedMinutes); elapsedSeconds = eval(elapsedTime - (elapsedMinutes * 60)); elapsedHours = elapsedMinutes/60; elapsedHours = Math.floor(elapsedHours); elapsedMinutes = eval(elapsedMinutes - (elapsedHours * 60)); var strSeconds = new String(elapsedSeconds); var strMinutes = new String(elapsedMinutes); var strHours = new String(elapsedHours); // convert time to string if (strSeconds.length == 1) { strSeconds = "0" + strSeconds; } if (strMinutes.length == 1) { strMinutes = "0" + strMinutes; } if (strHours.length == 1) { strHours = "0" + strHours; } // format time for SI add var strElapsedTime = strHours + ":" + strMinutes + ":" + strSeconds; document.si.UpdateXMLFile("SDC_SAInfo", "SDC_SAInfo", "elapsedTime", strElapsedTime, ""); document.si.EndXMLIO(); // form local cab file name and location var cabIssueFile = issueFile.replace(/xml$/i, "cab"); // compress the xml to cab var success = window.external.CompressFile(issueFile, cabIssueFile, true); // form remote cab file destination var issueDir = strServer; issueDir += "\\issue\\"; var rcabFn = issueDir + issueId + ".cab" // submit SI to remote location through HttpRequest window.external.EnableErrorExceptions(false); stat = window.external.HttpRequest(2, cabIssueFile, rcabFn); // ************************** // Error handling // ************************** errCode = window.external.GetLastError(); var strReturnedMessage = ""; var strErrorMsg; if ((errCode != 0) && (errCode < 600)) { strErrorMsg = window.external.GetLastErrorMsg(); // Handle 500 errors if (errCode.toString().charAt(0) == 5 && errCode.toString().length == 3) { // Display test in the <h1> tag as error message var h1RegExp = /<h1>(.*)<\/h1>/i; var arrayResults = strErrorMsg.match(h1RegExp); var strParsedMessage; if (arrayResults != null) { strParsedMessage = arrayResults[1]; } else { strParsedMessage = "Internal Server Error."; } strErrorMessage = "<b>Error " + errCode + ":</b> " + strParsedMessage + "<br>"; } // Parse the return to get errors var arrayErrorMsg = strErrorMsg.split("(ProvActivator)-MESSAGE: |"); if (arrayErrorMsg.length > 1) { var completionCode = 0; var errorCode = 0; var trackingID = 0; var sequenceID = 0; var errorText = ""; var activeError = ""; var username = ""; // Break down the sections var arrayKeyValue = arrayErrorMsg[1].split("|"); for (i=0; i <= arrayKeyValue.length-1; i++) { var arrayFields = arrayKeyValue[i].split("="); switch (arrayFields[0]) { case "completioncode" : completionCode = arrayFields[1]; break; case "errortext" : errorText = arrayFields[1]; break; case "errorcode" : errorCode = arrayFields[1]; break; case "trackingid" : trackingID = arrayFields[1]; break; case "sequence" : sequenceID = arrayFields[1]; break; case "activeerror" : activeError = arrayFields[1]; break; case "username" : username = arrayFields[1]; break; } } if (activeError != "") { strErrorMessage = "<b>Error " + errCode + ":</b> " + activeError + "<br>"; } else if (completionCode != 1) { if (errorCode != 0) { strErrorMessage = "<b>Error " + errCode + ":</b> " + errorText + "<br>"; } else { strErrorMessage = "<b>Error " + errCode + ":</b> " + completionCode + "<br>"; } } } } else { strErrorMessage = "<b>Custom Error " + errCode + ":</b> Server: " + strServer + ".<br>" + MSG_CUSTOM_ERROR; } if (stat == true && strErrorMessage == "") { if (ssGetCurrentPage() != "thankyou.htm") { // Advance to next page ssGoNextStep(); } } else { if (ssGetCurrentPage() != "devices.htm" && ssGetCurrentPage() != "thankyou.htm") { document.all.error.style.display = "block"; document.all.main.style.display = displayMain; document.all.status.style.display = "none"; document.all.buttons.style.visibility = "visible"; } } } } // If we found an error, display it properly if (strErrorMessage != "") { if (ssGetCurrentPage() == "thankyou.htm") { document.all.error.style.display = "block"; document.all.error.innerHTML = "<p class='error'><b>Error:</b> " + strErrorMessage + "</p>"; } } return stat; window.external.EnableErrorExceptions(true); }