[ Index ]
 

Code source de Seagull 0.6.1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/js/html_ajax/ -> clientPool.js (source)

   1  HTML_AJAX_Client_Pool = function(maxClients, startingClients)
   2  {
   3      this.maxClients = maxClients;
   4      this._clients = [];
   5      this._len = 0;
   6      while (--startingClients > 0) {
   7          this.addClient();
   8      }
   9  }
  10  
  11  HTML_AJAX_Client_Pool.prototype = {
  12      isEmpty: function()
  13      {
  14          return this._len == 0;
  15      },
  16      addClient: function()
  17      {
  18          if (this.maxClients != 0 && this._len > this.maxClients) {
  19              return false;
  20          }
  21          var key = this._len++;
  22          this._clients[key] = new HTML_AJAX_HttpClient();
  23          return this._clients[key];
  24      },
  25      getClient: function ()
  26      {
  27          for (var i = 0; i < this._len; i++) {
  28              if (!this._clients[i].callInProgress() && this._clients[i].callbackComplete) {
  29                  return this._clients[i];
  30              }
  31          }
  32          var client = this.addClient();
  33          if (client) {
  34              return client;
  35          }
  36          return false;
  37      },
  38      removeClient: function (client)
  39      {
  40          for (var i = 0; i < this._len; i++) {
  41              if (!this._clients[i] == client) {
  42                  this._clients.splice(i, 1);
  43                  return true;
  44              }
  45          }
  46          return false;
  47      },
  48      clear: function ()
  49      {
  50          this._clients = [];
  51          this._len = 0;
  52      }
  53  };
  54  
  55  // create a default client pool with unlimited clients
  56  HTML_AJAX.clientPools['default'] = new HTML_AJAX_Client_Pool(0);


Généré le : Fri Mar 30 01:27:52 2007 par Balluche grâce à PHPXref 0.7