⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.js

📁 js基本操作
💻 JS
📖 第 1 页 / 共 2 页
字号:
	this.push(name);	// FIXME: do we need to handle things that aren't direct children of the	// dojo.io module? (say, dojo.io.foo.fooTransport?)	this[name] = dojo.io[name];}// binding interface, the various implementations register their capabilities// and the bind() method dispatchesdojo.io.bind = function(/*dojo.io.Request or Object*/request){	// summary:	//		Binding interface for IO. Loading different IO transports, like	//		dojo.io.BrowserIO or dojo.io.IframeIO, will register with bind	//		to handle particular types of bind calls.	//		request: Object	//				Object containing bind arguments. This object is converted to	//				a dojo.io.Request object, and that request object is the return	//				value for this method.	if(!(request instanceof dojo.io.Request)){		try{			request = new dojo.io.Request(request);		}catch(e){ dojo.debug(e); }	}	// if the request asks for a particular implementation, use it	var tsName = "";	if(request["transport"]){		tsName = request["transport"];		if(!this[tsName]){			dojo.io.sendBindError(request, "No dojo.io.bind() transport with name '"				+ request["transport"] + "'.");			return request; //dojo.io.Request		}		if(!this[tsName].canHandle(request)){			dojo.io.sendBindError(request, "dojo.io.bind() transport with name '"				+ request["transport"] + "' cannot handle this type of request.");			return request;	//dojo.io.Request		}	}else{		// otherwise we do our best to auto-detect what available transports		// will handle 		for(var x=0; x<dojo.io.transports.length; x++){			var tmp = dojo.io.transports[x];			if((this[tmp])&&(this[tmp].canHandle(request))){				tsName = tmp;				break;			}		}		if(tsName == ""){			dojo.io.sendBindError(request, "None of the loaded transports for dojo.io.bind()"				+ " can handle the request.");			return request; //dojo.io.Request		}	}	this[tsName].bind(request);	request.bindSuccess = true;	return request; //dojo.io.Request}dojo.io.sendBindError = function(/* Object */request, /* String */message){	// summary:	//		Used internally by dojo.io.bind() to return/raise a bind error.	//Need to be careful since not all hostenvs support setTimeout.	if((typeof request.error == "function" || typeof request.handle == "function")		&& (typeof setTimeout == "function" || typeof setTimeout == "object")){		var errorObject = new dojo.io.Error(message);		setTimeout(function(){			request[(typeof request.error == "function") ? "error" : "handle"]("error", errorObject, null, request);		}, 50);	}else{		dojo.raise(message);	}}dojo.io.queueBind = function(/*dojo.io.Request or Object*/request){	// summary:	//		queueBind will use dojo.io.bind() but guarantee that only one bind	//		call is handled at a time.	// description:	//		If queueBind is called while a bind call	//		is in process, it will queue up the other calls to bind and call them	//		in order as bind calls complete.	//		request: Object	//			Same sort of request object as used for dojo.io.bind().	if(!(request instanceof dojo.io.Request)){		try{			request = new dojo.io.Request(request);		}catch(e){ dojo.debug(e); }	}	// make sure we get called if/when we get a response	var oldLoad = request.load;	request.load = function(){		dojo.io._queueBindInFlight = false;		var ret = oldLoad.apply(this, arguments);		dojo.io._dispatchNextQueueBind();		return ret;	}	var oldErr = request.error;	request.error = function(){		dojo.io._queueBindInFlight = false;		var ret = oldErr.apply(this, arguments);		dojo.io._dispatchNextQueueBind();		return ret;	}	dojo.io._bindQueue.push(request);	dojo.io._dispatchNextQueueBind();	return request; //dojo.io.Request}dojo.io._dispatchNextQueueBind = function(){	// summary:	//	Private method used by dojo.io.queueBind().	if(!dojo.io._queueBindInFlight){		dojo.io._queueBindInFlight = true;		if(dojo.io._bindQueue.length > 0){			dojo.io.bind(dojo.io._bindQueue.shift());		}else{			dojo.io._queueBindInFlight = false;		}	}}dojo.io._bindQueue = [];dojo.io._queueBindInFlight = false;dojo.io.argsFromMap = function(/*Object*/map, /*String?*/encoding, /*String?*/last){	// summary:	//		Converts name/values pairs in the map object to an URL-encoded string	//		with format of name1=value1&name2=value2...	//		map: Object	//			Object that has the contains the names and values.	//		encoding: String?	//			String to specify how to encode the name and value. If the encoding string	//			contains "utf" (case-insensitive), then encodeURIComponent is used. Otherwise	//			dojo.string.encodeAscii is used.	//		last: String?	//			The last parameter in the list. Helps with final string formatting?	var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;	var mapped = [];	var control = new Object();	for(var name in map){		var domap = function(elt){			var val = enc(name)+"="+enc(elt);			mapped[(last == name) ? "push" : "unshift"](val);		}		if(!control[name]){			var value = map[name];			// FIXME: should be isArrayLike?			if (dojo.lang.isArray(value)){				dojo.lang.forEach(value, domap);			}else{				domap(value);			}		}	}	return mapped.join("&"); //String}dojo.io.setIFrameSrc = function(/*DOMNode*/ iframe, /*String*/ src, /*Boolean*/ replace){	//summary:	//		Sets the URL that is loaded in an IFrame. The replace parameter indicates whether	//		location.replace() should be used when changing the location of the iframe.	try{		var r = dojo.render.html;		// dojo.debug(iframe);		if(!replace){			if(r.safari){				iframe.location = src;			}else{				frames[iframe.name].location = src;			}		}else{			// Fun with DOM 0 incompatibilities!			var idoc;			if(r.ie){				idoc = iframe.contentWindow.document;			}else if(r.safari){				idoc = iframe.document;			}else{ //  if(r.moz){				idoc = iframe.contentWindow;			}			//For Safari (at least 2.0.3) and Opera, if the iframe			//has just been created but it doesn't have content			//yet, then iframe.document may be null. In that case,			//use iframe.location and return.			if(!idoc){				iframe.location = src;				return;			}else{				idoc.location.replace(src);			}		}	}catch(e){ 		dojo.debug(e); 		dojo.debug("setIFrameSrc: "+e); 	}}/*dojo.io.sampleTranport = new function(){	this.canHandle = function(kwArgs){		// canHandle just tells dojo.io.bind() if this is a good transport to		// use for the particular type of request.		if(				(				(kwArgs["mimetype"] == "text/plain") ||				(kwArgs["mimetype"] == "text/html") ||				(kwArgs["mimetype"] == "text/javascript")			)&&(				(kwArgs["method"] == "get") ||				( (kwArgs["method"] == "post") && (!kwArgs["formNode"]) )			)		){			return true;		}		return false;	}	this.bind = function(kwArgs){		var hdlrObj = {};		// set up a handler object		for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){			var fn = dojo.io.hdlrFuncNames[x];			if(typeof kwArgs.handler == "object"){				if(typeof kwArgs.handler[fn] == "function"){					hdlrObj[fn] = kwArgs.handler[fn]||kwArgs.handler["handle"];				}			}else if(typeof kwArgs[fn] == "function"){				hdlrObj[fn] = kwArgs[fn];			}else{				hdlrObj[fn] = kwArgs["handle"]||function(){};			}		}		// build a handler function that calls back to the handler obj		var hdlrFunc = function(evt){			if(evt.type == "onload"){				hdlrObj.load("load", evt.data, evt);			}else if(evt.type == "onerr"){				var errObj = new dojo.io.Error("sampleTransport Error: "+evt.msg);				hdlrObj.error("error", errObj);			}		}		// the sample transport would attach the hdlrFunc() when sending the		// request down the pipe at this point		var tgtURL = kwArgs.url+"?"+dojo.io.argsFromMap(kwArgs.content);		// sampleTransport.sendRequest(tgtURL, hdlrFunc);	}	dojo.io.transports.addTransport("sampleTranport");}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -