this._getRandStr = function(){ return Math.random().toString().substring(2, 10); }  
dojox.cometd = new function(){		/* cometd states: 	* DISCONNECTED:  _initialized==false && _connected==false 	* CONNECTING:    _initialized==true  && _connected==false (handshake sent) 	* CONNECTED:     _initialized==true  && _connected==true  (first successful connect) 	* DISCONNECTING: _initialized==false && _connected==true  (disconnect sent) 	*/	this._initialized = false;	this._connected = false;	this._polling = false;	this.connectionTypes = new dojo.AdapterRegistry(true);	this.version = "1.0";	this.minimumVersion = "0.9";	this.clientId = null;	this.messageId = 0;	this.batch=0;	this._isXD = false;	this.handshakeReturn = null;	this.currentTransport = null;	this.url = null;	this.lastMessage = null;	this.topics = {};	this.globalTopicChannels = {};	this._messageQ = [];	this.handleAs="json-comment-optional";	this.advice;	this.pendingSubscriptions = {}	this.pendingUnsubscriptions = {}	this._subscriptions = [];	this.tunnelInit = function(childLocation, childDomain){		// placeholder	}	this.tunnelCollapse = function(){		console.debug("tunnel collapsed!");		// placeholder	}	this.init = function(root, props, bargs){		// FIXME: if the root isn't from the same host, we should automatically		// try to select an XD-capable transport		props = props||{};		// go ask the short bus server what we can support		props.version = this.version;		props.minimumVersion = this.minimumVersion;		props.channel = "/meta/handshake";		props.id = ""+this.messageId++;		props.ext = { "json-comment-filtered": true };		// FIXME: what about ScriptSrcIO for x-domain comet?		this.url = root||djConfig["cometdRoot"];		if(!this.url){			console.debug("no cometd root specified in djConfig and no root passed");			return;		}		// FIXME: we need to select a way to handle JSONP-style stuff		// generically here. We already know if the server is gonna be on		// another domain (or can know it), so we should select appropriate		// negotiation methods here as well as in final transport type		// selection.		var bindArgs = {			url: this.url,			handleAs: this.handleAs,			content: { "message": dojo.toJson([props]) },			callbackParamName: "jsonp", // usually ignored			load: dojo.hitch(this, "finishInit"),			error: function(e){ console.debug("handshake error!:", e); }		};		// borrowed from dojo.uri.Uri in lieu of fixed host and port properties		var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";		var r = (""+window.location).match(new RegExp(regexp));		if(r[4]){			var tmp = r[4].split(":");			var thisHost = tmp[0];			var thisPort = tmp[1]||"80"; // FIXME: match 443			r = this.url.match(new RegExp(regexp));			if(r[4]){				tmp = r[4].split(":");				var urlHost = tmp[0];				var urlPort = tmp[1]||"80";				this._isXD = ((urlHost != thisHost)||(urlPort != thisPort));			}		}		if(bargs){			dojo.mixin(bindArgs, bargs);		}				this._initialized=true;		this.startBatch();		if(this._isXD){			return dojo.io.script.get(bindArgs);		}		return dojo.xhrPost(bindArgs);	}	this.finishInit = function(data){		data = data[0];		this.handshakeReturn = data;		// pick a transport		if (data["advice"]){			this.advice = data.advice;		}		// TODO remove authSuccessful when all clients updated to the spec		if((!data.successful)&&(!data.authSuccessful)){			console.debug("cometd init failed");			// TODO follow advice			return;		}		if(data.version < this.minimumVersion){			console.debug("cometd protocol version mismatch. We wanted", this.minimumVersion, "but got", data.version);			return;		}		this.currentTransport = this.connectionTypes.match(			data.supportedConnectionTypes,			data.version,			this._isXD		);		this.currentTransport._cometd = this;		this.currentTransport.version = data.version;		this.clientId = data.clientId;		this.tunnelInit = dojo.hitch(this.currentTransport, "tunnelInit");		this.tunnelCollapse = dojo.hitch(this.currentTransport, "tunnelCollapse");		this.currentTransport.startup(data);	}	this._getRandStr = function(){		return Math.random().toString().substring(2, 10);	}	// public API functions called by cometd or by the transport classes	this.deliver = function(messages){		// console.debug(messages);		dojo.forEach(messages, this._deliver, this);		return messages;	}	this._deliver = function(message){		// dipatch events along the specified path		if(!message["channel"]){			if(message["success"] !== true){				console.debug("cometd error: no channel for message!", message);				return;			}		}		this.lastMessage = message;		if(message.advice){			this.advice = message.advice; // TODO maybe merge?		}		// check to see if we got a /meta channel message that we care about		if(	(message["channel"]) &&			(message.channel.length > 5)&&			(message.channel.substr(0, 5) == "/meta")){			// check for various meta topic actions that we need to respond to			switch(message.channel){				case "/meta/connect":					if(message.successful && !this._connected){						this._connected = this._initialized;						this.endBatch();					} else if (!this._initialized){						this._connected = false; // finish disconnect					}                                     					break;				case "/meta/subscribe":					var pendingDef = this.pendingSubscriptions[message.subscription];					if(!message.successful){						if(pendingDef){							pendingDef.errback(new Error(message.error));							delete this.pendingSubscriptions[message.subscription];						}						return;					}					dojox.cometd.subscribed(message.subscription, message);					if(pendingDef){						pendingDef.callback(true);						delete this.pendingSubscriptions[message.subscription];					}					break;				case "/meta/unsubscribe":					var pendingDef = this.pendingUnsubscriptions[message.subscription];					if(!message.successful){						if(pendingDef){							pendingDef.errback(new Error(message.error));							delete this.pendingUnsubscriptions[message.subscription];						}						return;					}					this.unsubscribed(message.subscription, message);					if(pendingDef){						pendingDef.callback(true);						delete this.pendingUnsubscriptions[message.subscription];					}					break;			}		}				// send the message down for processing by the transport		this.currentTransport.deliver(message);		if(message.data){			// dispatch the message to any locally subscribed listeners			var tname = (this.globalTopicChannels[message.channel]) ? message.channel : "/cometd"+message.channel;			dojo.publish(tname, [ message ]);		}	}	this.disconnect = function(){		dojo.forEach(this._subscriptions, dojo.unsubscribe);		this._subscriptions = [];		this._messageQ = [];		if(this._initialized && this.currentTransport) {			this.currentTransport.disconnect();		}		this._initialized=false;		if (!this._polling)			this._connected=false;	}	// public API functions called by end users	this.publish = function(/*string*/channel, /*object*/data, /*object*/properties){		// summary:		//		publishes the passed message to the cometd server for delivery		//		on the specified topic		// channel:		//		the destination channel for the message		// data:		//		a JSON object containing the message "payload"		// properties:		//		Optional. Other meta-data to be mixed into the top-level of the		//		message		var message = {			data: data,			channel: channel		};		if(properties){			dojo.mixin(message, properties);		}		this._sendMessage(message);	}	this._sendMessage = function(/* object */ message){		if(this.currentTransport && this._connected && this.batch==0){			return this.currentTransport.sendMessages([message]);		}		else{			this._messageQ.push(message);		}	}	this.subscribe = function(	/*string */					channel,								/*object, optional*/	     objOrFunc,								/*string, optional*/	     funcName){ // return: boolean		// summary:		//		inform the server of this client's interest in channel		// channel:		//		name of the cometd channel to subscribe to		// objOrFunc:		//		an object scope for funcName or the name or reference to a		//		function to be called when messages are delivered to the		//		channel		// funcName:		//		the second half of the objOrFunc/funcName pair for identifying		//		a callback function to notifiy upon channel message delivery		if(this.pendingSubscriptions[channel]){			// We already asked to subscribe to this channel, and			// haven't heard back yet. Fail the previous attempt.			var oldDef = this.pendingSubscriptions[channel];			oldDef.cancel();			delete this.pendingSubscriptions[channel];		}		var pendingDef = new dojo.Deferred();		this.pendingSubscriptions[channel] = pendingDef;		if(objOrFunc){			var tname = "/cometd"+channel;			if(this.topics[tname]){				dojo.unsubscribe(this.topics[tname]);			}			var topic = dojo.subscribe(tname, objOrFunc, funcName);			this.topics[tname] = topic;		}		this._sendMessage({			channel: "/meta/subscribe",			subscription: channel		});		return pendingDef;	}	this.subscribed = function(	/*string*/  channel,								/*obj*/     message){ 	}	this.unsubscribe = function(/*string*/			channel){ // return: boolean		// summary:		//		inform the server of this client's disinterest in channel		// channel:		//		name of the cometd channel to unsubscribe from		if(this.pendingUnsubscriptions[channel]){			// We already asked to unsubscribe from this channel, and			// haven't heard back yet. Fail the previous attempt.			var oldDef = this.pendingUnsubscriptions[channel];			oldDef.cancel();			delete this.pendingUnsubscriptions[channel];		}		var pendingDef = new dojo.Deferred();		this.pendingUnsubscriptions[channel] = pendingDef;		var tname = "/cometd"+channel;		if(this.topics[tname]){			dojo.unsubscribe(this.topics[tname]);		}		this._sendMessage({			channel: "/meta/unsubscribe",			subscription: channel		});		return pendingDef;	}	this.unsubscribed = function(	/*string*/  channel,					/*obj*/     message){	}	this.startBatch = function(){		this.batch++;	}	this.endBatch = function(){		if(--this.batch <= 0 && this.currentTransport){			this.batch=0;			var messages=this._messageQ;			this._messageQ=[];			if(messages.length>0){				this.currentTransport.sendMessages(messages);			}		}	}		this._onUnload = function(){		// make this the last of the onUnload method		dojo.addOnUnload(dojox.cometd,"disconnect");	}}
5168	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5168/d0f9ee8243dce3dfda13175ec0838eb68311844f/cometd.js/clean/_cometd/cometd.js