home *** CD-ROM | disk | FTP | other *** search
- // Auto Fix flow
- // Copyright (c) GTek Technologies Ltd.
-
- //======== Plugins are initialized on first call to getObj() method =====================
-
- var g_oXML = new ADPPlugin("Name=msxml,ProgID=Microsoft.XMLDOM"); // creates Xml Parser Object
- var g_oHideAb3 = new ADPPlugin("Name=HideAb3,DllName=HideAb3,FuncName=GetHiderDispatch");
-
- // Main Elements Objects in XML
- var flowSequenceXML;
- var eventColletionXML;
-
- var f_obj, f_objType, f_id, f_event, f_spanStep, f_hideStep; // XML flow seq. attributes
- var e_flowId, e_statId, e_obj, e_visible; // XML event / message collection attributes
-
- var g_sJsResult; // Js Function Events - relates to flow_func.js
- var bGetHide = false; // HideAb3 run flag
- var acsTimeout;
- var bAcsWait = false; // default - don't wait for AOL API return codes
-
- //======== XML Functions ================================================================
-
- function loadXML(fileXML) { // loads Xml Document
- g_oXML.getObj().async = "false";
- g_oXML.getObj().onreadystatechange = verify;
- g_oXML.getObj().load(fileXML);
- flowSequenceXML = g_oXML.getObj().documentElement.childNodes(0);
- eventColletionXML = g_oXML.getObj().documentElement.childNodes(1);
- }
-
- function verify() {
- if (g_oXML.getObj().readyState != 4)
- return false; // else = returns true (automatic)
- }
-
- function getXmlMatch(currFlag) { // matchs Xml Data to AF Events
- if (bAcsWait) { // breaks until AOL API returns complete
- acsTimeout = setTimeout(getXmlMatch, 2000);
- return true;
- }
-
- for (i=0;i<eventColletionXML.childNodes.length;i++) {
- loadEvents(i); // sets XML data into variables;
-
- if (e_flowId == currFlag) {
- hideProgBar(true);
- sendStat(e_statId);
-
- if (e_visible == "true") { // in case of message display
- g_oAdp.Vars("CurrentADP") = "goEndAF";
- window.location.replace(g_oAdp.Vars("StartHtm") + "?msgId=" + e_obj);
- } else {
- eval(e_obj); // runs function from XML by its full string form
- }
-
- return true;
- }
- }
-
- return false;
- }
-
- function loadFlow(itemLocation) {
- f_obj = flowSequenceXML.childNodes(itemLocation).getAttribute("obj");
- f_objType = flowSequenceXML.childNodes(itemLocation).getAttribute("objType");
- f_id = flowSequenceXML.childNodes(itemLocation).getAttribute("id");
- f_event = flowSequenceXML.childNodes(itemLocation).getAttribute("waitFor");
- f_spanStep = flowSequenceXML.childNodes(itemLocation).getAttribute("spanOn");
- f_hideStep = flowSequenceXML.childNodes(itemLocation).getAttribute("mayBeHidden");
- }
-
- function loadEvents(itemLocation) {
- e_flowId = eventColletionXML.childNodes(itemLocation).getAttribute("flowId");
- e_statId = eventColletionXML.childNodes(itemLocation).getAttribute("statId");
- e_obj = eventColletionXML.childNodes(itemLocation).getAttribute("obj");
- e_visible = eventColletionXML.childNodes(itemLocation).getAttribute("bVisible");
- }
-
- //======== AOLCoach CallBacks ===========================================================
-
- var g_sFixStatus = "";
-
- function Trainer_OnLessonStatus(sStatus) {
- g_sFixStatus = sStatus; // ACP - errors and values (resolution - ACP1)
- }
-
- function Trainer_OnLessonStart() {
- g_sFixStatus = "";
- }
-
- function Trainer_OnLessonFinish() {
- g_oHideAb3.getObj().Stop;
- var sResult = g_oIni.getObj().String("AdpData", "result", getIniPath());
-
- if (sResult == "Reboot") // closes ADP in case of pending reboot
- closeAdp();
-
- if (sResult != "") { // catchs Events
- if (!getXmlMatch(sResult))
- goStep("next");
- } else { // handles ACP errors
- if (!getXmlMatch(g_sFixStatus))
- goStep("next");
- }
- }
-
- //======== Dynamic GUI Creation functions ===============================================
-
- function loadSteps() {
- for (i=0;i<flowSequenceXML.childNodes.length;i++) {
- loadFlow(i); // sets XML data into variables
-
- if (f_id != null && !isStepHidden(f_hideStep))
- appendTable(i);
- }
-
- document.getElementById('BackgroundHeader').innerHTML = g_hdrStr; // creates Adp Header
- createBullets();
- hideProgBar(false);
- }
-
- function appendTable(currentItem) {
- currentTD = document.getElementById(f_id);
-
- if (currentItem == g_oAdp.Vars("currentStep")) { // Current Step
- setTableStyle(currentTD, false, "CurrentItem");
- } else if (currentItem < g_oAdp.Vars("currentStep")) { // Completed Step
- setTableStyle(currentTD, true, "CompletedItem");
- } else { // Future Step
- setTableStyle(currentTD, false, "NextItem");
- }
- }
-
- function createBullets() {
- tableRows = document.getElementById('ContentTable').childNodes[0].childNodes;
-
- for (j=0;j<tableRows.length;j++) {
- bulletTd = tableRows[j].insertCell(0);
- bulletTd.width = "10";
- bulletTd.vAlign = "Top";
- bulletTd.innerHTML = "<img src='../adpglobal/bullet.gif' ondrag='JavaScript:return false;'>";
- }
- }
-
- function setTableStyle(td, sign, cssClass) {
- td.className = cssClass;
- td.colspan = 2;
-
- if (sign) {
- td.colspan = 1;
- signTd = td.parentElement.insertCell();
- signTd.width = "10";
- signTd.innerHTML = "<img src='../adpglobal/v_sign.gif' ondrag='JavaScript:return false;'>";
- }
- }
-
- function setStepSpan() {
- if (f_spanStep != null)
- setTableStyle(document.getElementById(f_spanStep), false, "CurrentItem");
- }
-
- function isStepHidden(stepTerm) {
- if (f_hideStep != null) {
- bHideRes = eval(f_hideStep);
-
- if (bHideRes) {
- document.getElementById(f_id).parentElement.removeNode(true);
- return true;
- }
- }
-
- return false;
- }
-
- //======== AF execute parts =============================================================
-
- function goFlow() {
- setFlowMsgs();
- loadXML(formatFilePath(document.location.pathname, "flow_data.xml")); // loads Xml File
-
- if (g_oAdp.Vars("RunReboot") == "Reboot") {
- if (parseInt(g_oAdp.Vars("nBootStepIndex")) > 0) {
- g_oAdp.Vars("currentStep") = parseInt(g_oAdp.Vars("nBootStepIndex"));
- g_oAdp.Vars("nBootStepIndex") = "" // clears the flow flag
- } else {
- g_oAdp.Vars("currentStep") = flowSequenceXML.childNodes.length;
- }
- }
-
- loadSteps(); // displays Updated AF Location (list style)
-
- // If not at end of flow go to phase; else finish AF
- if (g_oAdp.Vars("currentStep") < flowSequenceXML.childNodes.length) {
-
- loadFlow(g_oAdp.Vars("currentStep")); // sets XML data into variables;
-
- if (f_objType=="js")
- setTimeout(runFix, 1000);
- else
- runFix();
- } else {
- hideProgBar(true); // ensure no prog_bar in case of restart
- setTimeout(goEndFlow, 2000);
- }
- }
-
- function runFix() {
- setStepSpan(); // sets joined span visual status
-
- if (f_objType == "acp")
- runAcpFix();
- else
- runJsFix();
- }
-
- function runAcpFix() { // runs *.atr File
- g_oHideAb3.getObj().Start;
- bGetHide = true;
- g_oIni.getObj().String("AdpData", "error_data", getIniPath()) = "";
- g_oIni.getObj().String("AdpData", "licence", getIniPath()) = "";
- g_oIni.getObj().String("AdpData", "result", getIniPath()) = "StartACP"; // continuously ESC protection
- g_oAdp.RunMeta("SB_CyberCoachWait", "");
- g_oAdp.RunFix(f_obj);
- }
-
- function runJsFix() { // runs Js Function
- eval(f_obj); // runnnig function from XML by it's full string form
-
- if (f_event != null)
- bAcsWait = true;
-
- if (!getXmlMatch(g_sJsResult)) // checks for Errors / Events
- goStep("next");
- }
-
- function clearAcsWait(sEventCode) {
- clearTimeout(acsTimeout);
- bAcsWait = false;
-
- if (!getXmlMatch(sEventCode)) // checks for Errors / Events
- goStep("next");
- }
-
- function goStep(sStep) { // moves Flow
- if (sStep == "next") // default - moves Next Action
- g_oAdp.Vars("currentStep")++;
- else // goes to Specific Step In Sequence
- g_oAdp.Vars("currentStep") = sStep;
-
- window.location.replace(document.location);
- }
-
- function hideProgBar(bHide) { // hides the progress bar
- progBar = document.getElementById("ProgressBar");
- progBarContainer = document.getElementById("ProgressBarContainer");
- progBar.attachEvent("ondrag", disableDrag);
-
- if (!bHide) {
- progBar.src = "../adpglobal/progbar.gif";
- progBarContainer.style.visibility = "visible";
- } else {
- progBarContainer.style.visibility = "hidden";
- }
- }
-
- function disableDrag() { // disables drag event
- return false;
- }
-
- function setFlowMsgs() { // hides all elements besids steps
- hideChildren(document.body);
- document.getElementById("StepsContainer").style.display = "";
- }
-
- function goEndFlow() {
- hideProgBar(true);
- sendStat("End");
- goEndAF(); // AOL CC AF - no need "Fixed" ADP msg.
- }
-
- function Window_OnClose() {
- if (bGetHide)
- g_oHideAb3.getObj().Stop;
-
- if (f_objType == "acp")
- g_oIni.getObj().String("AdpData", "licence", getIniPath()) = "FALSE";
-
- if (g_oAdp.Vars("StatWasSent") == "FALSE")
- sendStat("Quit");
-
- completeFix();
- closeAdp();
- }
-
- //======== ACS API events ===============================================================
-
- function OnEnd_Instantiate(sRes) {
- clearAcsWait("OnEnd_Instantiate_" + sRes);
- }
-
- function OnEnd_RebuildCurrentLocation(sRes) {
- clearAcsWait("OnEnd_RebuildCurrentLocation_" + sRes);
- }
-
- function OnEnd_FlowIsRunning(sRes) {
- clearAcsWait("OnEnd_FlowIsRunning_" + sRes);
- }
-
- function OnEnd_StopACS(sRes) {
- clearAcsWait("OnEnd_StopACS_" + sRes);
- }
-
- function OnEnd_RedetectDevices(sRes) {
- clearAcsWait("OnEnd_RedetectDevices_" + sRes);
- }
-
- function OnEnd_RebuildAdapter(sRes) {
- g_oAcs.getObj().UnloadAcs();
- }
-
- function OnEnd_WaitForConnection(sRes) {
- clearAcsWait("OnEnd_WaitForConnection_" + sRes);
- }
-
- function OnRebuildCurrentLocation(sRes) {
- clearAcsWait("OnRebuildCurrentLocation_" + sRes);
- }
-
- function OnEnd_UnloadAcs(sRes) {
- clearAcsWait("OnEnd_UnloadAcs_" + sRes);
- }