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

  1. function RRManager ( )
  2. {
  3.     this.requests         = new ActiveXObject("Scripting.Dictionary");
  4.     this.uniqueID        = 0;
  5.     this.cancelTimerID    = 0;
  6.     this.max             =10;
  7.     
  8. }
  9. var gblRRManager = new RRManager ();
  10. RRManager.prototype.resetData  = function () {    this.requests.RemoveAll(); };
  11. RRManager.prototype.register  = function ( request)
  12. {
  13.     if (gblRRManager.isAborting) { return; };
  14.     if (!request) { return; }
  15.     if (this.requests.Exists(request.getID())) {
  16.         var e = new Error();
  17.         e.description = "Already registered a request with this id";
  18.         throw e;
  19.      };
  20.      if (this.requests.Count < this.max)
  21.      {
  22.         this.uniqueID++;
  23.         request.setID(this.uniqueID);
  24.         request.isRegistered    = true;
  25.         this.requests.Add(this.uniqueID, request);
  26.     } else {
  27.         return -500;
  28.     };
  29.     return (this.uniqueID);
  30. };
  31. RRManager.prototype.unregister  = function ( request)
  32. {
  33.     if (!request)  { return; };
  34.     if (this.requests.Exists(request.getID())) {
  35.         this.requests.Item(request.getID()) = null;
  36.         this.requests.Remove(request.getID());
  37.         request.setID(-100);
  38.         request.isRegistered = false;
  39.     };
  40.      request = null;
  41. };
  42. RRManager.prototype.cancelTimerID = 0;
  43. RRManager.prototype.doCancel      = function ( )
  44. {
  45.    System.handleError = function() { return true; }
  46.     top.document.all.divDialogBox.setCapture(true);
  47.     window.external.PumpMessages();
  48.     if (!gblRRManager.isAborting) {
  49.         gblRRManager.isAborting                    = true;
  50.         if (this.requests.Count) {
  51.             for (var idx = (this.requests.Count -1); idx >= 0; idx--)
  52.             {
  53.                 try { 
  54.                     this.requests.Items().getItem(idx).abort();
  55.                 } catch (e) {
  56.                 };
  57.             };
  58.         };
  59.         gblRRManager.isGoingAway        = (gblRRManager.onCancel()) ? true : false;
  60.         if (gblRRManager.isGoingAway) {
  61.             //if (gblRRManager.cancelTimerID == 0) {
  62.             //    gblRRManager.cancelTimerID = setTimeout(function() { RRManager.goAway(); }, 85);
  63.             RRManager.goAway();
  64.             //};
  65.         } else {
  66.             gblRRManager.onCancel        = RRManager.prototype.onCancel;
  67.             gblRRManager.isAborting         = false;
  68.             System.GUI.loadingDialog.hide();
  69.             System.handleError = SystemClass.prototype.handleError;
  70.             top.document.releaseCapture(true);
  71.         };
  72.     };
  73. };
  74. RRManager.prototype.onCancel            = function() { return true };
  75. RRManager.prototype.resetOnCancel        = function() { this.onCancel = RRManager.prototype.onCancel; };
  76. RRManager.oldRRproto                = null;
  77. RRManager.goAway                    = function()
  78. {
  79.     if (gblRRManager.isGoingAway && gblRRManager.isAborting) {
  80.         var currentUserName            = System.Session.getUserName();
  81.         var currentPassword            = System.Session.getPassword();
  82.         System.GUI.clearLeftNav();
  83.         System.GUI.playTransition(true, false);
  84.         System.GUI.setTitle(System.GUI.Screens["1"].getTitle());
  85.         top.document.all.screen_bg.src         = "../../../fe/NHL/images/background/main_menu.jpg"
  86.         System.GUI.setLocation(System.GUI.Screens["1"].getScreenSrc());
  87.         System.GUI.currentScreenObj        = System.GUI.Screens["1"];
  88.         System.Session.logout();
  89.         gblRRManager.onCancel             = RRManager.prototype.onCancel;
  90.         gblRRManager.isAborting              = false;
  91.         gblRRManager.cancelTimerID         = 0;
  92.         System.handleError = SystemClass.prototype.handleError;
  93.         top.document.releaseCapture();
  94.     };
  95. };