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

📄 atomreadstore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var passed = false;				try{					var value = store.getValues("NotAnItem", foo);				}catch(e){					passed = true;				}				t.assertTrue(passed);			}		},		{			name: "ReadAPI:  isItem",			timeout:	5000, //1 second			runTest: function(t) {				//	summary:				//		Simple test of the isItem function of the store				//	description:				//		Simple test of the isItem function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function completedAll(items){					t.is(5, items.length);					for(var i=0; i < items.length; i++){						t.assertTrue(atomStore.isItem(items[i]));					}					d.callback(true);				}				//Get everything...				atomStore.fetch({						query: {						},						count: 5,						onComplete: completedAll,						onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)					});				return d; //Object			}		},		{			name: "ReadAPI:  hasAttribute",			timeout:	5000, //1 second			runTest: function(t) {				//	summary:				//		Simple test of the hasAttribute function of the store				//	description:				//		Simple test of the hasAttribute function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					t.is(1, items.length);					t.assertTrue(items[0] !== null);					var count = 0;					console.log("hasAttribute");					t.assertTrue(atomStore.hasAttribute(items[0], "author"));					t.assertTrue(atomStore.hasAttribute(items[0], "published"));					t.assertTrue(atomStore.hasAttribute(items[0], "updated"));					t.assertTrue(atomStore.hasAttribute(items[0], "category"));					t.assertTrue(atomStore.hasAttribute(items[0], "id"));					t.assertTrue(!atomStore.hasAttribute(items[0], "foo"));					t.assertTrue(!atomStore.hasAttribute(items[0], "bar"));															t.assertTrue(atomStore.hasAttribute(items[0], "summary"));					t.assertTrue(atomStore.hasAttribute(items[0], "content"));					t.assertTrue(atomStore.hasAttribute(items[0], "title"));															var summary = atomStore.getValue(items[0], "summary");					var content = atomStore.getValue(items[0], "content");					var title = atomStore.getValue(items[0], "title");															t.assertTrue(summary && summary.text && summary.type == "html");					t.assertTrue(content && content.text && content.type == "html");					t.assertTrue(title && title.text && title.type == "html");					//Test that null attributes throw an exception					try{						atomStore.hasAttribute(items[0], null);						t.assertTrue(false);					}catch (e){											}					d.callback(true);				}				//Get one item...				atomStore.fetch({					query: {					},					count: 1,						onComplete: onComplete,						onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)				});				return d; //Object			}		},		{			name: "ReadAPI:  containsValue",			timeout:	5000, //1 second			runTest: function(t) {				//	summary:				//		Simple test of the containsValue function of the store				//	description:				//		Simple test of the containsValue function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					t.is(1, items.length);					t.assertTrue(atomStore.containsValue(items[0], "id","http://shaneosullivan.wordpress.com/2008/01/22/using-aol-hosted-dojo-with-your-custom-code/"));					d.callback(true);				}				//Get one item...				atomStore.fetch({					query: {					},					count: 1,					onComplete: onComplete,					onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)				});				return d; //Object			}		},		{			name: "ReadAPI:  getAttributes",			timeout:	5000, //1 second			runTest: function(t) {				//	summary:				//		Simple test of the getAttributes function of the store				//	description:				//		Simple test of the getAttributes function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					t.is(1, items.length);					t.assertTrue(atomStore.isItem(items[0]));					var attributes = atomStore.getAttributes(items[0]);					console.log("getAttributes 4: "+attributes.length);					t.is(10, attributes.length);					d.callback(true);				}				//Get everything...				atomStore.fetch({						query: {						},						count: 1,						onComplete: onComplete,						onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)					});				return d; //Object			}		},		{			name: "ReadAPI:  fetch_Category",			timeout:	5000, //1 second.			runTest: function(t) {				//	summary:				//		Retrieve items from the store by category				//	description:				//		Simple test of the getAttributes function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					t.is(2, items.length);					t.assertTrue(atomStore.isItem(items[0]));					t.assertTrue(atomStore.isItem(items[1]));					var categories = atomStore.getValues(items[0], "category");					t.assertTrue(dojo.some(categories, function(category){						return category.term == "aol";					}));					categories = atomStore.getValues(items[1], "category");					t.assertTrue(dojo.some(categories, function(category){						return category.term == "aol";					}));					d.callback(true);				}				//Get everything...				atomStore.fetch({					query: {						category: "aol"					},					onComplete: onComplete,					onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)				});				return d; //Object			}		},		{			name: "ReadAPI:  fetch_byID",			timeout:	5000, //1 second.			runTest: function(t) {				//	summary:				//		Retrieve items from the store by category				//	description:				//		Simple test of the getAttributes function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					console.log("getById: items.length="+items.length)					t.is(1, items.length);					t.assertTrue(atomStore.isItem(items[0]));					var title = atomStore.getValue(items[0], "title");					console.log("getById: title.text="+title.text)					t.assertTrue(title.text == "Dojo Grid has landed");					d.callback(true);				}				//Get everything...				atomStore.fetch({					query: {						id: "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/"					},					onComplete: onComplete,					onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)				});				return d; //Object			}		},		{			name: "ReadAPI:  fetch_alternate",			timeout:	5000, //1 second.			runTest: function(t) {				//	summary:				//		Retrieve items from the store by category				//	description:				//		Simple test of the getAttributes function of the store				var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();				var d = new doh.Deferred();				function onComplete(items){					t.is(1, items.length);					t.assertTrue(atomStore.isItem(items[0]));					var alternate = atomStore.getValue(items[0], "alternate");					t.assertEqual(alternate.href, "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/");					d.callback(true);				}				//Get everything...				atomStore.fetch({					query: {						id: "http://shaneosullivan.wordpress.com/2007/10/05/dojo-grid-has-landed/"					},					onComplete: onComplete,					onError: dojo.partial(dojox.data.tests.stores.AtomReadStore.error, t, d)				});				return d; //Object			}		},		function testReadAPI_getFeatures(t){			//	summary:			//		Simple test of the getFeatures function of the store			//	description:			//		Simple test of the getFeatures function of the store			var atomStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();			var features = atomStore.getFeatures();			var count = 0;			for(i in features){				t.assertTrue((i === "dojo.data.api.Read"));				count++;			}			t.assertTrue(count === 1);		},		function testReadAPI_functionConformance(t){			//	summary:			//		Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.			//	description:			//		Simple test read API conformance.  Checks to see all declared functions are actual functions on the instances.			var testStore = dojox.data.tests.stores.AtomReadStore.getBlog1Store();			var readApi = new dojo.data.api.Read();			var passed = true;			for(i in readApi){				if(i.toString().charAt(0) !== '_')				{					var member = readApi[i];					//Check that all the 'Read' defined functions exist on the test store.					if(typeof member === "function"){						console.log("Looking at function: [" + i + "]");						var testStoreMember = testStore[i];						if(!(typeof testStoreMember === "function")){							console.log("Problem with function: [" + i + "].   Got value: " + testStoreMember);							passed = false;							break;						}					}				}			}			t.assertTrue(passed);		}	]);}

⌨️ 快捷键说明

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