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

📄 locale.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
						var num = (v < cutoff) ? century + v : century - 100 + v;						result[0] = num;					}else{						//we expected 2 digits and got more...						if(options.strict){							return false;						}						//interpret literally, so '150' would be 150 A.D.						//also tolerate '1950', if 'yyyy' input passed to 'yy' format						result[0] = v;					}				}				break;			case 'M':				if(l>2){					var months = bundle['months-format-' + widthList[l-3]].concat();					if(!options.strict){						//Tolerate abbreviating period in month part						//Case-insensitive comparison						v = v.replace(".","").toLowerCase();						months = dojo.map(months, function(s){ return s.replace(".","").toLowerCase(); } );					}					v = dojo.indexOf(months, v);					if(v == -1){//						console.debug("dojo.date.locale.parse: Could not parse month name: '" + v + "'.");						return false;					}				}else{					v--;				}				result[1] = v;				break;			case 'E':			case 'e':				var days = bundle['days-format-' + widthList[l-3]].concat();				if(!options.strict){					//Case-insensitive comparison					v = v.toLowerCase();					days = dojo.map(days, function(d){return d.toLowerCase();});				}				v = dojo.indexOf(days, v);				if(v == -1){//					console.debug("dojo.date.locale.parse: Could not parse weekday name: '" + v + "'.");					return false;				}				//TODO: not sure what to actually do with this input,				//in terms of setting something on the Date obj...?				//without more context, can't affect the actual date				//TODO: just validate?				break;			case 'D':				result[1] = 0;				// fallthrough...			case 'd':				result[2] = v;				break;			case 'a': //am/pm				var am = options.am || bundle.am;				var pm = options.pm || bundle.pm;				if(!options.strict){					var period = /\./g;					v = v.replace(period,'').toLowerCase();					am = am.replace(period,'').toLowerCase();					pm = pm.replace(period,'').toLowerCase();				}				if(options.strict && v != am && v != pm){//					console.debug("dojo.date.locale.parse: Could not parse am/pm part.");					return false;				}				// we might not have seen the hours field yet, so store the state and apply hour change later				amPm = (v == pm) ? 'p' : (v == am) ? 'a' : '';				break;			case 'K': //hour (1-24)				if(v == 24){ v = 0; }				// fallthrough...			case 'h': //hour (1-12)			case 'H': //hour (0-23)			case 'k': //hour (0-11)				//TODO: strict bounds checking, padding				if(v > 23){//					console.debug("dojo.date.locale.parse: Illegal hours value");					return false;				}				//in the 12-hour case, adjusting for am/pm requires the 'a' part				//which could come before or after the hour, so we will adjust later				result[3] = v;				break;			case 'm': //minutes				result[4] = v;				break;			case 's': //seconds				result[5] = v;				break;			case 'S': //milliseconds				result[6] = v;//				break;//			case 'w'://TODO				var firstDay = 0;//			default://TODO: throw?//				console.debug("dojo.date.locale.parse: unsupported pattern char=" + token.charAt(0));		}		return true;	});	var hours = +result[3];	if(amPm === 'p' && hours < 12){		result[3] = hours + 12; //e.g., 3pm -> 15	}else if(amPm === 'a' && hours == 12){		result[3] = 0; //12am -> 0	}	//TODO: implement a getWeekday() method in order to test 	//validity of input strings containing 'EEE' or 'EEEE'...	var dateObject = new Date(result[0], result[1], result[2], result[3], result[4], result[5], result[6]); // Date	if(options.strict){		dateObject.setFullYear(result[0]);	}	// Check for overflow.  The Date() constructor normalizes things like April 32nd...	//TODO: why isn't this done for times as well?	var allTokens = tokens.join("");	if(!valid ||		(allTokens.indexOf('M') != -1 && dateObject.getMonth() != result[1]) ||		(allTokens.indexOf('d') != -1 && dateObject.getDate() != result[2])){		return null;	}	return dateObject; // Date};function _processPattern(pattern, applyPattern, applyLiteral, applyAll){	//summary: Process a pattern with literals in it	// Break up on single quotes, treat every other one as a literal, except '' which becomes '	var identity = function(x){return x;};	applyPattern = applyPattern || identity;	applyLiteral = applyLiteral || identity;	applyAll = applyAll || identity;	//split on single quotes (which escape literals in date format strings) 	//but preserve escaped single quotes (e.g., o''clock)	var chunks = pattern.match(/(''|[^'])+/g); 	var literal = false;	dojo.forEach(chunks, function(chunk, i){		if(!chunk){			chunks[i]='';		}else{			chunks[i]=(literal ? applyLiteral : applyPattern)(chunk);			literal = !literal;		}	});	return applyAll(chunks.join(''));}function _buildDateTimeRE(tokens, bundle, options, pattern){	pattern = dojo.regexp.escapeString(pattern);	if(!options.strict){ pattern = pattern.replace(" a", " ?a"); } // kludge to tolerate no space before am/pm	return pattern.replace(/([a-z])\1*/ig, function(match){		// Build a simple regexp.  Avoid captures, which would ruin the tokens list		var s;		var c = match.charAt(0);		var l = match.length;		var p2 = '', p3 = '';		if(options.strict){			if(l > 1){ p2 = '0' + '{'+(l-1)+'}'; }			if(l > 2){ p3 = '0' + '{'+(l-2)+'}'; }		}else{			p2 = '0?'; p3 = '0{0,2}';		}		switch(c){			case 'y':				s = '\\d{2,4}';				break;			case 'M':				s = (l>2) ? '\\S+' : p2+'[1-9]|1[0-2]';				break;			case 'D':				s = p2+'[1-9]|'+p3+'[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6]';				break;			case 'd':				s = p2+'[1-9]|[12]\\d|3[01]';				break;			case 'w':				s = p2+'[1-9]|[1-4][0-9]|5[0-3]';				break;		    case 'E':				s = '\\S+';				break;			case 'h': //hour (1-12)				s = p2+'[1-9]|1[0-2]';				break;			case 'k': //hour (0-11)				s = p2+'\\d|1[01]';				break;			case 'H': //hour (0-23)				s = p2+'\\d|1\\d|2[0-3]';				break;			case 'K': //hour (1-24)				s = p2+'[1-9]|1\\d|2[0-4]';				break;			case 'm':			case 's':				s = '[0-5]\\d';				break;			case 'S':				s = '\\d{'+l+'}';				break;			case 'a':				var am = options.am || bundle.am || 'AM';				var pm = options.pm || bundle.pm || 'PM';				if(options.strict){					s = am + '|' + pm;				}else{					s = am + '|' + pm;					if(am != am.toLowerCase()){ s += '|' + am.toLowerCase(); }					if(pm != pm.toLowerCase()){ s += '|' + pm.toLowerCase(); }				}				break;			default:			// case 'v':			// case 'z':			// case 'Z':				s = ".*";//				console.debug("parse of date format, pattern=" + pattern);		}		if(tokens){ tokens.push(match); }		return "(" + s + ")"; // add capture	}).replace(/[\xa0 ]/g, "[\\s\\xa0]"); // normalize whitespace.  Need explicit handling of \xa0 for IE.}})();(function(){var _customFormats = [];dojo.date.locale.addCustomFormats = function(/*String*/packageName, /*String*/bundleName){	// summary:	//		Add a reference to a bundle containing localized custom formats to be	//		used by date/time formatting and parsing routines.	//	// description:	//		The user may add custom localized formats where the bundle has properties following the	//		same naming convention used by dojo.cldr: `dateFormat-xxxx` / `timeFormat-xxxx`	//		The pattern string should match the format used by the CLDR.	//		See dojo.date.locale.format() for details.	//		The resources must be loaded by dojo.requireLocalization() prior to use	_customFormats.push({pkg:packageName,name:bundleName});};dojo.date.locale._getGregorianBundle = function(/*String*/locale){	var gregorian = {};	dojo.forEach(_customFormats, function(desc){		var bundle = dojo.i18n.getLocalization(desc.pkg, desc.name, locale);		gregorian = dojo.mixin(gregorian, bundle);	}, this);	return gregorian; /*Object*/};})();dojo.date.locale.addCustomFormats("dojo.cldr","gregorian");dojo.date.locale.getNames = function(/*String*/item, /*String*/type, /*String?*/use, /*String?*/locale){	// summary:	//		Used to get localized strings from dojo.cldr for day or month names.	//	// item:	//	'months' || 'days'	// type:	//	'wide' || 'narrow' || 'abbr' (e.g. "Monday", "Mon", or "M" respectively, in English)	// use:	//	'standAlone' || 'format' (default)	// locale:	//	override locale used to find the names	var label;	var lookup = dojo.date.locale._getGregorianBundle(locale);	var props = [item, use, type];	if(use == 'standAlone'){		label = lookup[props.join('-')];	}	props[1] = 'format';	// return by copy so changes won't be made accidentally to the in-memory model	return (label || lookup[props.join('-')]).concat(); /*Array*/};dojo.date.locale.isWeekend = function(/*Date?*/dateObject, /*String?*/locale){	// summary:	//	Determines if the date falls on a weekend, according to local custom.	var weekend = dojo.cldr.supplemental.getWeekend(locale);	var day = (dateObject || new Date()).getDay();	if(weekend.end < weekend.start){		weekend.end += 7;		if(day < weekend.start){ day += 7; }	}	return day >= weekend.start && day <= weekend.end; // Boolean};// These are used only by format and strftime.  Do they need to be public?  Which module should they go in?dojo.date.locale._getDayOfYear = function(/*Date*/dateObject){	// summary: gets the day of the year as represented by dateObject	return dojo.date.difference(new Date(dateObject.getFullYear(), 0, 1), dateObject) + 1; // Number};dojo.date.locale._getWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDayOfWeek){	if(arguments.length == 1){ firstDayOfWeek = 0; } // Sunday	var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1).getDay();	var adj = (firstDayOfYear - firstDayOfWeek + 7) % 7;	var week = Math.floor((dojo.date.locale._getDayOfYear(dateObject) + adj - 1) / 7);	// if year starts on the specified day, start counting weeks at 1	if(firstDayOfYear == firstDayOfWeek){ week++; }	return week; // Number};}

⌨️ 快捷键说明

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