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

📄 keyvaluestore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
			 var keyStore = new dojox.data.KeyValueStore(args);						var d = new doh.Deferred();			function onComplete(items, request){				t.assertEqual(items.length, 1);				var labelList = keyStore.getLabelAttributes(items[0]);				t.assertTrue(dojo.isArray(labelList));				t.assertEqual("key", labelList[0]);				d.callback(true);			}			keyStore.fetch({ 	query: {key: "year"}, 								onComplete: onComplete, 								onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)							});			return d;		},		function testReadAPI_getValue(t){			//	summary: 			//		Simple test of the getValue function of the store.			//	description:			//		Simple test of the getValue function of the store.			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("nday", keyStore.getValue(item,"key"));				t.is(1, keyStore.getValue(item,"value"));				t.is(1, keyStore.getValue(item,"nday"));				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "nday", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},			function testReadAPI_getValue_2(t){			//	summary: 			//		Simple test of the getValue function of the store.			//	description:			//		Simple test of the getValue function of the store.			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("day", keyStore.getValue(item,"key"));				t.is("Saturday", keyStore.getValue(item,"value"));				t.is("Saturday", keyStore.getValue(item,"day"));				d.callback(true);				}            keyStore.fetchItemByIdentity({identity: "day", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},			function testReadAPI_getValue_3(t){			//	summary: 			//		Simple test of the getValue function of the store.			//	description:			//		Simple test of the getValue function of the store.			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("dayOfYear", keyStore.getValue(item,"key"));				t.is(335, keyStore.getValue(item,"value"));				t.is(335, keyStore.getValue(item,"dayOfYear"));				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "dayOfYear", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},			function testReadAPI_getValue_4(t){			//	summary: 			//		Simple test of the getValue function of the store.			//	description:			//		Simple test of the getValue function of the store.			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("weekOfYear", keyStore.getValue(item,"key"));				t.is(48, keyStore.getValue(item,"value"));				t.is(48, keyStore.getValue(item,"weekOfYear"));				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "weekOfYear", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testReadAPI_getValues(t){			//	summary: 			//		Simple test of the getValues function of the store.			//	description:			//		Simple test of the getValues function of the store.			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				var names = keyStore.getValues(item,"year");				t.assertTrue(dojo.isArray(names));				t.is(1, names.length);				t.is(2007, names[0]);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testIdentityAPI_fetchItemByIdentity(t){			//	summary: 			//		Simple test of the fetchItemByIdentity function of the store.			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testIdentityAPI_fetchItemByIdentity_bad1(t){			//	summary: 			//		Simple test of the fetchItemByIdentity function of the store.			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "y3ar", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testIdentityAPI_fetchItemByIdentity_bad2(t){			//	summary: 			//		Simple test of the fetchItemByIdentity function of the store.			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "-1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testIdentityAPI_fetchItemByIdentity_bad3(t){			//	summary: 			//		Simple test of the fetchItemByIdentity function of the store.			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "999999", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d;		},		function testIdentityAPI_getIdentity(t){			//	summary: 			//		Simple test of the fetchItemByIdentity function of the store.			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(7, items.length);				t.is(keyStore.getIdentity(items[0]), 'year');				t.is(keyStore.getIdentity(items[1]), 'nmonth');				t.is(keyStore.getIdentity(items[2]), 'month');				t.is(keyStore.getIdentity(items[3]), 'nday');				t.is(keyStore.getIdentity(items[4]), 'day');				t.is(keyStore.getIdentity(items[5]), 'dayOfYear');				t.is(keyStore.getIdentity(items[6]), 'weekOfYear');				d.callback(true);			}						//Get everything...			keyStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});			return d; //Object		},		function testIdentityAPI_getIdentityAttributes(t){			//	summary: 			//		Simple test of the getIdentityAttributes			//	description:			//		Simple test of the fetchItemByIdentity function of the store.						var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(keyStore.isItem(item));				t.assertEqual("key", keyStore.getIdentityAttributes(item)); 				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});		   	return d;		},		function testReadAPI_isItem(t){			//	summary: 			//		Simple test of the isItem function of the store			//	description:			//		Simple test of the isItem function of the store			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(keyStore.isItem(item));				t.assertTrue(!keyStore.isItem({}));				t.assertTrue(!keyStore.isItem({ item: "not an item" }));				t.assertTrue(!keyStore.isItem("not an item"));				t.assertTrue(!keyStore.isItem(["not an item"]));				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});		   	return d;		},		function testReadAPI_hasAttribute(t){			//	summary: 			//		Simple test of the hasAttribute function of the store			//	description:			//		Simple test of the hasAttribute function of the store			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(keyStore.hasAttribute(item, "key"));				t.assertTrue(keyStore.hasAttribute(item, "value"));				t.assertTrue(keyStore.hasAttribute(item, "year"));				t.assertTrue(!keyStore.hasAttribute(item, "Year"));				t.assertTrue(!keyStore.hasAttribute(item, "Nothing"));				t.assertTrue(!keyStore.hasAttribute(item, "Title"));				//Test that null attributes throw an exception				var passed = false;				try{					keyStore.hasAttribute(item, null);				}catch (e){					passed = true;				}				t.assertTrue(passed);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});		   	return d;		},		function testReadAPI_containsValue(t){			//	summary:  			//		Simple test of the containsValue function of the store			//	description:			//		Simple test of the containsValue function of the store			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args); 						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(keyStore.containsValue(item, "year", "2007"));				t.assertTrue(keyStore.containsValue(item, "value", "2007"));				t.assertTrue(keyStore.containsValue(item, "key", "year"));				t.assertTrue(!keyStore.containsValue(item, "Title", "Alien2"));				t.assertTrue(!keyStore.containsValue(item, "Year", "1979   "));				t.assertTrue(!keyStore.containsValue(item, "Title", null));				//Test that null attributes throw an exception				var passed = false;				try{					keyStore.containsValue(item, null, "foo");				}catch (e){					passed = true;				}				t.assertTrue(passed);				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});		   	return d;		},		function testReadAPI_getAttributes(t){			//	summary: 			//		Simple test of the getAttributes function of the store			//	description:			//		Simple test of the getAttributes function of the store			var args = dojox.data.tests.stores.KeyValueStore.getDatasource("stores/movies.csv");			var keyStore = new dojox.data.KeyValueStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(keyStore.isItem(item));				var attributes = keyStore.getAttributes(item);				t.is(3, attributes.length);				for(var i = 0; i < attributes.length; i++){					t.assertTrue((attributes[i] === "year" || attributes[i] === "value" || attributes[i] === "key"));				}				d.callback(true);				}			keyStore.fetchItemByIdentity({identity: "year", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.KeyValueStore.error, t, d)});

⌨️ 快捷键说明

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