home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / com / controller / UICoordinator.as
Text File  |  2007-10-16  |  13KB  |  391 lines

  1. class com.controller.UICoordinator
  2. {
  3.    var c_objTestXML = new Object();
  4.    function UICoordinator()
  5.    {
  6.       com.controller.UICoordinator.c_objInstance = null;
  7.    }
  8.    static function getInstance()
  9.    {
  10.       if(com.controller.UICoordinator.c_objInstance == null)
  11.       {
  12.          com.controller.UICoordinator.c_objInstance = new com.controller.UICoordinator();
  13.       }
  14.       return com.controller.UICoordinator.c_objInstance;
  15.    }
  16.    function init(_strDataPath)
  17.    {
  18.       var _loc1_ = this;
  19.       _loc1_.c_objObjectManager = new com.data.ObjectManager();
  20.       _loc1_.c_objScreenFactory = new com.screen.ScreenFactory();
  21.       _loc1_.c_objLoginHandler = new com.handler.LoginHandler();
  22.       _loc1_.c_objInstructionHandler = new com.handler.InstructionHandler();
  23.       _loc1_.c_objTestHandler = new com.handler.TestHandler();
  24.       _loc1_.c_objDAO = com.data.DAO.getInstance();
  25.       _loc1_.c_strUserName = "";
  26.       _loc1_.c_strASCIIUserName = "";
  27.       _loc1_.c_strcurrentTestName = "";
  28.       _loc1_.c_strTimeLeft = "";
  29.       _loc1_.c_strCurrentMode = "";
  30.       _loc1_.c_strSkillName = "";
  31.       _loc1_.c_iCurrentTestNumber = 0;
  32.       _loc1_.doAction("SETENVIRONMENT","");
  33.       _loc1_.doAction("INIT",_strDataPath);
  34.    }
  35.    function doAction(_strAction, _objParam)
  36.    {
  37.       var _loc1_ = this;
  38.       var _loc2_ = _objParam;
  39.       _loc1_.c_strXMLPath = _loc1_.c_objObjectManager.returnPath("XML");
  40.       _loc1_.c_strResultXMLPath = _loc1_.c_objObjectManager.returnPath("RESULTXML");
  41.       var _loc3_ = _loc1_.getOSEnvironment();
  42.       switch(_strAction)
  43.       {
  44.          case "SETENVIRONMENT":
  45.             _loc1_.setEnvironmentVariable();
  46.             break;
  47.          case "INIT":
  48.             _loc1_.c_objDAO.addListener(_loc1_);
  49.             _loc1_.c_objDAO.load("PathXML",_loc2_);
  50.             break;
  51.          case "LOGIN":
  52.             _loc1_.c_objDAO.load("BaseXML",_loc1_.c_strXMLPath + "base.xml");
  53.             break;
  54.          case "INSTRUCTION":
  55.             var strTemp = _loc1_.c_strFileName.charAt(_loc1_.c_strFileName.length - 1);
  56.             _loc1_.c_iCurrentTestNumber = strTemp;
  57.             _loc1_.c_objDAO.load("INSTRUCTIONXML",_loc1_.c_strXMLPath + "base.xml");
  58.             break;
  59.          case "TestXML":
  60.             _loc1_.__set__ipPort(_loc1_.c_objObjectManager.returnPath("IPPort"));
  61.             delete _loc1_.c_objLoginHandler;
  62.             _loc1_.c_objTestSelectHandler = new com.handler.TestSelectHandler();
  63.             _loc1_.c_objDAO.load("TestXML",_loc1_.c_strResultXMLPath + _loc1_.c_strXMLPath + "tests.xml");
  64.             break;
  65.          case "RecordXML":
  66.             _loc3_ = _loc1_.getOSEnvironment();
  67.             var strXML;
  68.             if(_loc3_ == "Linux")
  69.             {
  70.                strXML = _loc1_.getRecordSet();
  71.             }
  72.             _loc1_.c_objDAO.load("RecordXML",strXML);
  73.             break;
  74.          case "LoadScore":
  75.             _loc3_ = _loc1_.getOSEnvironment();
  76.             var strXML;
  77.             if(_loc3_ == "Linux")
  78.             {
  79.                var strUserName = com.controller.UICoordinator.getInstance().userASCIIName;
  80.                var strScoreFileName = String(_loc2_).split(".")[0];
  81.                strXML = _loc1_.c_objTestXML[strScoreFileName];
  82.             }
  83.             _loc1_.c_objDAO.load("ScoreXML",strXML);
  84.             break;
  85.          case "LOADTEST":
  86.             delete _loc1_.c_objLoginHandler;
  87.             var strTemp = _loc1_.c_strFileName.charAt(_loc1_.c_strFileName.length - 1);
  88.             _loc1_.c_iCurrentTestNumber = strTemp;
  89.             var strPath = _loc1_.c_strResultXMLPath + "tests/test" + _loc1_.c_iCurrentTestNumber + "/xml/";
  90.             _loc1_.c_objDAO.load("TestXML1",strPath + _loc1_.c_strFileName + ".xml");
  91.             break;
  92.          case "ReviewResult":
  93.             _loc1_.c_objTestHandler = new com.handler.TestHandler();
  94.             var strXML;
  95.             var strXMLFileName = _loc1_.convertToASCII(_loc2_.toString()) + ".xml";
  96.             var strTemp = _loc2_.charAt(_loc2_.length - 1);
  97.             _loc1_.c_iCurrentTestNumber = strTemp;
  98.             if(_loc3_ == "Linux")
  99.             {
  100.                var strUserName = com.controller.UICoordinator.getInstance().userASCIIName;
  101.                strXML = _loc1_.c_objTestXML[_loc1_.currentTestName];
  102.             }
  103.             _loc1_.c_objDAO.load("ReviewResultXML",strXML);
  104.             break;
  105.          case "SHOWRESULT":
  106.             _loc1_.c_objResultHandler = new com.handler.ResultHandler();
  107.             _loc1_.c_objResultHandler.startProcess("ShowResult",true);
  108.             break;
  109.          case "TestSound":
  110.             _loc1_.c_objTestSoundHandler = new com.handler.CheckSoundHandler();
  111.             _loc1_.c_objTestSoundHandler.startProcess("TestSound",true);
  112.       }
  113.    }
  114.    function DAOUpdate(_strXMLID)
  115.    {
  116.       var _loc1_ = this;
  117.       switch(_strXMLID)
  118.       {
  119.          case "PathXML":
  120.             if(_loc1_.c_objDAO.success)
  121.             {
  122.                if(_loc1_.c_objObjectManager.getObject("Path") != null && _loc1_.c_objObjectManager.getObject("Path") != undefined)
  123.                {
  124.                   _loc1_.c_objObjectManager.persistObject("PathXML",_loc1_.c_objObjectManager.getObject("Path"));
  125.                   _loc1_.doAction("LOGIN","");
  126.                }
  127.             }
  128.             else
  129.             {
  130.                trace("Error loading Path xml");
  131.             }
  132.             break;
  133.          case "BaseXML":
  134.             !_loc1_.c_objDAO.success ? (trace("Error loading Base xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objLoginHandler.startProcess("Login",true);
  135.             break;
  136.          case "INSTRUCTIONXML":
  137.             !_loc1_.c_objDAO.success ? (trace("Error loading Base xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objInstructionHandler.startProcess("Instruction",true);
  138.             break;
  139.          case "TestXML":
  140.             _loc1_.doAction("RecordXML","");
  141.             break;
  142.          case "RecordXML":
  143.             _loc1_.c_objRecordXML = _loc1_.c_objDAO.getDataSet("RecordXML:");
  144.             var _loc2_ = _loc1_.c_objObjectManager.getObject("RecordXML");
  145.             !_loc1_.c_objDAO.success ? (trace("Error loading test xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objTestSelectHandler.startProcess("TestSelect",_loc2_);
  146.             break;
  147.          case "ScoreXML":
  148.             !_loc1_.c_objDAO.success ? _loc1_.c_objTestSelectHandler.getScore("NOXML") : _loc1_.c_objTestSelectHandler.getScore("TestSelect");
  149.             break;
  150.          case "ContentXML":
  151.             !_loc1_.c_objDAO.success ? (trace("Error loading Content xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objTestHandler.startProcess("LoadTest",true);
  152.             break;
  153.          case "TestXML1":
  154.             !_loc1_.c_objDAO.success ? (trace("Error loading Content xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objTestHandler.startProcess("Test",true);
  155.             break;
  156.          case "ReviewResultXML":
  157.             !_loc1_.c_objDAO.success ? (trace("Error loading Content xml"), ┬º┬ºpush(undefined), undefined) : _loc1_.c_objTestHandler.reviewProcess("Test",true);
  158.       }
  159.    }
  160.    function setEnvironmentVariable()
  161.    {
  162.       var _loc1_ = System.capabilities.manufacturer;
  163.       var _loc2_ = _loc1_.split(" ")[1];
  164.       this.setOSEnvironment(_loc2_);
  165.    }
  166.    function destroyInstance(_objInstance, _objRef)
  167.    {
  168.       delete _objRef._objInstance;
  169.    }
  170.    function convertToASCII(_strValue)
  171.    {
  172.       var _loc3_ = _strValue;
  173.       _loc3_ = _loc3_.toUpperCase();
  174.       var strASCII = "";
  175.       var _loc2_ = 0;
  176.       while(_loc2_ < _loc3_.length)
  177.       {
  178.          var _loc1_ = Number(_loc3_.charCodeAt(_loc2_));
  179.          if(_loc1_ >= 65 && _loc1_ <= 86)
  180.          {
  181.             _loc1_ += 4;
  182.          }
  183.          else if(_loc1_ >= 86 && _loc1_ <= 90)
  184.          {
  185.             _loc1_ = _loc1_ + 4 - 26;
  186.          }
  187.          else
  188.          {
  189.             switch(_loc1_)
  190.             {
  191.                case 32:
  192.                   _loc1_ = 115;
  193.                   break;
  194.                case 34:
  195.                   _loc1_ = 97;
  196.                   break;
  197.                case 42:
  198.                   _loc1_ = 98;
  199.                   break;
  200.                case 47:
  201.                   _loc1_ = 99;
  202.                   break;
  203.                case 58:
  204.                   _loc1_ = 100;
  205.                   break;
  206.                case 60:
  207.                   _loc1_ = 101;
  208.                   break;
  209.                case 62:
  210.                   _loc1_ = 102;
  211.                   break;
  212.                case 63:
  213.                   _loc1_ = 103;
  214.                   break;
  215.                case 92:
  216.                   _loc1_ = 104;
  217.                   break;
  218.                case 124:
  219.                   _loc1_ = 105;
  220.             }
  221.          }
  222.          strASCII += String.fromCharCode(_loc1_);
  223.          _loc2_ = _loc2_ + 1;
  224.       }
  225.       return strASCII;
  226.    }
  227.    function getRecordSet()
  228.    {
  229.       var _loc1_ = this;
  230.       if(_loc1_.c_strRecordSet == undefined || _loc1_.c_strRecordSet == null)
  231.       {
  232.          _loc1_.c_strRecordSet = "<record />";
  233.       }
  234.       return _loc1_.c_strRecordSet;
  235.    }
  236.    function getObjectManagerInstance()
  237.    {
  238.       return this.c_objObjectManager;
  239.    }
  240.    function getScreenFactoryInstance()
  241.    {
  242.       return this.c_objScreenFactory;
  243.    }
  244.    function get userASCIIName()
  245.    {
  246.       return this.c_strASCIIUserName;
  247.    }
  248.    function set userASCIIName(_strUserName)
  249.    {
  250.       var _loc1_ = this;
  251.       var _loc2_ = _loc1_.convertToASCII(_strUserName);
  252.       _loc1_.c_strASCIIUserName = _loc2_;
  253.    }
  254.    function get userName()
  255.    {
  256.       return this.c_strUserName;
  257.    }
  258.    function set userName(_strUserName)
  259.    {
  260.       this.c_strUserName = _strUserName;
  261.    }
  262.    function set currentTestName(_strcurrentTestName)
  263.    {
  264.       this.c_strcurrentTestName = _strcurrentTestName;
  265.    }
  266.    function get currentTestName()
  267.    {
  268.       return this.c_strcurrentTestName;
  269.    }
  270.    function set currentTestNumber(_iCurrentTestNumber)
  271.    {
  272.       this.c_iCurrentTestNumber = _iCurrentTestNumber;
  273.    }
  274.    function get currentTestNumber()
  275.    {
  276.       return this.c_iCurrentTestNumber;
  277.    }
  278.    function set fileName(_strFileName)
  279.    {
  280.       this.c_strFileName = _strFileName;
  281.    }
  282.    function get fileName()
  283.    {
  284.       return this.c_strFileName;
  285.    }
  286.    function set currentMode(_strCurrentMode)
  287.    {
  288.       this.c_strCurrentMode = _strCurrentMode;
  289.    }
  290.    function get currentMode()
  291.    {
  292.       return this.c_strCurrentMode;
  293.    }
  294.    function set skillName(_strSkillName)
  295.    {
  296.       this.c_strSkillName = _strSkillName;
  297.    }
  298.    function get skillName()
  299.    {
  300.       return this.c_strSkillName;
  301.    }
  302.    function set volumeLevel(_strVolumeLevel)
  303.    {
  304.       this.c_strVolumeLevel = _strVolumeLevel;
  305.    }
  306.    function get volumeLevel()
  307.    {
  308.       return this.c_strVolumeLevel;
  309.    }
  310.    function set timeLeft(_strTimeLeft)
  311.    {
  312.       this.c_strTimeLeft = _strTimeLeft;
  313.    }
  314.    function get timeLeft()
  315.    {
  316.       return this.c_strTimeLeft;
  317.    }
  318.    function set instructionXML(_objInstructionXML)
  319.    {
  320.       this.c_objInstructionXML = _objInstructionXML;
  321.    }
  322.    function get instructionXML()
  323.    {
  324.       return this.c_objInstructionXML;
  325.    }
  326.    function set ipPort(_strIpPort)
  327.    {
  328.       this.c_strIpPort = _strIpPort;
  329.    }
  330.    function get ipPort()
  331.    {
  332.       return this.c_strIpPort;
  333.    }
  334.    function getTestTime()
  335.    {
  336.       return this.c_iTestTime;
  337.    }
  338.    function setTestTime(_iTestTime)
  339.    {
  340.       this.c_iTestTime = _iTestTime;
  341.    }
  342.    function getXMLPath()
  343.    {
  344.       return this.c_strXMLPath;
  345.    }
  346.    function getResultXMLPath()
  347.    {
  348.       return this.c_strResultXMLPath;
  349.    }
  350.    function getOSEnvironment()
  351.    {
  352.       return "Linux";
  353.    }
  354.    function setOSEnvironment(_strEnvironment)
  355.    {
  356.       this.c_strOSEnvironment = _strEnvironment;
  357.    }
  358.    function setTotalQuestion(_iTotalQuestion)
  359.    {
  360.       this.c_iTotalTestQuestion = _iTotalQuestion;
  361.    }
  362.    function getTotalQuestion()
  363.    {
  364.       return this.c_iTotalTestQuestion;
  365.    }
  366.    function setTotalAttemptedQuestion(_iTotalAttemptedQuestion)
  367.    {
  368.       this.c_iTotalAttemptedQuestion = _iTotalAttemptedQuestion;
  369.    }
  370.    function getTotalAttemptedQuestion()
  371.    {
  372.       return this.c_iTotalAttemptedQuestion;
  373.    }
  374.    function setTotalTestMark(_iTotalTestMark)
  375.    {
  376.       this.c_iTotalTestMark = _iTotalTestMark;
  377.    }
  378.    function getTotalTestMark()
  379.    {
  380.       return this.c_iTotalTestMark;
  381.    }
  382.    function setTitle(_strTitle)
  383.    {
  384.       this.c_strTitle = _strTitle;
  385.    }
  386.    function getTitle()
  387.    {
  388.       return this.c_strTitle;
  389.    }
  390. }
  391.