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

📄 csvstore.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
			t.assertTrue(count === 2);		},		function testReadAPI_fetch_patternMatch0(t){			//	summary: 			//		Function to test pattern matching of everything starting with lowercase e			//	description:			//		Function to test pattern matching of everything starting with lowercase e			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(2, items.length);				var valueArray = [ "Alien", "The Sequel to \"Dances With Wolves.\""];				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "Title", valueArray));				d.callback(true);			}						csvStore.fetch({query: {Producer: "* Scott"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_patternMatch1(t){			//	summary: 			//		Function to test pattern matching of everything with $ in it.			//	description:			//		Function to test pattern matching of everything with $ in it.						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.assertTrue(items.length === 2);				var valueArray = [ "jfq4@#!$!@Rf14r14i5u", "bit$Bite"];				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", valueArray));				d.callback(true);			}						csvStore.fetch({query: {value: "*$*"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_patternMatch2(t){			//	summary: 			//		Function to test exact pattern match			//	description:			//		Function to test exact pattern match						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(1, items.length);				t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo");				d.callback(true);			}						csvStore.fetch({query: {value: "bar\*foo"}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_patternMatch_caseInsensitive(t){			//	summary: 			//		Function to test exact pattern match with case insensitivity set.			//	description:			//		Function to test exact pattern match with case insensitivity set.						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(1, items.length);				t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo");				d.callback(true);			}						csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: true}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_patternMatch_caseSensitive(t){			//	summary: 			//		Function to test exact pattern match with case insensitivity set.			//	description:			//		Function to test exact pattern match with case insensitivity set.						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(0, items.length);				d.callback(true);			}						csvStore.fetch({query: {value: "BAR\\*foo"}, queryOptions: {ignoreCase: false}, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortNumeric(t){			//	summary: 			//		Function to test sorting numerically.			//	description:			//		Function to test sorting numerically.						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);			var d = new doh.Deferred();			function completed(items, request){				t.assertTrue(items.length === 10);				// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.				var orderedArray = [ "1", "10", "2", "3", "4", "5", "6", "7", "8", "9" ];				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));				d.callback(true);			}			var sortAttributes = [{attribute: "uniqueId"}];			csvStore.fetch({onComplete: completed, 							onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d),							sort: sortAttributes});			return d; //Object		},		function testReadAPI_fetch_sortNumericDescending(t){			//	summary: 			//		Function to test sorting numerically.			//	description:			//		Function to test sorting numerically.			var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(10, items.length);				// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.				var orderedArray = [ "9", "8", "7", "6", "5", "4", "3", "2", "10", "1" ];				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));				d.callback(true);			}						var sortAttributes = [{attribute: "uniqueId", descending: true}];			csvStore.fetch({ sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortNumericWithCount(t){			//	summary: 			//		Function to test sorting numerically in descending order, returning only a specified number of them.			//	description:			//		Function to test sorting numerically in descending order, returning only a specified number of them.					var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				t.is(5, items.length);				// TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically.				var orderedArray = [ "9", "8", "7", "6", "5" ];				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray));				d.callback(true);			}						var sortAttributes = [{attribute: "uniqueId", descending: true}];			csvStore.fetch({sort: sortAttributes, 							count: 5,							onComplete: completed,							onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortAlphabetic(t){			//	summary: 			//		Function to test sorting alphabetic ordering.			//	description:			//		Function to test sorting alphabetic ordering.					var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				//Output should be in this order...				var orderedArray = [ 	"123abc",										"123abc",										"123abc",										"123abcdefg",										"BaBaMaSaRa***Foo",										"bar*foo",										"bit$Bite",										"foo*bar",										"jfq4@#!$!@Rf14r14i5u",										undefined					];				t.is(10, items.length);				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray));				d.callback(true);			}						var sortAttributes = [{attribute: "value"}];			csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortAlphabeticDescending(t){			//	summary: 			//		Function to test sorting alphabetic ordering in descending mode.			//	description:			//		Function to test sorting alphabetic ordering in descending mode.					var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);						var d = new doh.Deferred();			function completed(items, request){				//Output should be in this order...				var orderedArray = [ 	undefined,										"jfq4@#!$!@Rf14r14i5u",										"foo*bar",										"bit$Bite",										"bar*foo",										"BaBaMaSaRa***Foo",										"123abcdefg",										"123abc",										"123abc",										"123abc"					];				t.is(10, items.length);				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray));				d.callback(true);			}						var sortAttributes = [{attribute: "value", descending: true}];			csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortMultiple(t){			//	summary: 			//		Function to test sorting on multiple attributes.			//	description:			//		Function to test sorting on multiple attributes.						var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/patterns.csv");			var csvStore = new dojox.data.CsvStore(args);					var d = new doh.Deferred();			function completed(items, request){				var orderedArray0 = [ "8", "5", "3", "10", "6", "2", "4", "1", "9", "7" ];				var orderedArray1 = [	"123abc",										"123abc",										"123abc",										"123abcdefg",										"BaBaMaSaRa***Foo",										"bar*foo",										"bit$Bite",										"foo*bar",										"jfq4@#!$!@Rf14r14i5u",										undefined									];				t.is(10, items.length);				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray0));				t.assertTrue(dojox.data.tests.stores.CsvStore.verifyItems(csvStore, items, "value", orderedArray1));				d.callback(true);			}						var sortAttributes = [{ attribute: "value"}, { attribute: "uniqueId", descending: true}];			csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		function testReadAPI_fetch_sortMultipleSpecialComparator(t){			//	summary: 			//		Function to test sorting on multiple attributes with a custom comparator.			//	description:			//		Function to test sorting on multiple attributes with a custom comparator.			var args = dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv");			var csvStore = new dojox.data.CsvStore(args);						csvStore.comparatorMap = {};			csvStore.comparatorMap["Producer"] = function(a,b){ 				var ret = 0;				// We want to sort authors alphabetical by their last name				function lastName(name){					if(typeof name === "undefined"){ return undefined; }										var matches = name.match(/\s*(\S+)$/); // Grab the last word in the string.					return matches ? matches[1] : name; // Strings with only whitespace will not match.				}				var lastNameA = lastName(a);				var lastNameB = lastName(b);				if(lastNameA > lastNameB || typeof lastNameA === "undefined"){					ret = 1;				}else if(lastNameA < lastNameB || typeof lastNameB === "undefined"){					ret = -1;				}				return ret;			};					var sortAttributes = [{attribute: "Producer", descending: true}, { attribute: "Title", descending: true}];					var d = new doh.Deferred();			function completed(items, findResult){				var orderedArray = [5,4,0,3,2,1,6];				t.assertTrue(items.length === 7);				var passed = true;				for(var i = 0; i < items.length; i++){					if(!(csvStore.getIdentity(items[i]) === orderedArray[i])){						passed=false;						break;					}				}				t.assertTrue(passed);				d.callback(true);			}						csvStore.fetch({sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.data.tests.stores.CsvStore.error, t, d)});			return d; //Object		},		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 = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"));			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);		},		function testIdentityAPI_functionConformance(t){			//	summary: 			//		Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.			//	description:			//		Simple test identity API conformance.  Checks to see all declared functions are actual functions on the instances.			var testStore = new dojox.data.CsvStore(dojox.data.tests.stores.CsvStore.getDatasource("stores/movies.csv"));			var identityApi = new dojo.data.api.Identity();			var passed = true;			for(i in identityApi){				if(i.toString().charAt(0) !== '_')				{					var member = identityApi[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")){							passed = false;							break;						}					}				}			}			t.assertTrue(passed);		}	]);}

⌨️ 快捷键说明

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