标签:des style http io ar color os 使用 sp
带有详尽注释的源代码:
- var jQuery = jQuery || {};
- jQuery.string = jQuery.string || {};
- jQuery.string.decodeHTML = function(source) {
- var str = String(source).replace(/"/g, ‘"‘).replace(/</g, ‘<‘)
- .replace(/>/g, ‘>‘).replace(/&/g, "&");
-
- return str.replace(/&#([\d]+);/g, function(_0, _1) {
- return String.fromCharCode(parseInt(_1, 10));
- });
- };
-
- jQuery.string.encodeHTML = function(source) {
- return String(source).replace(/&/g, ‘&‘).replace(/</g, ‘<‘).replace(
- />/g, ‘>‘).replace(/"/g, """).replace(/‘/g, "'");
- };
- jQuery.string.escapeReg = function(source) {
- return String(source).replace(
- new RegExp("([.*+?^=!:\x24{}()|[\\]\/\\\\])", "g"), ‘\\\x241‘);
- };
- jQuery.string.format = function(source, opts) {
- source = String(source);
- var data = Array.prototype.slice.call(arguments, 1), toString = Object.prototype.toString;
- if (data.length) {
- data = data.length == 1 ?
-
- (opts !== null
- && (/\[object Array\]|\[object Object\]/.test(toString
- .call(opts))) ? opts : data) : data;
- return source.replace(/#\{(.+?)\}/g, function(match, key) {
- var replacer = data[key];
-
- if (‘[object Function]‘ == toString.call(replacer)) {
- replacer = replacer(key);
- }
- return (‘undefined‘ == typeof replacer ? ‘‘ : replacer);
- });
- }
- return source;
- };
- jQuery.string.getByteLength = function(source) {
- return String(source).replace(/[^\x00-\xff]/g, "ci").length;
- };
- jQuery.string.stripTags = function(source) {
- return String(source || ‘‘).replace(/<[^>]+>/g, ‘‘);
- };
- jQuery.string.subByte = function(source, length, tail) {
- source = String(source);
- tail = tail || ‘‘;
- if (length < 0 || jQuery.string.getByteLength(source) <= length) {
- return source + tail;
- }
-
-
- source = source.substr(0, length).replace(/([^\x00-\xff])/g, "\x241 ")
- .substr(0, length)
- .replace(/[^\x00-\xff]$/, "")
- .replace(/([^\x00-\xff]) /g, "\x241");
- return source + tail;
-
- };
-
- jQuery.string.toCamelCase = function(source) {
-
- if (source.indexOf(‘-‘) < 0 && source.indexOf(‘_‘) < 0) {
- return source;
- }
- return source.replace(/[-_][^-_]/g, function(match) {
- return match.charAt(1).toUpperCase();
- });
- };
-
- jQuery.string.toHalfWidth = function(source) {
- return String(source).replace(/[\uFF01-\uFF5E]/g, function(c) {
- return String.fromCharCode(c.charCodeAt(0) - 65248);
- }).replace(/\u3000/g, " ");
- };
- jQuery.string.trim = jQuery.trim;
- jQuery.string.wbr = function(source) {
- return String(source).replace(/(?:<[^>]+>)|(?:&#?[0-9a-z]{2,6};)|(.{1})/gi,
- ‘$&<wbr>‘).replace(/><wbr>/g, ‘>‘);
- };
- jQuery.string.filterFormat = function(source, opts) {
- var data = Array.prototype.slice.call(arguments, 1), toString = Object.prototype.toString;
- if (data.length) {
- data = data.length == 1 ?
-
- (opts !== null
- && (/\[object Array\]|\[object Object\]/.test(toString
- .call(opts))) ? opts : data) : data;
- return source.replace(/#\{(.+?)\}/g, function(match, key) {
- var filters, replacer, i, len, func;
- if (!data)
- return ‘‘;
- filters = key.split("|");
- replacer = data[filters[0]];
-
- if (‘[object Function]‘ == toString.call(replacer)) {
- replacer = replacer(filters[0]
- }
- for (i = 1, len = filters.length; i < len; ++i) {
- func = jQuery.string.filterFormat[filters[i]];
- if (‘[object Function]‘ == toString.call(func)) {
- replacer = func(replacer);
- }
- }
- return ((‘undefined‘ == typeof replacer || replacer === null) ? ‘‘
- : replacer);
- });
- }
- return source;
- };
- jQuery.string.filterFormat.escapeJs = function(str) {
- if (!str || ‘string‘ != typeof str)
- return str;
- var i, len, charCode, ret = [];
- for (i = 0, len = str.length; i < len; ++i) {
- charCode = str.charCodeAt(i);
- if (charCode > 255) {
- ret.push(str.charAt(i));
- } else {
- ret.push(‘\\x‘ + charCode.toString(16));
- }
- }
- return ret.join(‘‘);
- };
- jQuery.string.filterFormat.escapeString = function(str) {
- if (!str || ‘string‘ != typeof str)
- return str;
- return str.replace(/["‘<>\\\/`]/g, function($0) {
- return ‘&#‘ + $0.charCodeAt(0) + ‘;‘;
- });
- };
- jQuery.string.filterFormat.toInt = function(str) {
- return parseInt(str, 10) || 0;
- };
- jQuery.array = jQuery.array || {};
- jQuery.array.contains = function(source, obj) {
- return (jQuery.array.indexOf(source, obj) >= 0);
- };
- jQuery.array.empty = function(source) {
- source.length = 0;
- };
- jQuery.array.filter = function(source, iterator, thisObject) {
- var result = [], resultIndex = 0, len = source.length, item, i;
-
- if (‘function‘ == typeof iterator) {
- for (i = 0; i < len; i++) {
- item = source[i];
-
- if (true === iterator.call(thisObject || source, item, i)) {
-
- result[resultIndex++] = item;
- }
- }
- }
-
- return result;
- };
- jQuery.array.find = function(source, iterator) {
- var item, i, len = source.length;
-
- if (‘function‘ == typeof iterator) {
- for (i = 0; i < len; i++) {
- item = source[i];
- if (true === iterator.call(source, item, i)) {
- return item;
- }
- }
- }
-
- return null;
- };
- jQuery.array.indexOf = function(source, match, fromIndex) {
- var len = source.length, iterator = match;
-
- fromIndex = fromIndex | 0;
- if (fromIndex < 0) {
- fromIndex = Math.max(0, len + fromIndex);
- }
- for (; fromIndex < len; fromIndex++) {
- if (fromIndex in source && source[fromIndex] === match) {
- return fromIndex;
- }
- }
-
- return -1;
- };
- jQuery.array.lastIndexOf = function(source, match, fromIndex) {
- var len = source.length;
-
- fromIndex = fromIndex | 0;
-
- if (!fromIndex || fromIndex >= len) {
- fromIndex = len - 1;
- }
- if (fromIndex < 0) {
- fromIndex += len;
- }
- for (; fromIndex >= 0; fromIndex--) {
- if (fromIndex in source && source[fromIndex] === match) {
- return fromIndex;
- }
- }
-
- return -1;
- };
- jQuery.array.remove = function(source, match) {
- var len = source.length;
-
- while (len--) {
- if (len in source && source[len] === match) {
- source.splice(len, 1);
- }
- }
- return source;
- };
- jQuery.array.removeAt = function(source, index) {
- return source.splice(index, 1)[0];
- };
- jQuery.array.unique = function(source, compareFn) {
- var len = source.length, result = source.slice(0), i, datum;
-
- if (‘function‘ != typeof compareFn) {
- compareFn = function(item1, item2) {
- return item1 === item2;
- };
- }
-
-
-
- while (--len > 0) {
- datum = result[len];
- i = len;
- while (i--) {
- if (compareFn(datum, result[i])) {
- result.splice(len, 1);
- break;
- }
- }
- }
-
- return result;
- };
- jQuery.cookie = jQuery.cookie || {};
- jQuery.cookie.isValidKey = function(key) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return (new RegExp(
- "^[^\\x00-\\x20\\x7f\\(\\)<>@,;:\\\\\\\"\\[\\]\\?=\\{\\}\\/\\u0080-\\uffff]+\x24"))
- .test(key);
- };
-
- jQuery.cookie.get = function(key) {
- var value = jQuery.cookie.getRaw(key);
- if (‘string‘ == typeof value) {
- value = decodeURIComponent(value);
- return value;
- }
- return null;
- };
- jQuery.cookie.getRaw = function(key) {
- if (jQuery.cookie.isValidKey(key)) {
- var reg = new RegExp("(^| )" + key + "=([^;]*)(;|\x24)"), result = reg
- .exec(document.cookie);
-
- if (result) {
- return result[2] || null;
- }
- }
-
- return null;
- };
- jQuery.cookie.remove = function(key, options) {
- options = options || {};
- options.expires = new Date(0);
- jQuery.cookie.setRaw(key, ‘‘, options);
- };
- jQuery.cookie.set = function(key, value, options) {
- jQuery.cookie.setRaw(key, encodeURIComponent(value), options);
- };
- jQuery.cookie.setRaw = function(key, value, options) {
- if (!jQuery.cookie.isValidKey(key)) {
- return;
- }
-
- options = options || {};
-
-
-
-
- var expires = options.expires;
- if (‘number‘ == typeof options.expires) {
- expires = new Date();
- expires.setTime(expires.getTime() + options.expires);
- }
-
- document.cookie = key + "=" + value
- + (options.path ? "; path=" + options.path : "")
- + (expires ? "; expires=" + expires.toGMTString() : "")
- + (options.domain ? "; domain=" + options.domain : "")
- + (options.secure ? "; secure" : ‘‘);
- };
- jQuery.date = jQuery.date || {};
-
- jQuery.date.format = function(source, pattern) {
- if (‘string‘ != typeof pattern) {
- return source.toString();
- }
-
- function replacer(patternPart, result) {
- pattern = pattern.replace(patternPart, result);
- }
-
- var pad = jQuery.number.pad, year = source.getFullYear(), month = source
- .getMonth() + 1, date2 = source.getDate(), hours = source
- .getHours(), minutes = source.getMinutes(), seconds = source
- .getSeconds();
-
- replacer(/yyyy/g, pad(year, 4));
- replacer(/yy/g, pad(parseInt(year.toString().slice(2), 10), 2));
- replacer(/MM/g, pad(month, 2));
- replacer(/M/g, month);
- replacer(/dd/g, pad(date2, 2));
- replacer(/d/g, date2);
-
- replacer(/HH/g, pad(hours, 2));
- replacer(/H/g, hours);
- replacer(/hh/g, pad(hours % 12, 2));
- replacer(/h/g, hours % 12);
- replacer(/mm/g, pad(minutes, 2));
- replacer(/m/g, minutes);
- replacer(/ss/g, pad(seconds, 2));
- replacer(/s/g, seconds);
-
- return pattern;
- };
-
- jQuery.date.parse = function(source) {
- var reg = new RegExp("^\\d+(\\-|\\/)\\d+(\\-|\\/)\\d+\x24");
- if (‘string‘ == typeof source) {
- if (reg.test(source) || isNaN(Date.parse(source))) {
- var d = source.split(/ |T/), d1 = d.length > 1 ? d[1]
- .split(/[^\d]/) : [ 0, 0, 0 ], d0 = d[0].split(/[^\d]/);
- return new Date(d0[0] - 0, d0[1] - 1, d0[2] - 0, d1[0] - 0,
- d1[1] - 0, d1[2] - 0);
- } else {
- return new Date(source);
- }
- }
-
- return new Date();
- };
-
- jQuery.url = jQuery.url || {};
- jQuery.url.escapeSymbol = function(source) {
-
-
-
-
- return String(source).replace(
- /[#%&+=\/\\\ \ \f\r\n\t]/g,
- function(all) {
- return ‘%‘
- + (0x100 + all.charCodeAt()).toString(16).substring(1)
- .toUpperCase();
- });
- };
- jQuery.url.getQueryValue = function(url, key) {
- var reg = new RegExp("(^|&|\\?|#)" + jQuery.string.escapeReg(key)
- + "=([^&#]*)(&|\x24|#)", "");
- var match = url.match(reg);
- if (match) {
- return match[2];
- }
-
- return null;
- };
- jQuery.url.jsonToQuery = function(json, replacer_opt) {
- var result = [], itemLen, replacer = replacer_opt || function(value) {
- return jQuery.url.escapeSymbol(value);
- };
-
- jQuery.object.each(json, function(item, key) {
-
- if (jQuery.lang.isArray(item)) {
- itemLen = item.length;
-
-
- while (itemLen--) {
- result.push(key + ‘=‘ + replacer(item[itemLen], key));
- }
- } else {
- result.push(key + ‘=‘ + replacer(item, key));
- }
- });
-
- return result.join(‘&‘);
- };
- jQuery.url.queryToJson = function(url) {
- var query = url.substr(url.lastIndexOf(‘?‘) + 1), params = query.split(‘&‘), len = params.length, result = {}, i = 0, key, value, item, param;
-
- for (; i < len; i++) {
- if (!params[i]) {
- continue;
- }
- param = params[i].split(‘=‘);
- key = param[0];
- value = param[1];
-
- item = result[key];
- if (‘undefined‘ == typeof item) {
- result[key] = value;
- } else if (jQuery.lang.isArray(item)) {
- item.push(value);
- } else {
- result[key] = [ item, value ];
- }
- }
-
- return result;
- };
- jQuery.url.getContextPath = function() {
- var path = String(window.document.location);
- return path.substring(0, path.lastIndexOf("/"));
- };
- jQuery.form = jQuery.form || {};
- jQuery.form.json = function(form, replacer) {
- var elements = form.elements, replacer = replacer || function(value, name) {
- return value;
- }, data = {}, item, itemType, itemName, itemValue, opts, oi, oLen, oItem;
-
-
- function addData(name, value) {
- var val = data[name];
- if (val) {
- val.push || (data[name] = [ val ]);
- data[name].push(value);
- } else {
- data[name] = value;
- }
- }
-
- for ( var i = 0, len = elements.length; i < len; i++) {
- item = elements[i];
- itemName = item.name;
-
-
- if (!item.disabled && itemName) {
- itemType = item.type;
- itemValue = jQuery.url.escapeSymbol(item.value);
-
- switch (itemType) {
-
- case ‘radio‘:
- case ‘checkbox‘:
- if (!item.checked) {
- break;
- }
-
-
- case ‘textarea‘:
- case ‘text‘:
- case ‘password‘:
- case ‘hidden‘:
- case ‘file‘:
- case ‘select-one‘:
- addData(itemName, replacer(itemValue, itemName));
- break;
-
-
- case ‘select-multiple‘:
- opts = item.options;
- oLen = opts.length;
- for (oi = 0; oi < oLen; oi++) {
- oItem = opts[oi];
- if (oItem.selected) {
- addData(itemName, replacer(oItem.value, itemName));
- }
- }
- break;
- }
- }
- }
-
- return data;
- };
- jQuery.form.serialize = function(form, replacer) {
- var elements = form.elements, replacer = replacer || function(value, name) {
- return value;
- }, data = [], item, itemType, itemName, itemValue, opts, oi, oLen, oItem;
-
-
- function addData(name, value) {
- data.push(name + ‘=‘ + value);
- }
-
- for ( var i = 0, len = elements.length; i < len; i++) {
- item = elements[i];
- itemName = item.name;
-
-
- if (!item.disabled && itemName) {
- itemType = item.type;
- itemValue = jQuery.url.escapeSymbol(item.value);
-
- switch (itemType) {
-
- case ‘radio‘:
- case ‘checkbox‘:
- if (!item.checked) {
- break;
- }
-
-
- case ‘textarea‘:
- case ‘text‘:
- case ‘password‘:
- case ‘hidden‘:
- case ‘file‘:
- case ‘select-one‘:
- addData(itemName, replacer(itemValue, itemName));
- break;
-
-
- case ‘select-multiple‘:
- opts = item.options;
- oLen = opts.length;
- for (oi = 0; oi < oLen; oi++) {
- oItem = opts[oi];
- if (oItem.selected) {
- addData(itemName, replacer(oItem.value, itemName));
- }
- }
- break;
- }
- }
- }
-
- return data;
- };
- jQuery.form.findFirstElement = function(form) {
- var elements = null;
- if (!(elements = form.elements) || typeof elements.length !== "number"
- || elements.length === 0) {
- return null;
- }
- return elements[0];
- };
- jQuery.form.focusFirstElement = function(form) {
- var elements = null;
- if (!(elements = form.elements) || typeof elements.length !== "number"
- || elements.length === 0) {
- return;
- }
- jQuery(elements[0]).focus();
- };
- jQuery.json = jQuery.json || {};
- jQuery.json.parse = function(data) {
-
- return (new Function("return (" + data + ")"))();
- };
- jQuery.json.stringify = (function() {
-
- var escapeMap = {
- "\b" : ‘\\b‘,
- "\t" : ‘\\t‘,
- "\n" : ‘\\n‘,
- "\f" : ‘\\f‘,
- "\r" : ‘\\r‘,
- ‘"‘ : ‘\\"‘,
- "\\" : ‘\\\\‘
- };
-
-
- function encodeString(source) {
- if (/["\\\x00-\x1f]/.test(source)) {
- source = source.replace(/["\\\x00-\x1f]/g, function(match) {
- var c = escapeMap[match];
- if (c) {
- return c;
- }
- c = match.charCodeAt();
- return "\\u00" + Math.floor(c / 16).toString(16)
- + (c % 16).toString(16);
- });
- }
- return ‘"‘ + source + ‘"‘;
- }
-
-
- function encodeArray(source) {
- var result = [ "[" ], l = source.length, preComma, i, item;
-
- for (i = 0; i < l; i++) {
- item = source[i];
-
- switch (typeof item) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if (preComma) {
- result.push(‘,‘);
- }
- result.push(jQuery.json.stringify(item));
- preComma = 1;
- }
- }
- result.push("]");
- return result.join("");
- }
-
-
- function pad(source) {
- return source < 10 ? ‘0‘ + source : source;
- }
-
-
- function encodeDate(source) {
- return ‘"‘ + source.getFullYear() + "-" + pad(source.getMonth() + 1)
- + "-" + pad(source.getDate()) + "T" + pad(source.getHours())
- + ":" + pad(source.getMinutes()) + ":"
- + pad(source.getSeconds()) + ‘"‘;
- }
-
- return function(value) {
- switch (typeof value) {
- case ‘undefined‘:
- return ‘undefined‘;
-
- case ‘number‘:
- return isFinite(value) ? String(value) : "null";
-
- case ‘string‘:
- return encodeString(value);
-
- case ‘boolean‘:
- return String(value);
-
- default:
- if (value === null) {
- return ‘null‘;
- } else if (value instanceof Array) {
- return encodeArray(value);
- } else if (value instanceof Date) {
- return encodeDate(value);
- } else {
- var result = [ ‘{‘ ], encode = jQuery.json.stringify, preComma, item;
-
- for ( var key in value) {
- if (Object.prototype.hasOwnProperty.call(value, key)) {
- item = value[key];
- switch (typeof item) {
- case ‘undefined‘:
- case ‘unknown‘:
- case ‘function‘:
- break;
- default:
- if (preComma) {
- result.push(‘,‘);
- }
- preComma = 1;
- result.push(encode(key) + ‘:‘ + encode(item));
- }
- }
- }
- result.push(‘}‘);
- return result.join(‘‘);
- }
- }
- };
- })();
-
- jQuery.lang = jQuery.lang || {};
- jQuery.lang.isArray = function(source) {
- return ‘[object Array]‘ == Object.prototype.toString.call(source);
- };
- jQuery.lang.isBoolean = function(o) {
- return typeof o === ‘boolean‘;
- };
- jQuery.lang.isDate = function(o) {
-
- return {}.toString.call(o) === "[object Date]"
- && o.toString() !== ‘Invalid Date‘ && !isNaN(o);
- };
- jQuery.lang.isElement = function(source) {
- return !!(source && source.nodeName && source.nodeType == 1);
- };
- jQuery.lang.isFunction = function(source) {
-
- return ‘[object Function]‘ == Object.prototype.toString.call(source);
- };
- jQuery.lang.isNumber = function(source) {
- return ‘[object Number]‘ == Object.prototype.toString.call(source)
- && isFinite(source);
- };
- jQuery.lang.isObject = function(source) {
- return ‘function‘ == typeof source
- || !!(source && ‘object‘ == typeof source);
- };
- jQuery.lang.isString = function(source) {
- return ‘[object String]‘ == Object.prototype.toString.call(source);
- };
- jQuery.lang.toArray = function(source) {
- if (source === null || source === undefined)
- return [];
- if (jQuery.lang.isArray(source))
- return source;
-
-
- if (typeof source.length !== ‘number‘ || typeof source === ‘string‘
- || jQuery.lang.isFunction(source)) {
- return [ source ];
- }
-
-
- if (source.item) {
- var l = source.length, array = new Array(l);
- while (l--)
- array[l] = source[l];
- return array;
- }
-
- return [].slice.call(source);
- };
- jQuery.number = jQuery.number || {};
- jQuery.number.format = function(source, pattern) {
- var str = source.toString();
- var strInt;
- var strFloat;
- var formatInt;
- var formatFloat;
- if (/\./g.test(pattern)) {
- formatInt = pattern.split(‘.‘)[0];
- formatFloat = pattern.split(‘.‘)[1];
- } else {
- formatInt = pattern;
- formatFloat = null;
- }
- if (/\./g.test(str)) {
- if (formatFloat != null) {
- var tempFloat = Math.round(parseFloat(‘0.‘ + str.split(‘.‘)[1])
- * Math.pow(10, formatFloat.length))
- / Math.pow(10, formatFloat.length);
- strInt = (Math.floor(source) + Math.floor(tempFloat)).toString();
- strFloat = /\./g.test(tempFloat.toString()) ? tempFloat.toString()
- .split(‘.‘)[1] : ‘0‘;
- } else {
- strInt = Math.round(source).toString();
- strFloat = ‘0‘;
- }
- } else {
- strInt = str;
- strFloat = ‘0‘;
- }
- if (formatInt != null) {
- var outputInt = ‘‘;
- var zero = formatInt.match(/0*$/)[0].length;
- var comma = null;
- if (/,/g.test(formatInt)) {
- comma = formatInt.match(/,[^,]*/)[0].length - 1;
- }
- var newReg = new RegExp(‘(\\d{‘ + comma + ‘})‘, ‘g‘);
- if (strInt.length < zero) {
- outputInt = new Array(zero + 1).join(‘0‘) + strInt;
- outputInt = outputInt.substr(outputInt.length - zero, zero);
- } else {
- outputInt = strInt;
- }
- var outputInt = outputInt.substr(0, outputInt.length % comma)
- + outputInt.substring(outputInt.length % comma).replace(newReg,
- (comma != null ? ‘,‘ : ‘‘) + ‘$1‘);
- outputInt = outputInt.replace(/^,/, ‘‘);
- strInt = outputInt;
- }
- if (formatFloat != null) {
- var outputFloat = ‘‘;
- var zero = formatFloat.match(/^0*/)[0].length;
- if (strFloat.length < zero) {
- outputFloat = strFloat + new Array(zero + 1).join(‘0‘);
-
- var outputFloat1 = outputFloat.substring(0, zero);
- var outputFloat2 = outputFloat.substring(zero, formatFloat.length);
- outputFloat = outputFloat1 + outputFloat2.replace(/0*$/, ‘‘);
- } else {
- outputFloat = strFloat.substring(0, formatFloat.length);
- }
- strFloat = outputFloat;
- } else {
- if (pattern != ‘‘ || (pattern == ‘‘ && strFloat == ‘0‘)) {
- strFloat = ‘‘;
- }
- }
- return strInt + (strFloat == ‘‘ ? ‘‘ : ‘.‘ + strFloat);
- };
- jQuery.number.randomInt = function(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min);
- };
- jQuery.number.abs = Math.abs;
- jQuery.number.ceil = Math.ceil;
- jQuery.number.floor = Math.floor;
- jQuery.number.round = Math.round;
- jQuery.number.min = Math.min;
- jQuery.number.max = Math.max;
- jQuery.page = jQuery.page || {};
- jQuery.page.getScrollLeft = function() {
- var d = document;
- return window.pageXOffset || d.documentElement.scrollLeft
- || d.body.scrollLeft;
- };
- jQuery.page.getScrollTop = function() {
- var d = document;
- return window.pageYOffset || d.documentElement.scrollTop
- || d.body.scrollTop;
- };
- jQuery.page.getViewHeight = function() {
- var doc = document, client = doc.compatMode == ‘BackCompat‘ ? doc.body
- : doc.documentElement;
-
- return client.clientHeight;
- };
- jQuery.page.getViewWidth = function() {
- var doc = document, client = doc.compatMode == ‘BackCompat‘ ? doc.body
- : doc.documentElement;
-
- return client.clientWidth;
- };
-
- jQuery.page.loadJsFile = function(path) {
- var element = document.createElement(‘script‘);
-
- element.setAttribute(‘type‘, ‘text/javascript‘);
- element.setAttribute(‘src‘, path);
- element.setAttribute(‘defer‘, ‘defer‘);
-
- document.getElementsByTagName("head")[0].appendChild(element);
- };
-
- jQuery.page.loadCssFile = function(path) {
- var element = document.createElement("link");
-
- element.setAttribute("rel", "stylesheet");
- element.setAttribute("type", "text/css");
- element.setAttribute("href", path);
-
- document.getElementsByTagName("head")[0].appendChild(element);
- };
-
- jQuery.swf = jQuery.swf || {};
- jQuery.swf.version = (function() {
- var n = navigator;
- if (n.plugins && n.mimeTypes.length) {
- var plugin = n.plugins["Shockwave Flash"];
- if (plugin && plugin.description) {
- return plugin.description.replace(/([a-zA-Z]|\s)+/, "").replace(
- /(\s)+r/, ".")
- + ".0";
- }
- } else if (window.ActiveXObject && !window.opera) {
- for ( var i = 12; i >= 2; i--) {
- try {
- var c = new ActiveXObject(‘ShockwaveFlash.ShockwaveFlash.‘ + i);
- if (c) {
- var version = c.GetVariable("$version");
- return version.replace(/WIN/g, ‘‘).replace(/,/g, ‘.‘);
- }
- } catch (e) {
- }
- }
- }
- })();
- jQuery.swf.createHTML = function(options) {
- options = options || {};
- var version = jQuery.swf.version, needVersion = options[‘ver‘] || ‘6.0.0‘, vUnit1, vUnit2, i, k, len, item, tmpOpt = {}, encodeHTML = jQuery.string.encodeHTML;
-
-
- for (k in options) {
- tmpOpt[k] = options[k];
- }
- options = tmpOpt;
-
-
- if (version) {
- version = version.split(‘.‘);
- needVersion = needVersion.split(‘.‘);
- for (i = 0; i < 3; i++) {
- vUnit1 = parseInt(version[i], 10);
- vUnit2 = parseInt(needVersion[i], 10);
- if (vUnit2 < vUnit1) {
- break;
- } else if (vUnit2 > vUnit1) {
- return ‘‘;
- }
- }
- } else {
- return ‘‘;
- }
-
- var vars = options[‘vars‘], objProperties = [ ‘classid‘, ‘codebase‘, ‘id‘,
- ‘width‘, ‘height‘, ‘align‘ ];
-
-
- options[‘align‘] = options[‘align‘] || ‘middle‘;
- options[‘classid‘] = ‘clsid:d27cdb6e-ae6d-11cf-96b8-444553540000‘;
- options[‘codebase‘] = ‘http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0‘;
- options[‘movie‘] = options[‘url‘] || ‘‘;
- delete options[‘vars‘];
- delete options[‘url‘];
-
-
- if (‘string‘ == typeof vars) {
- options[‘flashvars‘] = vars;
- } else {
- var fvars = [];
- for (k in vars) {
- item = vars[k];
- fvars.push(k + "=" + encodeURIComponent(item));
- }
- options[‘flashvars‘] = fvars.join(‘&‘);
- }
-
-
- var str = [ ‘<object ‘ ];
- for (i = 0, len = objProperties.length; i < len; i++) {
- item = objProperties[i];
- str.push(‘ ‘, item, ‘="‘, encodeHTML(options[item]), ‘"‘);
- }
- str.push(‘>‘);
- var params = {
- ‘wmode‘ : 1,
- ‘scale‘ : 1,
- ‘quality‘ : 1,
- ‘play‘ : 1,
- ‘loop‘ : 1,
- ‘menu‘ : 1,
- ‘salign‘ : 1,
- ‘bgcolor‘ : 1,
- ‘base‘ : 1,
- ‘allowscriptaccess‘ : 1,
- ‘allownetworking‘ : 1,
- ‘allowfullscreen‘ : 1,
- ‘seamlesstabbing‘ : 1,
- ‘devicefont‘ : 1,
- ‘swliveconnect‘ : 1,
- ‘flashvars‘ : 1,
- ‘movie‘ : 1
- };
-
- for (k in options) {
- item = options[k];
- k = k.toLowerCase();
- if (params[k] && (item || item === false || item === 0)) {
- str.push(‘<param name="‘ + k + ‘" value="‘ + encodeHTML(item)
- + ‘" />‘);
- }
- }
-
-
- options[‘src‘] = options[‘movie‘];
- options[‘name‘] = options[‘id‘];
- delete options[‘id‘];
- delete options[‘movie‘];
- delete options[‘classid‘];
- delete options[‘codebase‘];
- options[‘type‘] = ‘application/x-shockwave-flash‘;
- options[‘pluginspage‘] = ‘http://www.macromedia.com/go/getflashplayer‘;
-
-
- str.push(‘<embed‘);
-
-
- var salign;
- for (k in options) {
- item = options[k];
- if (item || item === false || item === 0) {
- if ((new RegExp("^salign\x24", "i")).test(k)) {
- salign = item;
- continue;
- }
-
- str.push(‘ ‘, k, ‘="‘, encodeHTML(item), ‘"‘);
- }
- }
-
- if (salign) {
- str.push(‘ salign="‘, encodeHTML(salign), ‘"‘);
- }
- str.push(‘></embed></object>‘);
-
- return str.join(‘‘);
- };
- jQuery.swf.create = function(options, target) {
- options = options || {};
- var html = jQuery.swf.createHTML(options) || options[‘errorMessage‘] || ‘‘;
-
- if (target && ‘string‘ == typeof target) {
- target = document.getElementById(target);
- }
-
-
-
- $(target || document.body).append(html);
- };
经过压缩之后的代码
- var jQuery=jQuery||{};jQuery.string=jQuery.string||{};jQuery.string.decodeHTML=function(c){var d=String(c).replace(/"/g,‘"‘).replace(/</g,‘<‘).replace(/>/g,‘>‘).replace(/&/g,"&");return d.replace(/&#([\d]+);/g,function(a,b){return String.fromCharCode(parseInt(b,10))})};jQuery.string.encodeHTML=function(a){return String(a).replace(/&/g,‘&‘).replace(/</g,‘<‘).replace(/>/g,‘>‘).replace(/"/g,""").replace(/‘/g,"'")};jQuery.string.escapeReg=function(a){return String(a).replace(new RegExp("([.*+?^=!:\x24{}()|[\\]\/\\\\])","g"),‘\\\x241‘)};jQuery.string.format=function(d,e){d=String(d);var f=Array.prototype.slice.call(arguments,1),toString=Object.prototype.toString;if(f.length){f=f.length==1?(e!==null&&(/\[object Array\]|\[object Object\]/.test(toString.call(e)))?e:f):f;return d.replace(/#\{(.+?)\}/g,function(a,b){var c=f[b];if(‘[object Function]‘==toString.call(c)){c=c(b)}return(‘undefined‘==typeof c?‘‘:c)})}return d};jQuery.string.getByteLength=function(a){return String(a).replace(/[^\x00-\xff]/g,"ci").length};jQuery.string.stripTags=function(a){return String(a||‘‘).replace(/<[^>]+>/g,‘‘)};jQuery.string.subByte=function(a,b,c){a=String(a);c=c||‘‘;if(b<0||jQuery.string.getByteLength(a)<=b){return a+c}a=a.substr(0,b).replace(/([^\x00-\xff])/g,"\x241 ").substr(0,b).replace(/[^\x00-\xff]$/,"").replace(/([^\x00-\xff]) /g,"\x241");return a+c};jQuery.string.toCamelCase=function(b){if(b.indexOf(‘-‘)<0&&b.indexOf(‘_‘)<0){return b}return b.replace(/[-_][^-_]/g,function(a){return a.charAt(1).toUpperCase()})};jQuery.string.toHalfWidth=function(a){return String(a).replace(/[\uFF01-\uFF5E]/g,function(c){return String.fromCharCode(c.charCodeAt(0)-65248)}).replace(/\u3000/g," ")};jQuery.string.trim=jQuery.trim;jQuery.string.wbr=function(a){return String(a).replace(/(?:<[^>]+>)|(?:&#?[0-9a-z]{2,6};)|(.{1})/gi,‘$&<wbr>‘).replace(/><wbr>/g,‘>‘)};jQuery.string.filterFormat=function(d,e){var f=Array.prototype.slice.call(arguments,1),toString=Object.prototype.toString;if(f.length){f=f.length==1?(e!==null&&(/\[object Array\]|\[object Object\]/.test(toString.call(e)))?e:f):f;return d.replace(/#\{(.+?)\}/g,function(a,b){var c,replacer,i,len,func;if(!f)return‘‘;c=b.split("|");replacer=f[c[0]];if(‘[object Function]‘==toString.call(replacer)){replacer=replacer(c[0])}for(i=1,len=c.length;i<len;++i){func=jQuery.string.filterFormat[c[i]];if(‘[object Function]‘==toString.call(func)){replacer=func(replacer)}}return((‘undefined‘==typeof replacer||replacer===null)?‘‘:replacer)})}return d};jQuery.string.filterFormat.escapeJs=function(a){if(!a||‘string‘!=typeof a)return a;var i,len,charCode,ret=[];for(i=0,len=a.length;i<len;++i){charCode=a.charCodeAt(i);if(charCode>255){ret.push(a.charAt(i))}else{ret.push(‘\\x‘+charCode.toString(16))}}return ret.join(‘‘)};jQuery.string.filterFormat.escapeString=function(b){if(!b||‘string‘!=typeof b)return b;return b.replace(/["‘<>\\\/`]/g,function(a){return‘&#‘+a.charCodeAt(0)+‘;‘})};jQuery.string.filterFormat.toInt=function(a){return parseInt(a,10)||0};jQuery.array=jQuery.array||{};jQuery.array.contains=function(a,b){return(jQuery.array.indexOf(a,b)>=0)};jQuery.array.empty=function(a){a.length=0};jQuery.array.filter=function(a,b,c){var d=[],resultIndex=0,len=a.length,item,i;if(‘function‘==typeof b){for(i=0;i<len;i++){item=a[i];if(true===b.call(c||a,item,i)){d[resultIndex++]=item}}}return d};jQuery.array.find=function(a,b){var c,i,len=a.length;if(‘function‘==typeof b){for(i=0;i<len;i++){c=a[i];if(true===b.call(a,c,i)){return c}}}return null};jQuery.array.indexOf=function(a,b,c){var d=a.length,iterator=b;c=c|0;if(c<0){c=Math.max(0,d+c)}for(;c<d;c++){if(c in a&&a[c]===b){return c}}return-1};jQuery.array.lastIndexOf=function(a,b,c){var d=a.length;c=c|0;if(!c||c>=d){c=d-1}if(c<0){c+=d}for(;c>=0;c--){if(c in a&&a[c]===b){return c}}return-1};jQuery.array.remove=function(a,b){var c=a.length;while(c--){if(c in a&&a[c]===b){a.splice(c,1)}}return a};jQuery.array.removeAt=function(a,b){return a.splice(b,1)[0]};jQuery.array.unique=function(c,d){var e=c.length,result=c.slice(0),i,datum;if(‘function‘!=typeof d){d=function(a,b){return a===b}}while(--e>0){datum=result[e];i=e;while(i--){if(d(datum,result[i])){result.splice(e,1);break}}}return result};jQuery.cookie=jQuery.cookie||{};jQuery.cookie.isValidKey=function(a){return(new RegExp("^[^\\x00-\\x20\\x7f\\(\\)<>@,;:\\\\\\\"\\[\\]\\?=\\{\\}\\/\\u0080-\\uffff]+\x24")).test(a)};jQuery.cookie.get=function(a){var b=jQuery.cookie.getRaw(a);if(‘string‘==typeof b){b=decodeURIComponent(b);return b}return null};jQuery.cookie.getRaw=function(a){if(jQuery.cookie.isValidKey(a)){var b=new RegExp("(^| )"+a+"=([^;]*)(;|\x24)"),result=b.exec(document.cookie);if(result){return result[2]||null}}return null};jQuery.cookie.remove=function(a,b){b=b||{};b.expires=new Date(0);jQuery.cookie.setRaw(a,‘‘,b)};jQuery.cookie.set=function(a,b,c){jQuery.cookie.setRaw(a,encodeURIComponent(b),c)};jQuery.cookie.setRaw=function(a,b,c){if(!jQuery.cookie.isValidKey(a)){return}c=c||{};var d=c.expires;if(‘number‘==typeof c.expires){d=new Date();d.setTime(d.getTime()+c.expires)}document.cookie=a+"="+b+(c.path?"; path="+c.path:"")+(d?"; expires="+d.toGMTString():"")+(c.domain?"; domain="+c.domain:"")+(c.secure?"; secure":‘‘)};jQuery.date=jQuery.date||{};jQuery.date.format=function(c,d){if(‘string‘!=typeof d){return c.toString()}function replacer(a,b){d=d.replace(a,b)}var e=jQuery.number.pad,year=c.getFullYear(),month=c.getMonth()+1,date2=c.getDate(),hours=c.getHours(),minutes=c.getMinutes(),seconds=c.getSeconds();replacer(/yyyy/g,e(year,4));replacer(/yy/g,e(parseInt(year.toString().slice(2),10),2));replacer(/MM/g,e(month,2));replacer(/M/g,month);replacer(/dd/g,e(date2,2));replacer(/d/g,date2);replacer(/HH/g,e(hours,2));replacer(/H/g,hours);replacer(/hh/g,e(hours%12,2));replacer(/h/g,hours%12);replacer(/mm/g,e(minutes,2));replacer(/m/g,minutes);replacer(/ss/g,e(seconds,2));replacer(/s/g,seconds);return d};jQuery.date.parse=function(a){var b=new RegExp("^\\d+(\\-|\\/)\\d+(\\-|\\/)\\d+\x24");if(‘string‘==typeof a){if(b.test(a)||isNaN(Date.parse(a))){var d=a.split(/ |T/),d1=d.length>1?d[1].split(/[^\d]/):[0,0,0],d0=d[0].split(/[^\d]/);return new Date(d0[0]-0,d0[1]-1,d0[2]-0,d1[0]-0,d1[1]-0,d1[2]-0)}else{return new Date(a)}}return new Date()};jQuery.url=jQuery.url||{};jQuery.url.escapeSymbol=function(b){return String(b).replace(/[#%&+=\/\\\ \ \f\r\n\t]/g,function(a){return‘%‘+(0x100+a.charCodeAt()).toString(16).substring(1).toUpperCase()})};jQuery.url.getQueryValue=function(a,b){var c=new RegExp("(^|&|\\?|#)"+jQuery.string.escapeReg(b)+"=([^&#]*)(&|\x24|#)","");var d=a.match(c);if(d){return d[2]}return null};jQuery.url.jsonToQuery=function(c,d){var e=[],itemLen,replacer=d||function(a){return jQuery.url.escapeSymbol(a)};jQuery.object.each(c,function(a,b){if(jQuery.lang.isArray(a)){itemLen=a.length;while(itemLen--){e.push(b+‘=‘+replacer(a[itemLen],b))}}else{e.push(b+‘=‘+replacer(a,b))}});return e.join(‘&‘)};jQuery.url.queryToJson=function(a){var b=a.substr(a.lastIndexOf(‘?‘)+1),params=b.split(‘&‘),len=params.length,result={},i=0,key,value,item,param;for(;i<len;i++){if(!params[i]){continue}param=params[i].split(‘=‘);key=param[0];value=param[1];item=result[key];if(‘undefined‘==typeof item){result[key]=value}else if(jQuery.lang.isArray(item)){item.push(value)}else{result[key]=[item,value]}}return result};jQuery.url.getContextPath=function(){var a=String(window.document.location);return a.substring(0,a.lastIndexOf("/"))};jQuery.form=jQuery.form||{};jQuery.form.json=function(d,e){var f=d.elements,e=e||function(a,b){return a},data={},item,itemType,itemName,itemValue,opts,oi,oLen,oItem;function addData(a,b){var c=data[a];if(c){c.push||(data[a]=[c]);data[a].push(b)}else{data[a]=b}}for(var i=0,len=f.length;i<len;i++){item=f[i];itemName=item.name;if(!item.disabled&&itemName){itemType=item.type;itemValue=jQuery.url.escapeSymbol(item.value);switch(itemType){case‘radio‘:case‘checkbox‘:if(!item.checked){break}case‘textarea‘:case‘text‘:case‘password‘:case‘hidden‘:case‘file‘:case‘select-one‘:addData(itemName,e(itemValue,itemName));break;case‘select-multiple‘:opts=item.options;oLen=opts.length;for(oi=0;oi<oLen;oi++){oItem=opts[oi];if(oItem.selected){addData(itemName,e(oItem.value,itemName))}}break}}}return data};jQuery.form.serialize=