- Timestamp:
- 10/01/10 17:17:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js
r3264 r3317 24 24 {var func=this;return function(){var newargs=[arg];for(var i=0;i<arguments.length;i++){newargs.push(arguments[i]);} 25 25 return func.apply(this,newargs);};};} 26 if(!Array.prototype.indexOf)27 {Array.prototype.indexOf=function(elt)28 {var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}29 for(;from<len;from++){if(from in this&&this[from]===elt){return from;}}30 return-1;};}31 26 (function(callback){var Strophe;function $build(name,attrs){return new Strophe.Builder(name,attrs);} 32 27 function $msg(attrs){return new Strophe.Builder("message",attrs);} … … 183 178 {Strophe.info("_doDisconnect was called");this.authenticated=false;this.disconnecting=false;this.sid=null;this.streamId=null;this.rid=Math.floor(Math.random()*4294967295);if(this.connected){this._changeConnectStatus(Strophe.Status.DISCONNECTED,null);this.connected=false;} 184 179 this.handlers=[];this.timedHandlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];},_dataRecv:function(req) 185 {try{var elem=req.getResponse();}catch(e){if(e!="parsererror"){throw e;} 180 {var arrayIndexOf=function(pArray,pInd) 181 {var len=pArray.length;for(var i=0;i<len;i++) 182 {if(pArray[i]==pInd) 183 return i;} 184 return-1;};try{var elem=req.getResponse();}catch(e){if(e!="parsererror"){throw e;} 186 185 this.disconnect("strophe-parsererror");} 187 186 if(elem===null){return;} 188 this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0){hand=this.removeHandlers.pop();i=this.handlers.indexOf(hand);if(i>=0){this.handlers.splice(i,1);}} 187 this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0) 188 {hand=this.removeHandlers.pop();i=arrayIndexOf(this.handlers,hand);if(i>=0) 189 {this.handlers.splice(i,1);}} 189 190 while(this.addHandlers.length>0){this.handlers.push(this.addHandlers.pop());} 190 191 if(this.disconnecting&&this._requests.length===0){this.deleteTimedHandler(this._disconnectTimeout);this._disconnectTimeout=null;this._doDisconnect();return;} … … 236 237 {Strophe.info("_onDisconnectTimeout was called");var req;while(this._requests.length>0){req=this._requests.pop();req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};} 237 238 this._doDisconnect();return false;},_onIdle:function() 238 {var i,thand,since,newList;while(this.removeTimeds.length>0){thand=this.removeTimeds.pop();i=this.timedHandlers.indexOf(thand);if(i>=0){this.timedHandlers.splice(i,1);}} 239 {var arrayIndexOf=function(pArray,pInd) 240 {var len=pArray.length;for(var i=0;i<len;i++) 241 {if(pArray[i]==pInd) 242 return i;} 243 return-1;};var i,thand,since,newList;while(this.removeTimeds.length>0) 244 {thand=this.removeTimeds.pop();i=arrayIndexOf(this.timedHandlers,thand);if(i>=0) 245 {this.timedHandlers.splice(i,1);}} 239 246 while(this.addTimeds.length>0){this.timedHandlers.push(this.addTimeds.pop());} 240 247 var now=new Date().getTime();newList=[];for(i=0;i<this.timedHandlers.length;i++){thand=this.timedHandlers[i];if(this.authenticated||!thand.user){since=thand.lastCalled+thand.period;if(since-now<=0){if(thand.run()){newList.push(thand);}}else{newList.push(thand);}}}
Note: See TracChangeset
for help on using the changeset viewer.