home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2003 October / cmycha200310.iso / NHL2004 / NHL2004Demo.exe / fe / COMMON / js / System.js < prev    next >
Text File  |  2003-08-20  |  7KB  |  218 lines

  1. function SystemClass() { this.handleErrorTimerID = 0; };
  2. SystemClass.prototype.libraryClasses             = [
  3.                                             "Remote_Request",
  4.                                             "JAX_Object",
  5.                                             "JAX_Cookie",
  6.                                             "User_Profile",
  7.                                             "User_Stats_Base",
  8.                                             "NHL_Stats_Base",
  9.                                                     "Tournament"
  10.                                              ];
  11. SystemClass.prototype.handleError                = function(msg, line, url, dontNav)
  12. {
  13.     var bCont         = true;
  14.     if (System.GUI.loadingDialog) { System.GUI.loadingDialog.hide(); };
  15.     if (msg.match(/(?:\:\:\d+\:\:|\:\:\-\d+\:\:)/g)) {
  16.         var errorCode                    = "";
  17.         var errorMsg                    = "";
  18.         errorCode                    = msg.match(/(?:\:\:\d+\:\:|\:\:\-\d+\:\:)/g).toString();
  19.         errorMsg                    = msg.substr(errorCode.lastIndexOf("::") +2);
  20.         errorCode                    = errorCode.substr(2);
  21.         errorCode                    = errorCode.substr(0, errorCode.lastIndexOf("::"));
  22.  
  23.         gblRRManager.doCancel();
  24.  
  25.         if (System.GUI.dialog) {
  26.  
  27.             var bShowServerErrorMsg = false;
  28.             errorCode        = parseInt(errorCode);
  29.             if  (errorCode == 10 || (errorCode >=102 && errorCode <=122) ) {
  30.                 bShowServerErrorMsg = true;
  31.             } else if (errorCode == 97 || errorCode == 99) {
  32.                 bShowServerErorrMsg = false;
  33.             } else if (errorCode >= 130 && errorCode <= 139) {
  34.                 errorMsg = "Your Account has been Suspended";
  35.             } else if (errorCode >= 400 && errorCode <= 432) {
  36.                 bShowServerErrorMsg = true;
  37.             } else {
  38.                 if (System.localEnums.sc["SC_ERROR_" + errorCode]) {
  39.                     errorMsg = scMsg("SC_ERROR_" + errorCode);
  40.                     bShowServerErrorMsg = true;
  41.                 } else {
  42.                     bShowServerErrorMsg = false;
  43.                 };
  44.             };
  45.             if (bShowServerErrorMsg) {
  46.                 System.GUI.dialog.innerHTML     = errorMsg;
  47.             } else {
  48.                 System.GUI.dialog.innerHTML     = scMsg("SC_REGERROR_99");
  49.             };
  50.  
  51.             System.GUI.dialog.setSize(380, 157);
  52.             System.GUI.dialog.addButton("btn1", "OK");
  53.             System.GUI.dialog.show();
  54.         };
  55.         bCont = msg = line = url = null;
  56.     } else {
  57.         //window.external.GameInterface.Quit();
  58.         bCont = msg = line = url = bDontNav = null;
  59.     };
  60.     return true;
  61. };
  62. SystemClass.prototype.localEnums                = new locArray();
  63. SystemClass.prototype.writeLocaleString            = function(str, win)
  64. {
  65.     win.document.write(this.getLocaleStr(str));
  66.     win = str = null;
  67. };
  68. SystemClass.prototype.Session                    = new Session();
  69. SystemClass.prototype.GUI                    = new GUI_FrameWork();
  70. SystemClass.prototype.ScratchPad                = new JAX_Object();
  71. SystemClass.prototype.getHostURL                = function() { return EASOProps.get("host_url"); };
  72. SystemClass.prototype.getInstallFolder            = function(prependProtocall)
  73. {
  74.     if (!this._installFolderPre) {
  75.         var split                        = top.location.href.split(/\b\/fe\/\w/gi, 2);
  76.         this._installFolderPre            = (split) ? split[0] : "";
  77.         split = null;
  78.     };
  79.  
  80.     if (!prependProtocall) {
  81.           this._installFolder                = this._installFolderPre.substring(8) + "/";
  82.     } else {
  83.         this._installFolder                = this._installFolderPre + "/";
  84.     };
  85.     this._installFolder    = unescape(this._installFolder);
  86.     prependProtocol     = null;
  87.     return this._installFolder;
  88. };
  89. SystemClass.prototype.getEASODataDir        = function( )
  90. {
  91.     if (this._dataDir ) {return this._dataDir ;};
  92.     if ( "GetUserDirectory" in window.external.GameInterface )
  93.         this._dataDir = unescape(  window.external.GameInterface.GetUserDirectory()  ) + "\EASO";
  94.     else {
  95.         this._dataDir = "c:\temp"
  96.     }
  97.     return this._dataDir;
  98. }
  99.  
  100. var showId = false;
  101.  
  102. SystemClass.prototype.showLabel                    = function(bShow)
  103. {
  104.     showId = bShow;
  105. }
  106.  
  107. SystemClass.prototype.getLocaleString            = function(str, dict, uppercase)
  108. {
  109.     if (!showId)
  110.     {
  111.         dict        = (!dict) ? 0 : dict;
  112.         var msgID    = System.localEnums.lookup(dict, str);
  113.         if (msgID) {
  114.             try {
  115.                 if (uppercase)
  116.                     return window.external.GameInterface.GetLocalizedText(dict, msgID, false).toUpperCase();
  117.                 else
  118.                     return window.external.GameInterface.GetLocalizedText(dict, msgID, false);
  119.             } catch (e) { };
  120.         };
  121.     }
  122.  
  123.     var ret = str.replace(/^SC_/,"");
  124.     str = dict = uppercase = msgID  = null;
  125.  
  126.     if (uppercase)
  127.         return ret.toUpperCase();
  128.     else
  129.         return ret;
  130. };
  131. SystemClass.prototype.loadLibrary            = function(win)
  132. {
  133.     win.offscreenBuffering    = true;
  134.     win.confirm            = function() { return false; };
  135.     //win.alert                = function() { return false; };
  136.     win.prompt            = function() { return false; };
  137.     win.open                = function() { return false; };
  138.     win.close                = function() { return false; };
  139.     win.document.onselectstart = function()
  140.     {
  141.         if (this.parentWindow.event) {
  142.             this.parentWindow.event.cancelBubble    = true;
  143.             if ( (this.parentWindow.event.srcElement.tagName != "INPUT") && (this.parentWindow.event.srcElement.tagName != "TEXTAREA")) {
  144.                 return false;
  145.             };
  146.         };
  147.         return true;
  148.     };
  149.     win.document.onmousewheel    = function()
  150.     {
  151.         if (this.parentWindow.event) {
  152.             if (this.parentWindow.event.shiftKey) { return false; };
  153.         };
  154.     };
  155.     win.document.ondragstart    = function()  {    return false;  };
  156.     win.onerror            = function(message, line, url)  {    return System.handleError(message, line, url); };
  157.  
  158.     var idx = 0;
  159.     var end = this.libraryClasses.length;
  160.  
  161.     while (idx < end)
  162.     {
  163.         win[this.libraryClasses[idx]]    = top[this.libraryClasses[idx]];
  164.         idx++;
  165.     };
  166.     win.nhlMsg        = function(msg, isUpper) { return System.getLocaleString(msg, 0, isUpper);     };
  167.     win.writeNHLMsg    = function(msg, isUpper) { this.document.write(this.nhlMsg(msg, isUpper));     };
  168.     win.scMsg            = function(msg, isUpper) { return System.getLocaleString(msg, 1, isUpper);     };
  169.     win.writeSCMsg    = function(msg, isUpper) { this.document.write(this.scMsg(msg, isUpper));         };
  170.     win.ContextMenu    = ContextMenu;
  171.  
  172.     win.isNHL            = function ()
  173.     {
  174.         if ( ("GameInterface" in window.external) && ("AudioInterface" in window.external.GameInterface) )
  175.             return true;
  176.         else
  177.            return false;
  178.     };
  179.     win = idx = end = null;
  180. };
  181. SystemClass.prototype._init    = function()
  182. {
  183.     window.offscreenBuffering    = true;
  184.     window.confirm            = function() { return false; };
  185.     //win.alert                = function() { return false; };
  186.     window.prompt                = function() { return false; };
  187.     window.open                = function() { return false; };
  188.     window.close                = function() { return false; };
  189.     document.onselectstart = function()
  190.     {
  191.         if (event) {
  192.             event.cancelBubble    = true;
  193.             if ( (event.srcElement.tagName != "INPUT") && (event.srcElement.tagName != "TEXTAREA")) {return false; };
  194.         };
  195.         return true;
  196.     };
  197.     document.onmousewheel    = function() { if (event) { if (event.shiftKey) { return false; };     };};
  198.     document.ondragstart    = function()  {    return false;  };
  199.  
  200.     if (!window.external.GameInterface.IsDebug())
  201.     {
  202.         window.onerror            = function(message, line, url)  {    return System.handleError(message, line, url); };
  203.     }
  204.  
  205.     window.nhlMsg            = function(msg, isUpper) { return System.getLocaleString(msg, 0, isUpper);     };
  206.     window.writeNHLMsg    = function(msg, isUpper) { document.write(nhlMsg(msg, isUpper));     };
  207.     window.scMsg            = function(msg, isUpper) { return System.getLocaleString(msg, 1, isUpper);     };
  208.     window.writeSCMsg        = function(msg, isUpper) { document.write(scMsg(msg, isUpper));         };
  209.     window.isNHL            = function ()
  210.     {
  211.         if ( ("GameInterface" in window.external) && ("AudioInterface" in window.external.GameInterface) ) {
  212.             return true;
  213.          } else {
  214.            return false;
  215.          };
  216.     };
  217. };
  218. var System        = new SystemClass();