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

📄 csvstore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
			 args.label = "Title";			 var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function onComplete(items, request){				t.assertEqual(items.length, 1);				var labelList = csvStore.getLabelAttributes(items[0]);				t.assertTrue(dojo.isArray(labelList));				t.assertEqual("Title", labelList[0]);				d.callback(true);			}			csvStore.fetch({ 	query: {Title: "*Sequel*"}, 								onComplete: onComplete, 								onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is('Dymtryk "the King", Edward', csvStore.getValue(item,"Producer"));				t.is('Caine Mutiny, The', csvStore.getValue(item,"Title"));				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "6", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("City of God", csvStore.getValue(item,"Title"));				t.is("2002", csvStore.getValue(item,"Year"));				d.callback(true);				}            csvStore.fetchItemByIdentity({identity: "0", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("1979", csvStore.getValue(item,"Year"));				t.is("Alien", csvStore.getValue(item,"Title"));				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.is("2001: A Space Odyssey", csvStore.getValue(item,"Title"));				t.is("Stanley Kubrick", csvStore.getValue(item,"Producer"));				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "2", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				var names = csvStore.getValues(item,"Title");				t.assertTrue(dojo.isArray(names));				t.is(1, names.length);				t.is("Rain", names[0]);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "7", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "-1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item === null);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "999999", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(7, items.length);				var passed = true;				for(var i = 0; i < items.length; i++){					if(!(csvStore.getIdentity(items[i]) === i)){						passed=false;						break;					}				}				t.assertTrue(passed);				d.callback(true);			}						//Get everything...			csvStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(csvStore.isItem(item));				t.assertEqual(null, csvStore.getIdentityAttributes(item)); 				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(csvStore.isItem(item));				t.assertTrue(!csvStore.isItem({}));				t.assertTrue(!csvStore.isItem({ item: "not an item" }));				t.assertTrue(!csvStore.isItem("not an item"));				t.assertTrue(!csvStore.isItem(["not an item"]));				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(csvStore.hasAttribute(item, "Title"));				t.assertTrue(csvStore.hasAttribute(item, "Producer"));				t.assertTrue(!csvStore.hasAttribute(item, "Year"));				t.assertTrue(!csvStore.hasAttribute(item, "Nothing"));				t.assertTrue(!csvStore.hasAttribute(item, "title"));				//Test that null attributes throw an exception				var passed = false;				try{					csvStore.hasAttribute(item, null);				}catch (e){					passed = true;				}				t.assertTrue(passed);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args); 						var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(csvStore.containsValue(item, "Title", "Alien"));				t.assertTrue(csvStore.containsValue(item, "Year", "1979"));				t.assertTrue(csvStore.containsValue(item, "Producer", "Ridley Scott"));				t.assertTrue(!csvStore.containsValue(item, "Title", "Alien2"));				t.assertTrue(!csvStore.containsValue(item, "Year", "1979   "));				t.assertTrue(!csvStore.containsValue(item, "Title", null));				//Test that null attributes throw an exception				var passed = false;				try{					csvStore.containsValue(item, null, "foo");				}catch (e){					passed = true;				}				t.assertTrue(passed);				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				t.assertTrue(item !== null);				t.assertTrue(csvStore.isItem(item));				var attributes = csvStore.getAttributes(item);				t.is(3, attributes.length);				for(var i = 0; i < attributes.length; i++){					t.assertTrue((attributes[i] === "Title" || attributes[i] === "Year" || attributes[i] === "Producer"));				}				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "4", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});		   	return d;		},		function testReadAPI_getAttributes_onlyTwo(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.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function onItem(item){				// Test an item that does not have all of the attributes				t.assertTrue(item !== null);				t.assertTrue(csvStore.isItem(item));				var attributes = csvStore.getAttributes(item);				t.assertTrue(attributes.length === 2);				t.assertTrue(attributes[0] === "Title");				t.assertTrue(attributes[1] === "Producer");				d.callback(true);				}			csvStore.fetchItemByIdentity({identity: "1", onItem: onItem, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});		   	return d;		},		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 args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);			var features = csvStore.getFeatures(); 			var count = 0;			for(i in features){				t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity"));				count++;			}

⌨️ 快捷键说明

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