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

📄 _common.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
		this._cacheDojoResources();				// FIXME: need to pull in the firebug lite files here!		// workaround or else we will get an error on page load		// from Dojo that it can't find 'console.debug' for optimized builds		// dojox.off.files.cache(dojo.config.baseRelativePath + "src/debug.js");				// make sure that resources needed by all of our underlying		// Dojo Storage storage providers will be available		// offline		dojox.off.files.cache(dojox.storage.manager.getResourceList());				// slurp the page if the end-developer wants that		dojox.off.files._slurp();				// see if we have an offline cache; when done, move		// on to the rest of our startup tasks		this._checkOfflineCacheAvailable(dojo.hitch(this, "_onOfflineCacheChecked"));	},		_onOfflineCacheChecked: function(){		// this method is part of our _onLoad series of startup tasks				// if we have an offline cache, see if we have been added to the 		// list of available offline web apps yet		if(this.hasOfflineCache && this.enabled){			// load framework data; when we are finished, continue			// initializing ourselves			this._load(dojo.hitch(this, "_finishStartingUp"));		}else if(this.hasOfflineCache && !this.enabled){			// we have an offline cache, but it is disabled for some reason			// perhaps due to the user denying a core operation			this._finishStartingUp();		}else{			this._keepCheckingUntilInstalled();		}	},		_keepCheckingUntilInstalled: function(){		// this method is part of our _onLoad series of startup tasks				// kick off a background interval that keeps		// checking to see if an offline cache has been		// installed since this page loaded					// FIXME: Gears: See if we are installed somehow after the		// page has been loaded				// now continue starting up		this._finishStartingUp();	},		_finishStartingUp: function(){		//console.debug("dojox.off._finishStartingUp");				// this method is part of our _onLoad series of startup tasks				if(!this.hasOfflineCache){			this.onLoad();		}else if(this.enabled){			// kick off a thread to check network status on			// a regular basis			this._startNetworkThread();			// try to go online			this.goOnline(dojo.hitch(this, function(){				//console.debug("Finished trying to go online");				// indicate we are ready to be used				dojox.off.onLoad();			}));		}else{ // we are disabled or a core operation failed			if(this.coreOpFailed){				this.onFrameworkEvent("coreOperationFailed");			}else{				this.onLoad();			}		}	},		_onPageLoad: function(){		//console.debug("dojox.off._onPageLoad");		this._pageLoaded = true;				if(this._storageLoaded && this._initializeCalled){			this._onLoad();		}	},		_onStorageLoad: function(){		//console.debug("dojox.off._onStorageLoad");		this._storageLoaded = true;				// were we able to initialize storage? if		// not, then this is a core operation, and		// let's indicate we will need to fail fast		if(!dojox.storage.manager.isAvailable()			&& dojox.storage.manager.isInitialized()){			this.coreOpFailed = true;			this.enabled = false;		}				if(this._pageLoaded && this._initializeCalled){			this._onLoad();				}	},		_isSiteAvailable: function(callback){		// summary:		//		Determines if our web application's website is available.		// description:		//		This method will asychronously determine if our web		//		application's web site is available, which is a good proxy for		//		network availability. The URL dojox.off.availabilityURL is		//		used, which defaults to this site's domain name (ex:		//		foobar.com). We check for dojox.off.AVAILABILITY_TIMEOUT (in		//		seconds) and abort after that		// callback: Function		//		An optional callback function that will receive one argument:		//		whether the site is available or not and is boolean. If this		//		function is not present we call dojox.off.onNetwork instead if we		//		are able to go online.		dojo.xhrGet({			url:		this._getAvailabilityURL(),			handleAs:	"text",			timeout:	this.NET_CHECK * 1000, 			error:		dojo.hitch(this, function(err){				//console.debug("dojox.off._isSiteAvailable.error: " + err);				this.goingOnline = false;				this.isOnline = false;				if(callback){ callback(false); }			}),			load:		dojo.hitch(this, function(data){				//console.debug("dojox.off._isSiteAvailable.load, data="+data);				this.goingOnline = false;				this.isOnline = true;								if(callback){ callback(true);				}else{ this.onNetwork("online"); }			})		});	},		_startNetworkThread: function(){		//console.debug("startNetworkThread");				// kick off a thread that does periodic		// checks on the status of the network		if(!this.doNetChecking){			return;		}				window.setInterval(dojo.hitch(this, function(){				var d = dojo.xhrGet({				url:	 	this._getAvailabilityURL(),				handleAs:	"text",				timeout: 	this.NET_CHECK * 1000,				error:		dojo.hitch(this, 								function(err){									if(this.isOnline){										this.isOnline = false;																				// FIXME: xhrGet() is not										// correctly calling abort										// on the XHR object when										// it times out; fix inside										// there instead of externally										// here										try{											if(typeof d.ioArgs.xhr.abort == "function"){												d.ioArgs.xhr.abort();											}										}catch(e){}															// if things fell in the middle of syncing, 										// stop syncing										dojox.off.sync.isSyncing = false;															this.onNetwork("offline");									}								}							),				load:		dojo.hitch(this, 								function(data){									if(!this.isOnline){										this.isOnline = true;										this.onNetwork("online");									}								}							)			});		}), this.NET_CHECK * 1000);	},		_getAvailabilityURL: function(){		var url = this.availabilityURL.toString();				// bust the browser's cache to make sure we are really talking to		// the server		if(url.indexOf("?") == -1){			url += "?";		}else{			url += "&";		}		url += "browserbust=" + new Date().getTime();				return url;	},		_onOfflineCacheInstalled: function(){		this.onFrameworkEvent("offlineCacheInstalled");	},		_cacheDojoResources: function(){		// if we are a non-optimized build, then the core Dojo bootstrap		// system was loaded as separate JavaScript files;		// add these to our offline cache list. these are		// loaded before the dojo.require() system exists				// FIXME: create a better mechanism in the Dojo core to		// expose whether you are dealing with an optimized build;		// right now we just scan the SCRIPT tags attached to this		// page and see if there is one for _base/_loader/bootstrap.js		var isOptimizedBuild = true;		dojo.forEach(dojo.query("script"), function(i){			var src = i.getAttribute("src");			if(!src){ return; }						if(src.indexOf("_base/_loader/bootstrap.js") != -1){				isOptimizedBuild = false;			}		});				if(!isOptimizedBuild){			dojox.off.files.cache(dojo.moduleUrl("dojo", "_base.js").uri);			dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/loader.js").uri);			dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/bootstrap.js").uri);						// FIXME: pull in the host environment file in a more generic way			// for other host environments			dojox.off.files.cache(dojo.moduleUrl("dojo", "_base/_loader/hostenv_browser.js").uri);		}				// add anything that was brought in with a 		// dojo.require() that resulted in a JavaScript		// URL being fetched				// FIXME: modify dojo/_base/_loader/loader.js to		// expose a public API to get this information			for(var i = 0; i < dojo._loadedUrls.length; i++){			dojox.off.files.cache(dojo._loadedUrls[i]);		}				// FIXME: add the standard Dojo CSS file	},		_save: function(){		// summary:		//		Causes the Dojo Offline framework to save its configuration		//		data into local storage.		},		_load: function(callback){		// summary:		//		Causes the Dojo Offline framework to load its configuration		//		data from local storage		dojox.off.sync._load(callback);	}});// wait until the storage system is finished loadingdojox.storage.manager.addOnLoad(dojo.hitch(dojox.off, "_onStorageLoad"));// wait until the page is finished loadingdojo.addOnLoad(dojox.off, "_onPageLoad");}

⌨️ 快捷键说明

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