带有详尽注释的源代码: 

Javascript代码  一个jQuery扩展工具包_html
  1. var jQuery = jQuery || {};  
  2. // TODO  
  3. // ###################################string操作相关函数###################################  
  4. jQuery.string = jQuery.string || {};  
  5. /** 
  6.  * 对目标字符串进行html解码 
  7.  *  
  8.  * @name jQuery.string.decodeHTML 
  9.  * @function 
  10.  * @grammar jQuery.string.decodeHTML(source) 
  11.  * @param {string} 
  12.  *            source 目标字符串 
  13.  * @shortcut decodeHTML 
  14.  * @meta standard 
  15.  * @see jQuery.string.encodeHTML 
  16.  *  
  17.  * @returns {string} html解码后的字符串 
  18.  */  
  19. jQuery.string.decodeHTML = function(source) {  
  20.     var str = String(source).replace(/&quot;/g, '"').replace(/&lt;/g, '<')  
  21.             .replace(/&gt;/g, '>').replace(/&amp;/g, "&");  
  22.     // 处理转义的中文和实体字符  
  23.     return str.replace(/&#([\d]+);/g, function(_0, _1) {  
  24.         return String.fromCharCode(parseInt(_1, 10));  
  25.     });  
  26. };  
  27.   
  28. /** 
  29.  * 对目标字符串进行html编码 
  30.  *  
  31.  * @name jQuery.string.encodeHTML 
  32.  * @function 
  33.  * @grammar jQuery.string.encodeHTML(source) 
  34.  * @param {string} 
  35.  *            source 目标字符串 
  36.  * @remark 编码字符有5个:&<>"' 
  37.  * @shortcut encodeHTML 
  38.  * @meta standard 
  39.  * @see jQuery.string.decodeHTML 
  40.  *  
  41.  * @returns {string} html编码后的字符串 
  42.  */  
  43. jQuery.string.encodeHTML = function(source) {  
  44.     return String(source).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(  
  45.             />/g, '&gt;').replace(/"/g, "&quot;").replace(/'/g, "&#39;");  
  46. };  
  47. /** 
  48.  * 将目标字符串中可能会影响正则表达式构造的字符串进行转义。 
  49.  *  
  50.  * @name jQuery.string.escapeReg 
  51.  * @function 
  52.  * @grammar jQuery.string.escapeReg(source) 
  53.  * @param {string} 
  54.  *            source 目标字符串 
  55.  * @remark 给以下字符前加上“\”进行转义:.*+?^=!:${}()|[]/\ 
  56.  * @meta standard 
  57.  *  
  58.  * @returns {string} 转义后的字符串 
  59.  */  
  60. jQuery.string.escapeReg = function(source) {  
  61.     return String(source).replace(  
  62.             new RegExp("([.*+?^=!:\x24{}()|[\\]\/\\\\])", "g"), '\\\x241');  
  63. };  
  64. /** 
  65.  * 对目标字符串进行格式化 
  66.  *  
  67.  * @name jQuery.string.format 
  68.  * @function 
  69.  * @grammar jQuery.string.format(source, opts) 
  70.  * @param {string} 
  71.  *            source 目标字符串 
  72.  * @param {Object|string...} 
  73.  *            opts 提供相应数据的对象或多个字符串 
  74.  * @remark 
  75.  *  
  76.  * opts参数为“Object”时,替换目标字符串中的#{property name}部分。<br> 
  77.  * opts为“string...”时,替换目标字符串中的#{0}、#{1}...部分。 
  78.  *  
  79.  * @shortcut format 
  80.  * @meta standard 
  81.  *  
  82.  * @returns {string} 格式化后的字符串 
  83.  */  
  84. jQuery.string.format = function(source, opts) {  
  85.     source = String(source);  
  86.     var data = Array.prototype.slice.call(arguments, 1), toString = Object.prototype.toString;  
  87.     if (data.length) {  
  88.         data = data.length == 1 ?  
  89.         /* ie 下 Object.prototype.toString.call(null) == '[object Object]' */  
  90.         (opts !== null  
  91.                 && (/\[object Array\]|\[object Object\]/.test(toString  
  92.                         .call(opts))) ? opts : data) : data;  
  93.         return source.replace(/#\{(.+?)\}/g, function(match, key) {  
  94.             var replacer = data[key];  
  95.             // chrome 下 typeof /a/ == 'function'  
  96.             if ('[object Function]' == toString.call(replacer)) {  
  97.                 replacer = replacer(key);  
  98.             }  
  99.             return ('undefined' == typeof replacer ? '' : replacer);  
  100.         });  
  101.     }  
  102.     return source;  
  103. };  
  104. /** 
  105.  * 获取目标字符串在gbk编码下的字节长度 
  106.  *  
  107.  * @name jQuery.string.getByteLength 
  108.  * @function 
  109.  * @grammar jQuery.string.getByteLength(source) 
  110.  * @param {string} 
  111.  *            source 目标字符串 
  112.  * @remark 获取字符在gbk编码下的字节长度, 实现原理是认为大于127的就一定是双字节。如果字符超出gbk编码范围, 则这个计算不准确 
  113.  * @meta standard 
  114.  * @see jQuery.string.subByte 
  115.  *  
  116.  * @returns {number} 字节长度 
  117.  */  
  118. jQuery.string.getByteLength = function(source) {  
  119.     return String(source).replace(/[^\x00-\xff]/g, "ci").length;  
  120. };  
  121. /** 
  122.  * 去掉字符串中的html标签 
  123.  *  
  124.  * @function 
  125.  * @grammar jQuery.string.stripTags(source) 
  126.  * @param {string} 
  127.  *            source 要处理的字符串. 
  128.  * @return {String} 
  129.  */  
  130. jQuery.string.stripTags = function(source) {  
  131.     return String(source || '').replace(/<[^>]+>/g, '');  
  132. };  
  133. /** 
  134.  * 对目标字符串按gbk编码截取字节长度 
  135.  *  
  136.  * @name jQuery.string.subByte 
  137.  * @function 
  138.  * @grammar jQuery.string.subByte(source, length) 
  139.  * @param {string} 
  140.  *            source 目标字符串 
  141.  * @param {number} 
  142.  *            length 需要截取的字节长度 
  143.  * @param {string} 
  144.  *            [tail] 追加字符串,可选. 
  145.  * @remark 截取过程中,遇到半个汉字时,向下取整。 
  146.  * @see jQuery.string.getByteLength 
  147.  *  
  148.  * @returns {string} 字符串截取结果 
  149.  */  
  150. jQuery.string.subByte = function(source, length, tail) {  
  151.     source = String(source);  
  152.     tail = tail || '';  
  153.     if (length < 0 || jQuery.string.getByteLength(source) <= length) {  
  154.         return source + tail;  
  155.     }  
  156.   
  157.     // thanks 加宽提供优化方法  
  158.     source = source.substr(0, length).replace(/([^\x00-\xff])/g, "\x241 ")// 双字节字符替换成两个  
  159.     .substr(0, length)// 截取长度  
  160.     .replace(/[^\x00-\xff]$/, "")// 去掉临界双字节字符  
  161.     .replace(/([^\x00-\xff]) /g, "\x241");// 还原  
  162.     return source + tail;  
  163.   
  164. };  
  165. /** 
  166.  * 将目标字符串进行驼峰化处理 
  167.  *  
  168.  * @name jQuery.string.toCamelCase 
  169.  * @function 
  170.  * @grammar jQuery.string.toCamelCase(source) 
  171.  * @param {string} 
  172.  *            source 目标字符串 
  173.  * @remark 支持单词以“-_”分隔 
  174.  * @meta standard 
  175.  *  
  176.  * @returns {string} 驼峰化处理后的字符串 
  177.  */  
  178.   
  179. // todo:考虑以后去掉下划线支持?  
  180. jQuery.string.toCamelCase = function(source) {  
  181.     // 提前判断,提高getStyle等的效率 thanks xianwei  
  182.     if (source.indexOf('-') < 0 && source.indexOf('_') < 0) {  
  183.         return source;  
  184.     }  
  185.     return source.replace(/[-_][^-_]/g, function(match) {  
  186.         return match.charAt(1).toUpperCase();  
  187.     });  
  188. };  
  189. /** 
  190.  * 将目标字符串中常见全角字符转换成半角字符 
  191.  *  
  192.  * @name jQuery.string.toHalfWidth 
  193.  * @function 
  194.  * @grammar jQuery.string.toHalfWidth(source) 
  195.  * @param {string} 
  196.  *            source 目标字符串 
  197.  * @remark 
  198.  *  
  199.  * 将全角的字符转成半角, 将“&amp;#xFF01;”至“&amp;#xFF5E;”范围的全角转成“&amp;#33;”至“&amp;#126;”, 
  200.  * 还包括全角空格包括常见的全角数字/空格/字母, 用于需要同时支持全半角的转换, 具体转换列表如下("空格"未列出):<br> 
  201.  * <br> ! => !<br> " => "<br> # => #<br> $ => $<br> % => %<br> & => &<br> ' => '<br> ( => (<br> ) => )<br> * => *<br> + => +<br> , => ,<br> - => -<br> . => .<br> / => /<br> 
  202.  * 0 => 0<br> 
  203.  * 1 => 1<br> 
  204.  * 2 => 2<br> 
  205.  * 3 => 3<br> 
  206.  * 4 => 4<br> 
  207.  * 5 => 5<br> 
  208.  * 6 => 6<br> 
  209.  * 7 => 7<br> 
  210.  * 8 => 8<br> 
  211.  * 9 => 9<br> : => :<br> ; => ;<br> < => <<br> = => =<br> > => ><br> ? => ?<br> @ => @<br> 
  212.  * A => A<br> 
  213.  * B => B<br> 
  214.  * C => C<br> 
  215.  * D => D<br> 
  216.  * E => E<br> 
  217.  * F => F<br> 
  218.  * G => G<br> 
  219.  * H => H<br> 
  220.  * I => I<br> 
  221.  * J => J<br> 
  222.  * K => K<br> 
  223.  * L => L<br> 
  224.  * M => M<br> 
  225.  * N => N<br> 
  226.  * O => O<br> 
  227.  * P => P<br> 
  228.  * Q => Q<br> 
  229.  * R => R<br> 
  230.  * S => S<br> 
  231.  * T => T<br> 
  232.  * U => U<br> 
  233.  * V => V<br> 
  234.  * W => W<br> 
  235.  * X => X<br> 
  236.  * Y => Y<br> 
  237.  * Z => Z<br> [ => [<br> \ => \<br> ] => ]<br> ^ => ^<br> _ => _<br> ` => `<br> 
  238.  * a => a<br> 
  239.  * b => b<br> 
  240.  * c => c<br> 
  241.  * d => d<br> 
  242.  * e => e<br> 
  243.  * f => f<br> 
  244.  * g => g<br> 
  245.  * h => h<br> 
  246.  * i => i<br> 
  247.  * j => j<br> 
  248.  * k => k<br> 
  249.  * l => l<br> 
  250.  * m => m<br> 
  251.  * n => n<br> 
  252.  * o => o<br> 
  253.  * p => p<br> 
  254.  * q => q<br> 
  255.  * r => r<br> 
  256.  * s => s<br> 
  257.  * t => t<br> 
  258.  * u => u<br> 
  259.  * v => v<br> 
  260.  * w => w<br> 
  261.  * x => x<br> 
  262.  * y => y<br> 
  263.  * z => z<br> { => {<br> | => |<br> } => }<br> ~ => ~<br> 
  264.  *  
  265.  *  
  266.  * @returns {string} 转换后的字符串 
  267.  */  
  268.   
  269. jQuery.string.toHalfWidth = function(source) {  
  270.     return String(source).replace(/[\uFF01-\uFF5E]/g, function(c) {  
  271.         return String.fromCharCode(c.charCodeAt(0) - 65248);  
  272.     }).replace(/\u3000/g, " ");  
  273. };  
  274. /** 
  275.  * 去掉字符串两端的空格,跟jQuery.trim相同,具体请参照jQuery.trim方法 
  276.  */  
  277. jQuery.string.trim = jQuery.trim;  
  278. /** 
  279.  * 为目标字符串添加wbr软换行 
  280.  *  
  281.  * @name jQuery.string.wbr 
  282.  * @function 
  283.  * @grammar jQuery.string.wbr(source) 
  284.  * @param {string} 
  285.  *            source 目标字符串 
  286.  * @remark 
  287.  *  
  288.  * 1.支持html标签、属性以及字符实体。<br> 
  289.  * 2.任意字符中间都会插入wbr标签,对于过长的文本,会造成dom节点元素增多,占用浏览器资源。 
  290.  * 3.在opera下,浏览器默认css不会为wbr加上样式,导致没有换行效果,可以在css中加上 wbr:after { content: 
  291.  * "\00200B" } 解决此问题 
  292.  *  
  293.  *  
  294.  * @returns {string} 添加软换行后的字符串 
  295.  */  
  296. jQuery.string.wbr = function(source) {  
  297.     return String(source).replace(/(?:<[^>]+>)|(?:&#?[0-9a-z]{2,6};)|(.{1})/gi,  
  298.             '$&<wbr>').replace(/><wbr>/g, '>');  
  299. };  
  300. /** 
  301.  * 对目标字符串进行格式化,支持过滤 
  302.  *  
  303.  * @name jQuery.string.filterFormat 
  304.  * @function 
  305.  * @grammar jQuery.string.filterFormat(source, opts) 
  306.  * @param {string} 
  307.  *            source 目标字符串 
  308.  * @param {Object|string...} 
  309.  *            opts 提供相应数据的对象 
  310.  * @version 1.2 
  311.  * @remark 
  312.  *  
  313.  * 在 jQuery.string.format的基础上,增加了过滤功能. 目标字符串中的#{url|escapeUrl},<br/> 
  314.  * 会替换成jQuery.string.filterFormat["escapeUrl"](opts.url);<br/> 
  315.  * 过滤函数需要之前挂载在jQuery.string.filterFormat属性中. 
  316.  *  
  317.  * @see jQuery.string.format,jQuery.string.filterFormat.escapeJs,jQuery.string.filterFormat.escapeString,jQuery.string.filterFormat.toInt 
  318.  * @returns {string} 格式化后的字符串 
  319.  */  
  320. jQuery.string.filterFormat = function(source, opts) {  
  321.     var data = Array.prototype.slice.call(arguments, 1), toString = Object.prototype.toString;  
  322.     if (data.length) {  
  323.         data = data.length == 1 ?  
  324.         /* ie 下 Object.prototype.toString.call(null) == '[object Object]' */  
  325.         (opts !== null  
  326.                 && (/\[object Array\]|\[object Object\]/.test(toString  
  327.                         .call(opts))) ? opts : data) : data;  
  328.         return source.replace(/#\{(.+?)\}/g, function(match, key) {  
  329.             var filters, replacer, i, len, func;  
  330.             if (!data)  
  331.                 return '';  
  332.             filters = key.split("|");  
  333.             replacer = data[filters[0]];  
  334.             // chrome 下 typeof /a/ == 'function'  
  335.             if ('[object Function]' == toString.call(replacer)) {  
  336.                 replacer = replacer(filters[0]/* key */);  
  337.             }  
  338.             for (i = 1, len = filters.length; i < len; ++i) {  
  339.                 func = jQuery.string.filterFormat[filters[i]];  
  340.                 if ('[object Function]' == toString.call(func)) {  
  341.                     replacer = func(replacer);  
  342.                 }  
  343.             }  
  344.             return (('undefined' == typeof replacer || replacer === null) ? ''  
  345.                     : replacer);  
  346.         });  
  347.     }  
  348.     return source;  
  349. };  
  350. /** 
  351.  * 对js片段的字符做安全转义,编码低于255的都将转换成\x加16进制数 
  352.  *  
  353.  * @name jQuery.string.filterFormat.escapeJs 
  354.  * @function 
  355.  * @grammar jQuery.string.filterFormat.escapeJs(source) 
  356.  * @param {String} 
  357.  *            source 待转义字符串 
  358.  *  
  359.  * @see jQuery.string.filterFormat,jQuery.string.filterFormat.escapeString,jQuery.string.filterFormat.toInt 
  360.  * @version 1.2 
  361.  * @return {String} 转义之后的字符串 
  362.  */  
  363. jQuery.string.filterFormat.escapeJs = function(str) {  
  364.     if (!str || 'string' != typeof str)  
  365.         return str;  
  366.     var i, len, charCode, ret = [];  
  367.     for (i = 0, len = str.length; i < len; ++i) {  
  368.         charCode = str.charCodeAt(i);  
  369.         if (charCode > 255) {  
  370.             ret.push(str.charAt(i));  
  371.         } else {  
  372.             ret.push('\\x' + charCode.toString(16));  
  373.         }  
  374.     }  
  375.     return ret.join('');  
  376. };  
  377. /** 
  378.  * 对字符串做安全转义,转义字符包括: 单引号,双引号,左右小括号,斜杠,反斜杠,上引号. 
  379.  *  
  380.  * @name jQuery.string.filterFormat.escapeString 
  381.  * @function 
  382.  * @grammar jQuery.string.filterFormat.escapeString(source) 
  383.  * @param {String} 
  384.  *            source 待转义字符串 
  385.  *  
  386.  * @see jQuery.string.filterFormat,jQuery.string.filterFormat.escapeJs,jQuery.string.filterFormat.toInt 
  387.  * @version 1.2 
  388.  * @return {String} 转义之后的字符串 
  389.  */  
  390. jQuery.string.filterFormat.escapeString = function(str) {  
  391.     if (!str || 'string' != typeof str)  
  392.         return str;  
  393.     return str.replace(/["'<>\\\/`]/g, function($0) {  
  394.         return '&#' + $0.charCodeAt(0) + ';';  
  395.     });  
  396. };  
  397. /** 
  398.  * 对数字做安全转义,确保是十进制数字;否则返回0. 
  399.  *  
  400.  * @name jQuery.string.filterFormat.toInt 
  401.  * @function 
  402.  * @grammar jQuery.string.filterFormat.toInt(source) 
  403.  * @param {String} 
  404.  *            source 待转义字符串 
  405.  *  
  406.  * @see jQuery.string.filterFormat,jQuery.string.filterFormat.escapeJs,jQuery.string.filterFormat.escapeString 
  407.  * @version 1.2 
  408.  * @return {Number} 转义之后的数字 
  409.  */  
  410. jQuery.string.filterFormat.toInt = function(str) {  
  411.     return parseInt(str, 10) || 0;  
  412. };  
  413. // TODO  
  414. // ###################################array操作相关函数###################################  
  415. jQuery.array = jQuery.array || {};  
  416. /** 
  417.  * 判断一个数组中是否包含给定元素 
  418.  *  
  419.  * @name jQuery.array.contains 
  420.  * @function 
  421.  * @grammar jQuery.array.contains(source, obj) 
  422.  * @param {Array} 
  423.  *            source 需要判断的数组. 
  424.  * @param {Any} 
  425.  *            obj 要查找的元素. 
  426.  * @return {boolean} 判断结果. 
  427.  * @author berg 
  428.  */  
  429. jQuery.array.contains = function(source, obj) {  
  430.     return (jQuery.array.indexOf(source, obj) >= 0);  
  431. };  
  432. /** 
  433.  * 清空一个数组 
  434.  *  
  435.  * @name jQuery.array.empty 
  436.  * @function 
  437.  * @grammar jQuery.array.empty(source) 
  438.  * @param {Array} 
  439.  *            source 需要清空的数组. 
  440.  * @author berg 
  441.  */  
  442. jQuery.array.empty = function(source) {  
  443.     source.length = 0;  
  444. };  
  445. /** 
  446.  * 从数组中筛选符合条件的元素 
  447.  *  
  448.  * @name jQuery.array.filter 
  449.  * @function 
  450.  * @grammar jQuery.array.filter(source, iterator[, thisObject]) 
  451.  * @param {Array} 
  452.  *            source 需要筛选的数组 
  453.  * @param {Function} 
  454.  *            iterator 对每个数组元素进行筛选的函数,该函数有两个参数,第一个为数组元素,第二个为数组索引值,function 
  455.  *            (item, index),函数需要返回true或false 
  456.  * @param {Object} 
  457.  *            [thisObject] 函数调用时的this指针,如果没有此参数,默认是当前遍历的数组 
  458.  * @meta standard 
  459.  * @see jQuery.array.find 
  460.  *  
  461.  * @returns {Array} 符合条件的数组项集合 
  462.  */  
  463. jQuery.array.filter = function(source, iterator, thisObject) {  
  464.     var result = [], resultIndex = 0, len = source.length, item, i;  
  465.   
  466.     if ('function' == typeof iterator) {  
  467.         for (i = 0; i < len; i++) {  
  468.             item = source[i];  
  469.             // 和标准不符,see array.each  
  470.             if (true === iterator.call(thisObject || source, item, i)) {  
  471.                 // resultIndex用于优化对result.length的多次读取  
  472.                 result[resultIndex++] = item;  
  473.             }  
  474.         }  
  475.     }  
  476.   
  477.     return result;  
  478. };  
  479. /** 
  480.  * 从数组中寻找符合条件的第一个元素 
  481.  *  
  482.  * @name jQuery.array.find 
  483.  * @function 
  484.  * @grammar jQuery.array.find(source, iterator) 
  485.  * @param {Array} 
  486.  *            source 需要查找的数组 
  487.  * @param {Function} 
  488.  *            iterator 对每个数组元素进行查找的函数,该函数有两个参数,第一个为数组元素,第二个为数组索引值,function 
  489.  *            (item, index),函数需要返回true或false 
  490.  * @see jQuery.array.filter,jQuery.array.indexOf 
  491.  *  
  492.  * @returns {Any|null} 符合条件的第一个元素,找不到时返回null 
  493.  */  
  494. jQuery.array.find = function(source, iterator) {  
  495.     var item, i, len = source.length;  
  496.   
  497.     if ('function' == typeof iterator) {  
  498.         for (i = 0; i < len; i++) {  
  499.             item = source[i];  
  500.             if (true === iterator.call(source, item, i)) {  
  501.                 return item;  
  502.             }  
  503.         }  
  504.     }  
  505.   
  506.     return null;  
  507. };  
  508. /** 
  509.  * 查询数组中指定元素的索引位置 
  510.  *  
  511.  * @name jQuery.array.indexOf 
  512.  * @function 
  513.  * @grammar jQuery.array.indexOf(source, match[, fromIndex]) 
  514.  * @param {Array} 
  515.  *            source 需要查询的数组 
  516.  * @param {Any} 
  517.  *            match 查询项 
  518.  * @param {number} 
  519.  *            [fromIndex] 查询的起始位索引位置,如果为负数,则从source.length+fromIndex往后开始查找 
  520.  * @see jQuery.array.find,jQuery.array.lastIndexOf 
  521.  *  
  522.  * @returns {number} 指定元素的索引位置,查询不到时返回-1 
  523.  */  
  524. jQuery.array.indexOf = function(source, match, fromIndex) {  
  525.     var len = source.length, iterator = match;  
  526.   
  527.     fromIndex = fromIndex | 0;  
  528.     if (fromIndex < 0) {// 小于0  
  529.         fromIndex = Math.max(0, len + fromIndex);  
  530.     }  
  531.     for (; fromIndex < len; fromIndex++) {  
  532.         if (fromIndex in source && source[fromIndex] === match) {  
  533.             return fromIndex;  
  534.         }  
  535.     }  
  536.   
  537.     return -1;  
  538. };  
  539. /** 
  540.  * 从后往前,查询数组中指定元素的索引位置 
  541.  *  
  542.  * @name jQuery.array.lastIndexOf 
  543.  * @function 
  544.  * @grammar jQuery.array.lastIndexOf(source, match) 
  545.  * @param {Array} 
  546.  *            source 需要查询的数组 
  547.  * @param {Any} 
  548.  *            match 查询项 
  549.  * @param {number} 
  550.  *            [fromIndex] 查询的起始位索引位置,如果为负数,则从source.length+fromIndex往前开始查找 
  551.  * @see jQuery.array.indexOf 
  552.  *  
  553.  * @returns {number} 指定元素的索引位置,查询不到时返回-1 
  554.  */  
  555. jQuery.array.lastIndexOf = function(source, match, fromIndex) {  
  556.     var len = source.length;  
  557.   
  558.     fromIndex = fromIndex | 0;  
  559.   
  560.     if (!fromIndex || fromIndex >= len) {  
  561.         fromIndex = len - 1;  
  562.     }  
  563.     if (fromIndex < 0) {  
  564.         fromIndex += len;  
  565.     }  
  566.     for (; fromIndex >= 0; fromIndex--) {  
  567.         if (fromIndex in source && source[fromIndex] === match) {  
  568.             return fromIndex;  
  569.         }  
  570.     }  
  571.   
  572.     return -1;  
  573. };  
  574. /** 
  575.  * 移除数组中的项 
  576.  *  
  577.  * @name jQuery.array.remove 
  578.  * @function 
  579.  * @grammar jQuery.array.remove(source, match) 
  580.  * @param {Array} 
  581.  *            source 需要移除项的数组 
  582.  * @param {Any} 
  583.  *            match 要移除的项 
  584.  * @meta standard 
  585.  * @see jQuery.array.removeAt 
  586.  *  
  587.  * @returns {Array} 移除后的数组 
  588.  */  
  589. jQuery.array.remove = function(source, match) {  
  590.     var len = source.length;  
  591.   
  592.     while (len--) {  
  593.         if (len in source && source[len] === match) {  
  594.             source.splice(len, 1);  
  595.         }  
  596.     }  
  597.     return source;  
  598. };  
  599. /** 
  600.  * 移除数组中的项 
  601.  *  
  602.  * @name jQuery.array.removeAt 
  603.  * @function 
  604.  * @grammar jQuery.array.removeAt(source, index) 
  605.  * @param {Array} 
  606.  *            source 需要移除项的数组 
  607.  * @param {number} 
  608.  *            index 要移除项的索引位置 
  609.  * @see jQuery.array.remove 
  610.  * @meta standard 
  611.  * @returns {Any} 被移除的数组项 
  612.  */  
  613. jQuery.array.removeAt = function(source, index) {  
  614.     return source.splice(index, 1)[0];  
  615. };  
  616. /** 
  617.  * 过滤数组中的相同项。如果两个元素相同,会删除后一个元素。 
  618.  *  
  619.  * @name jQuery.array.unique 
  620.  * @function 
  621.  * @grammar jQuery.array.unique(source[, compareFn]) 
  622.  * @param {Array} 
  623.  *            source 需要过滤相同项的数组 
  624.  * @param {Function} 
  625.  *            [compareFn] 比较两个数组项是否相同的函数,两个数组项作为函数的参数。 
  626.  *  
  627.  * @returns {Array} 过滤后的新数组 
  628.  */  
  629. jQuery.array.unique = function(source, compareFn) {  
  630.     var len = source.length, result = source.slice(0), i, datum;  
  631.   
  632.     if ('function' != typeof compareFn) {  
  633.         compareFn = function(item1, item2) {  
  634.             return item1 === item2;  
  635.         };  
  636.     }  
  637.   
  638.     // 从后往前双重循环比较  
  639.     // 如果两个元素相同,删除后一个  
  640.     while (--len > 0) {  
  641.         datum = result[len];  
  642.         i = len;  
  643.         while (i--) {  
  644.             if (compareFn(datum, result[i])) {  
  645.                 result.splice(len, 1);  
  646.                 break;  
  647.             }  
  648.         }  
  649.     }  
  650.   
  651.     return result;  
  652. };  
  653. // TODO  
  654. // ###################################cookie操作相关函数###################################  
  655. jQuery.cookie = jQuery.cookie || {};  
  656. /** 
  657.  * 验证字符串是否合法的cookie键名 
  658.  *  
  659.  * @param {string} 
  660.  *            source 需要遍历的数组 
  661.  * @meta standard 
  662.  * @return {boolean} 是否合法的cookie键名 
  663.  */  
  664. jQuery.cookie.isValidKey = function(key) {  
  665.     // http://www.w3.org/Protocols/rfc2109/rfc2109  
  666.     // Syntax: General  
  667.     // The two state management headers, Set-Cookie and Cookie, have common  
  668.     // syntactic properties involving attribute-value pairs. The following  
  669.     // grammar uses the notation, and tokens DIGIT (decimal digits) and  
  670.     // token (informally, a sequence of non-special, non-white space  
  671.     // characters) from the HTTP/1.1 specification [RFC 2068] to describe  
  672.     // their syntax.  
  673.     // av-pairs = av-pair *(";" av-pair)  
  674.     // av-pair = attr ["=" value] ; optional value  
  675.     // attr = token  
  676.     // value = word  
  677.     // word = token | quoted-string  
  678.   
  679.     // http://www.ietf.org/rfc/rfc2068.txt  
  680.     // token = 1*<any CHAR except CTLs or tspecials>  
  681.     // CHAR = <any US-ASCII character (octets 0 - 127)>  
  682.     // CTL = <any US-ASCII control character  
  683.     // (octets 0 - 31) and DEL (127)>  
  684.     // tspecials = "(" | ")" | "<" | ">" | "@"  
  685.     // | "," | ";" | ":" | "\" | <">  
  686.     // | "/" | "[" | "]" | "?" | "="  
  687.     // | "{" | "}" | SP | HT  
  688.     // SP = <US-ASCII SP, space (32)>  
  689.     // HT = <US-ASCII HT, horizontal-tab (9)>  
  690.   
  691.     return (new RegExp(  
  692.             "^[^\\x00-\\x20\\x7f\\(\\)<>@,;:\\\\\\\"\\[\\]\\?=\\{\\}\\/\\u0080-\\uffff]+\x24"))  
  693.             .test(key);  
  694. };  
  695.   
  696. /** 
  697.  * 获取cookie的值,用decodeURIComponent进行解码 
  698.  *  
  699.  * @name jQuery.cookie.get 
  700.  * @function 
  701.  * @grammar jQuery.cookie.get(key) 
  702.  * @param {string} 
  703.  *            key 需要获取Cookie的键名 
  704.  * @remark <b>注意:</b>该方法会对cookie值进行decodeURIComponent解码。如果想获得cookie源字符串,请使用getRaw方法。 
  705.  * @meta standard 
  706.  * @see jQuery.cookie.getRaw,jQuery.cookie.set 
  707.  *  
  708.  * @returns {string|null} cookie的值,获取不到时返回null 
  709.  */  
  710. jQuery.cookie.get = function(key) {  
  711.     var value = jQuery.cookie.getRaw(key);  
  712.     if ('string' == typeof value) {  
  713.         value = decodeURIComponent(value);  
  714.         return value;  
  715.     }  
  716.     return null;  
  717. };  
  718. /** 
  719.  * 获取cookie的值,不对值进行解码 
  720.  *  
  721.  * @name jQuery.cookie.getRaw 
  722.  * @function 
  723.  * @grammar jQuery.cookie.getRaw(key) 
  724.  * @param {string} 
  725.  *            key 需要获取Cookie的键名 
  726.  * @meta standard 
  727.  * @see jQuery.cookie.get,jQuery.cookie.setRaw 
  728.  *  
  729.  * @returns {string|null} 获取的Cookie值,获取不到时返回null 
  730.  */  
  731. jQuery.cookie.getRaw = function(key) {  
  732.     if (jQuery.cookie.isValidKey(key)) {  
  733.         var reg = new RegExp("(^| )" + key + "=([^;]*)(;|\x24)"), result = reg  
  734.                 .exec(document.cookie);  
  735.   
  736.         if (result) {  
  737.             return result[2] || null;  
  738.         }  
  739.     }  
  740.   
  741.     return null;  
  742. };  
  743. /** 
  744.  * 删除cookie的值 
  745.  *  
  746.  * @name jQuery.cookie.remove 
  747.  * @function 
  748.  * @grammar jQuery.cookie.remove(key, options) 
  749.  * @param {string} 
  750.  *            key 需要删除Cookie的键名 
  751.  * @param {Object} 
  752.  *            options 需要删除的cookie对应的 path domain 等值 
  753.  * @meta standard 
  754.  */  
  755. jQuery.cookie.remove = function(key, options) {  
  756.     options = options || {};  
  757.     options.expires = new Date(0);  
  758.     jQuery.cookie.setRaw(key, '', options);  
  759. };  
  760. /** 
  761.  * 设置cookie的值,用encodeURIComponent进行编码 
  762.  *  
  763.  * @name jQuery.cookie.set 
  764.  * @function 
  765.  * @grammar jQuery.cookie.set(key, value[, options]) 
  766.  * @param {string} 
  767.  *            key 需要设置Cookie的键名 
  768.  * @param {string} 
  769.  *            value 需要设置Cookie的值 
  770.  * @param {Object} 
  771.  *            [options] 设置Cookie的其他可选参数 
  772.  * @config {string} [path] cookie路径 
  773.  * @config {Date|number} [expires] cookie过期时间,如果类型是数字的话, 单位是毫秒 
  774.  * @config {string} [domain] cookie域名 
  775.  * @config {string} [secure] cookie是否安全传输 
  776.  * @remark 
  777.  *  
  778.  * 1. <b>注意:</b>该方法会对cookie值进行encodeURIComponent编码。如果想设置cookie源字符串,请使用setRaw方法。<br> 
  779.  * <br> 
  780.  * 2. <b>options参数包括:</b><br> 
  781.  * path:cookie路径<br> 
  782.  * expires:cookie过期时间,Number型,单位为毫秒。<br> 
  783.  * domain:cookie域名<br> 
  784.  * secure:cookie是否安全传输 
  785.  *  
  786.  * @meta standard 
  787.  * @see jQuery.cookie.setRaw,jQuery.cookie.get 
  788.  */  
  789. jQuery.cookie.set = function(key, value, options) {  
  790.     jQuery.cookie.setRaw(key, encodeURIComponent(value), options);  
  791. };  
  792. /** 
  793.  * 设置cookie的值,不对值进行编码 
  794.  *  
  795.  * @name jQuery.cookie.setRaw 
  796.  * @function 
  797.  * @grammar jQuery.cookie.setRaw(key, value[, options]) 
  798.  * @param {string} 
  799.  *            key 需要设置Cookie的键名 
  800.  * @param {string} 
  801.  *            value 需要设置Cookie的值 
  802.  * @param {Object} 
  803.  *            [options] 设置Cookie的其他可选参数 
  804.  * @config {string} [path] cookie路径 
  805.  * @config {Date|number} [expires] cookie过期时间,如果类型是数字的话, 单位是毫秒 
  806.  * @config {string} [domain] cookie域名 
  807.  * @config {string} [secure] cookie是否安全传输 
  808.  * @remark 
  809.  *  
  810.  * <b>options参数包括:</b><br> 
  811.  * path:cookie路径<br> 
  812.  * expires:cookie过期时间,Number型,单位为毫秒。<br> 
  813.  * domain:cookie域名<br> 
  814.  * secure:cookie是否安全传输 
  815.  *  
  816.  * @meta standard 
  817.  * @see jQuery.cookie.set,jQuery.cookie.getRaw 
  818.  */  
  819. jQuery.cookie.setRaw = function(key, value, options) {  
  820.     if (!jQuery.cookie.isValidKey(key)) {  
  821.         return;  
  822.     }  
  823.   
  824.     options = options || {};  
  825.     // options.path = options.path || "/"; // meizz 20100402 设定一个初始值,方便后续的操作  
  826.     // berg 20100409 去掉,因为用户希望默认的path是当前路径,这样和浏览器对cookie的定义也是一致的  
  827.   
  828.     // 计算cookie过期时间  
  829.     var expires = options.expires;  
  830.     if ('number' == typeof options.expires) {  
  831.         expires = new Date();  
  832.         expires.setTime(expires.getTime() + options.expires);  
  833.     }  
  834.   
  835.     document.cookie = key + "=" + value  
  836.             + (options.path ? "; path=" + options.path : "")  
  837.             + (expires ? "; expires=" + expires.toGMTString() : "")  
  838.             + (options.domain ? "; domain=" + options.domain : "")  
  839.             + (options.secure ? "; secure" : '');  
  840. };  
  841. // TODO  
  842. // ###################################date操作相关函数###################################  
  843. jQuery.date = jQuery.date || {};  
  844. /** 
  845.  * 对目标日期对象进行格式化 
  846.  *  
  847.  * @name jQuery.date.format 
  848.  * @function 
  849.  * @grammar jQuery.date.format(source, pattern) 
  850.  * @param {Date} 
  851.  *            source 目标日期对象 
  852.  * @param {string} 
  853.  *            pattern 日期格式化规则 
  854.  * @remark 
  855.  *  
  856.  * <b>格式表达式,变量含义:</b><br> 
  857.  * <br> 
  858.  * hh: 带 0 补齐的两位 12 进制时表示<br> 
  859.  * h: 不带 0 补齐的 12 进制时表示<br> 
  860.  * HH: 带 0 补齐的两位 24 进制时表示<br> 
  861.  * H: 不带 0 补齐的 24 进制时表示<br> 
  862.  * mm: 带 0 补齐两位分表示<br> 
  863.  * m: 不带 0 补齐分表示<br> 
  864.  * ss: 带 0 补齐两位秒表示<br> 
  865.  * s: 不带 0 补齐秒表示<br> 
  866.  * yyyy: 带 0 补齐的四位年表示<br> 
  867.  * yy: 带 0 补齐的两位年表示<br> 
  868.  * MM: 带 0 补齐的两位月表示<br> 
  869.  * M: 不带 0 补齐的月表示<br> 
  870.  * dd: 带 0 补齐的两位日表示<br> 
  871.  * d: 不带 0 补齐的日表示 
  872.  *  
  873.  *  
  874.  * @returns {string} 格式化后的字符串 
  875.  */  
  876.   
  877. jQuery.date.format = function(source, pattern) {  
  878.     if ('string' != typeof pattern) {  
  879.         return source.toString();  
  880.     }  
  881.   
  882.     function replacer(patternPart, result) {  
  883.         pattern = pattern.replace(patternPart, result);  
  884.     }  
  885.   
  886.     var pad = jQuery.number.pad, year = source.getFullYear(), month = source  
  887.             .getMonth() + 1, date2 = source.getDate(), hours = source  
  888.             .getHours(), minutes = source.getMinutes(), seconds = source  
  889.             .getSeconds();  
  890.   
  891.     replacer(/yyyy/g, pad(year, 4));  
  892.     replacer(/yy/g, pad(parseInt(year.toString().slice(2), 10), 2));  
  893.     replacer(/MM/g, pad(month, 2));  
  894.     replacer(/M/g, month);  
  895.     replacer(/dd/g, pad(date2, 2));  
  896.     replacer(/d/g, date2);  
  897.   
  898.     replacer(/HH/g, pad(hours, 2));  
  899.     replacer(/H/g, hours);  
  900.     replacer(/hh/g, pad(hours % 12, 2));  
  901.     replacer(/h/g, hours % 12);  
  902.     replacer(/mm/g, pad(minutes, 2));  
  903.     replacer(/m/g, minutes);  
  904.     replacer(/ss/g, pad(seconds, 2));  
  905.     replacer(/s/g, seconds);  
  906.   
  907.     return pattern;  
  908. };  
  909. /** 
  910.  * 将目标字符串转换成日期对象 
  911.  *  
  912.  * @name jQuery.date.parse 
  913.  * @function 
  914.  * @grammar jQuery.date.parse(source) 
  915.  * @param {string} 
  916.  *            source 目标字符串 
  917.  * @remark 
  918.  *  
  919.  * 对于目标字符串,下面这些规则决定了 parse 方法能够成功地解析: <br> 
  920.  * <ol> 
  921.  * <li>短日期可以使用“/”或“-”作为日期分隔符,但是必须用月/日/年的格式来表示,例如"7/20/96"。</li> 
  922.  * <li>以 "July 10 1995" 形式表示的长日期中的年、月、日可以按任何顺序排列,年份值可以用 2 位数字表示也可以用 4 
  923.  * 位数字表示。如果使用 2 位数字来表示年份,那么该年份必须大于或等于 70。 </li> 
  924.  * <li>括号中的任何文本都被视为注释。这些括号可以嵌套使用。 </li> 
  925.  * <li>逗号和空格被视为分隔符。允许使用多个分隔符。 </li> 
  926.  * <li>月和日的名称必须具有两个或两个以上的字符。如果两个字符所组成的名称不是独一无二的,那么该名称就被解析成最后一个符合条件的月或日。例如,"Ju" 
  927.  * 被解释为七月而不是六月。 </li> 
  928.  * <li>在所提供的日期中,如果所指定的星期几的值与按照该日期中剩余部分所确定的星期几的值不符合,那么该指定值就会被忽略。例如,尽管 1996 年 11 
  929.  * 月 9 日实际上是星期五,"Tuesday November 9 1996" 也还是可以被接受并进行解析的。但是结果 date 对象中包含的是 
  930.  * "Friday November 9 1996"。 </li> 
  931.  * <li>JScript 处理所有的标准时区,以及全球标准时间 (UTC) 和格林威治标准时间 (GMT)。</li> 
  932.  * <li>小时、分钟、和秒钟之间用冒号分隔,尽管不是这三项都需要指明。"10:"、"10:11"、和 "10:11:12" 都是有效的。 </li> 
  933.  * <li>如果使用 24 小时计时的时钟,那么为中午 12 点之后的时间指定 "PM" 是错误的。例如 "23:15 PM" 就是错误的。</li> 
  934.  * <li>包含无效日期的字符串是错误的。例如,一个包含有两个年份或两个月份的字符串就是错误的。</li> 
  935.  * </ol> 
  936.  *  
  937.  *  
  938.  * @returns {Date} 转换后的日期对象 
  939.  */  
  940.   
  941. jQuery.date.parse = function(source) {  
  942.     var reg = new RegExp("^\\d+(\\-|\\/)\\d+(\\-|\\/)\\d+\x24");  
  943.     if ('string' == typeof source) {  
  944.         if (reg.test(source) || isNaN(Date.parse(source))) {  
  945.             var d = source.split(/ |T/), d1 = d.length > 1 ? d[1]  
  946.                     .split(/[^\d]/) : [ 0, 0, 0 ], d0 = d[0].split(/[^\d]/);  
  947.             return new Date(d0[0] - 0, d0[1] - 1, d0[2] - 0, d1[0] - 0,  
  948.                     d1[1] - 0, d1[2] - 0);  
  949.         } else {  
  950.             return new Date(source);  
  951.         }  
  952.     }  
  953.   
  954.     return new Date();  
  955. };  
  956.   
  957. // TODO  
  958. // ###################################url操作相关函数###################################  
  959. jQuery.url = jQuery.url || {};  
  960. /** 
  961.  * 对字符串进行%#&+=以及和\s匹配的所有字符进行url转义 
  962.  *  
  963.  * @name jQuery.url.escapeSymbol 
  964.  * @function 
  965.  * @grammar jQuery.url.escapeSymbol(source) 
  966.  * @param {string} 
  967.  *            source 需要转义的字符串. 
  968.  * @return {string} 转义之后的字符串. 
  969.  * @remark 用于get请求转义。在服务器只接受gbk,并且页面是gbk编码时,可以经过本转义后直接发get请求。 
  970.  *  
  971.  * @return {string} 转义后的字符串 
  972.  */  
  973. jQuery.url.escapeSymbol = function(source) {  
  974.   
  975.     // 之前使用\s来匹配任意空白符  
  976.     // 发现在ie下无法匹配中文全角空格和纵向指标符\v,所以改\s为\f\r\n\t\v以及中文全角空格和英文空格  
  977.     // 但是由于ie本身不支持纵向指标符\v,故去掉对其的匹配,保证各浏览器下效果一致  
  978.     return String(source).replace(  
  979.             /[#%&+=\/\\\ \ \f\r\n\t]/g,  
  980.             function(all) {  
  981.                 return '%'  
  982.                         + (0x100 + all.charCodeAt()).toString(16).substring(1)  
  983.                                 .toUpperCase();  
  984.             });  
  985. };  
  986. /** 
  987.  * 根据参数名从目标URL中获取参数值 
  988.  *  
  989.  * @name jQuery.url.getQueryValue 
  990.  * @function 
  991.  * @grammar jQuery.url.getQueryValue(url, key) 
  992.  * @param {string} 
  993.  *            url 目标URL 
  994.  * @param {string} 
  995.  *            key 要获取的参数名 
  996.  * @meta standard 
  997.  * @see jQuery.url.jsonToQuery 
  998.  *  
  999.  * @returns {string|null} - 获取的参数值,其中URI编码后的字符不会被解码,获取不到时返回null 
  1000.  */  
  1001. jQuery.url.getQueryValue = function(url, key) {  
  1002.     var reg = new RegExp("(^|&|\\?|#)" + jQuery.string.escapeReg(key)  
  1003.             + "=([^&#]*)(&|\x24|#)", "");  
  1004.     var match = url.match(reg);  
  1005.     if (match) {  
  1006.         return match[2];  
  1007.     }  
  1008.   
  1009.     return null;  
  1010. };  
  1011. /** 
  1012.  * 将json对象解析成query字符串 
  1013.  *  
  1014.  * @name jQuery.url.jsonToQuery 
  1015.  * @function 
  1016.  * @grammar jQuery.url.jsonToQuery(json[, replacer]) 
  1017.  * @param {Object} 
  1018.  *            json 需要解析的json对象 
  1019.  * @param {Function=} 
  1020.  *            replacer_opt 对值进行特殊处理的函数,function (value, key) 
  1021.  * @see jQuery.url.queryToJson,jQuery.url.getQueryValue 
  1022.  *  
  1023.  * @return {string} - 解析结果字符串,其中值将被URI编码,{a:'&1 '} ==> "a=%261%20"。 
  1024.  */  
  1025. jQuery.url.jsonToQuery = function(json, replacer_opt) {  
  1026.     var result = [], itemLen, replacer = replacer_opt || function(value) {  
  1027.         return jQuery.url.escapeSymbol(value);  
  1028.     };  
  1029.   
  1030.     jQuery.object.each(json, function(item, key) {  
  1031.         // 这里只考虑item为数组、字符串、数字类型,不考虑嵌套的object  
  1032.         if (jQuery.lang.isArray(item)) {  
  1033.             itemLen = item.length;  
  1034.             // value的值需要encodeURIComponent转义吗?  
  1035.             // FIXED 优化了escapeSymbol函数  
  1036.             while (itemLen--) {  
  1037.                 result.push(key + '=' + replacer(item[itemLen], key));  
  1038.             }  
  1039.         } else {  
  1040.             result.push(key + '=' + replacer(item, key));  
  1041.         }  
  1042.     });  
  1043.   
  1044.     return result.join('&');  
  1045. };  
  1046. /** 
  1047.  * 解析目标URL中的参数成json对象 
  1048.  *  
  1049.  * @name jQuery.url.queryToJson 
  1050.  * @function 
  1051.  * @grammar jQuery.url.queryToJson(url) 
  1052.  * @param {string} 
  1053.  *            url 目标URL 
  1054.  * @see jQuery.url.jsonToQuery 
  1055.  *  
  1056.  * @returns {Object} - 解析为结果对象,其中URI编码后的字符不会被解码,'a=%20' ==> {a:'%20'}。 
  1057.  */  
  1058. jQuery.url.queryToJson = function(url) {  
  1059.     var query = url.substr(url.lastIndexOf('?') + 1), params = query.split('&'), len = params.length, result = {}, i = 0, key, value, item, param;  
  1060.   
  1061.     for (; i < len; i++) {  
  1062.         if (!params[i]) {  
  1063.             continue;  
  1064.         }  
  1065.         param = params[i].split('=');  
  1066.         key = param[0];  
  1067.         value = param[1];  
  1068.   
  1069.         item = result[key];  
  1070.         if ('undefined' == typeof item) {  
  1071.             result[key] = value;  
  1072.         } else if (jQuery.lang.isArray(item)) {  
  1073.             item.push(value);  
  1074.         } else { // 这里只可能是string了  
  1075.             result[key] = [ item, value ];  
  1076.         }  
  1077.     }  
  1078.   
  1079.     return result;  
  1080. };  
  1081. // TODO这个函数的实现方式还有待检验  
  1082. jQuery.url.getContextPath = function() {  
  1083.     var path = String(window.document.location);  
  1084.     return path.substring(0, path.lastIndexOf("/"));  
  1085. };  
  1086. // TODO  
  1087. // ###################################form操作相关函数###################################  
  1088. jQuery.form = jQuery.form || {};  
  1089. /** 
  1090.  * josn化表单数据 
  1091.  *  
  1092.  * @name jQuery.form.json 
  1093.  * @function 
  1094.  * @grammar jQuery.form.json(form[, replacer]) 
  1095.  * @param {HTMLFormElement} 
  1096.  *            form 需要提交的表单元素 
  1097.  * @param {Function} 
  1098.  *            replacer 对参数值特殊处理的函数,replacer(string value, string key) 
  1099.  *  
  1100.  * @returns {data} 表单数据js对象 
  1101.  */  
  1102. jQuery.form.json = function(form, replacer) {  
  1103.     var elements = form.elements, replacer = replacer || function(value, name) {  
  1104.         return value;  
  1105.     }, data = {}, item, itemType, itemName, itemValue, opts, oi, oLen, oItem;  
  1106.   
  1107.     /** 
  1108.      * 向缓冲区添加参数数据 
  1109.      *  
  1110.      * @private 
  1111.      */  
  1112.     function addData(name, value) {  
  1113.         var val = data[name];  
  1114.         if (val) {  
  1115.             val.push || (data[name] = [ val ]);  
  1116.             data[name].push(value);  
  1117.         } else {  
  1118.             data[name] = value;  
  1119.         }  
  1120.     }  
  1121.   
  1122.     for ( var i = 0, len = elements.length; i < len; i++) {  
  1123.         item = elements[i];  
  1124.         itemName = item.name;  
  1125.   
  1126.         // 处理:可用并包含表单name的表单项  
  1127.         if (!item.disabled && itemName) {  
  1128.             itemType = item.type;  
  1129.             itemValue = jQuery.url.escapeSymbol(item.value);  
  1130.   
  1131.             switch (itemType) {  
  1132.             // radio和checkbox被选中时,拼装queryString数据  
  1133.             case 'radio':  
  1134.             case 'checkbox':  
  1135.                 if (!item.checked) {  
  1136.                     break;  
  1137.                 }  
  1138.   
  1139.                 // 默认类型,拼装queryString数据  
  1140.             case 'textarea':  
  1141.             case 'text':  
  1142.             case 'password':  
  1143.             case 'hidden':  
  1144.             case 'file':  
  1145.             case 'select-one':  
  1146.                 addData(itemName, replacer(itemValue, itemName));  
  1147.                 break;  
  1148.   
  1149.             // 多行选中select,拼装所有选中的数据  
  1150.             case 'select-multiple':  
  1151.                 opts = item.options;  
  1152.                 oLen = opts.length;  
  1153.                 for (oi = 0; oi < oLen; oi++) {  
  1154.                     oItem = opts[oi];  
  1155.                     if (oItem.selected) {  
  1156.                         addData(itemName, replacer(oItem.value, itemName));  
  1157.                     }  
  1158.                 }  
  1159.                 break;  
  1160.             }  
  1161.         }  
  1162.     }  
  1163.   
  1164.     return data;  
  1165. };  
  1166. /** 
  1167.  * 序列化表单数据 
  1168.  *  
  1169.  * @name jQuery.form.serialize 
  1170.  * @function 
  1171.  * @grammar jQuery.form.serialize(form[, replacer]) 
  1172.  * @param {HTMLFormElement} 
  1173.  *            form 需要提交的表单元素 
  1174.  * @param {Function} 
  1175.  *            replacer 对参数值特殊处理的函数,replacer(string value, string key) 
  1176.  *  
  1177.  * @returns {data} 表单数据数组 
  1178.  */  
  1179. jQuery.form.serialize = function(form, replacer) {  
  1180.     var elements = form.elements, replacer = replacer || function(value, name) {  
  1181.         return value;  
  1182.     }, data = [], item, itemType, itemName, itemValue, opts, oi, oLen, oItem;  
  1183.   
  1184.     /** 
  1185.      * 向缓冲区添加参数数据 
  1186.      *  
  1187.      * @private 
  1188.      */  
  1189.     function addData(name, value) {  
  1190.         data.push(name + '=' + value);  
  1191.     }  
  1192.   
  1193.     for ( var i = 0, len = elements.length; i < len; i++) {  
  1194.         item = elements[i];  
  1195.         itemName = item.name;  
  1196.   
  1197.         // 处理:可用并包含表单name的表单项  
  1198.         if (!item.disabled && itemName) {  
  1199.             itemType = item.type;  
  1200.             itemValue = jQuery.url.escapeSymbol(item.value);  
  1201.   
  1202.             switch (itemType) {  
  1203.             // radio和checkbox被选中时,拼装queryString数据  
  1204.             case 'radio':  
  1205.             case 'checkbox':  
  1206.                 if (!item.checked) {  
  1207.                     break;  
  1208.                 }  
  1209.   
  1210.                 // 默认类型,拼装queryString数据  
  1211.             case 'textarea':  
  1212.             case 'text':  
  1213.             case 'password':  
  1214.             case 'hidden':  
  1215.             case 'file':  
  1216.             case 'select-one':  
  1217.                 addData(itemName, replacer(itemValue, itemName));  
  1218.                 break;  
  1219.   
  1220.             // 多行选中select,拼装所有选中的数据  
  1221.             case 'select-multiple':  
  1222.                 opts = item.options;  
  1223.                 oLen = opts.length;  
  1224.                 for (oi = 0; oi < oLen; oi++) {  
  1225.                     oItem = opts[oi];  
  1226.                     if (oItem.selected) {  
  1227.                         addData(itemName, replacer(oItem.value, itemName));  
  1228.                     }  
  1229.                 }  
  1230.                 break;  
  1231.             }  
  1232.         }  
  1233.     }  
  1234.   
  1235.     return data;  
  1236. };  
  1237. /** 
  1238.  * 找到表单的第一个元素,未找到则返回null 
  1239.  *  
  1240.  * @name jQuery.form.findFirstElement 
  1241.  * @function 
  1242.  * @grammar jQuery.form.findFirstElement(form) 
  1243.  * @param {HTMLFormElement} 
  1244.  *            form 需要查找的表单元素 
  1245.  * @returns {data} 表单的第一个元素 
  1246.  */  
  1247. jQuery.form.findFirstElement = function(form) {  
  1248.     var elements = null;  
  1249.     if (!(elements = form.elements) || typeof elements.length !== "number"  
  1250.             || elements.length === 0) {  
  1251.         return null;  
  1252.     }  
  1253.     return elements[0];  
  1254. };  
  1255. /** 
  1256.  * 为表单的第一个元素设置焦点,找不到这个元素则什么都不做 
  1257.  *  
  1258.  * @name jQuery.form.focusFirstElement 
  1259.  * @function 
  1260.  * @grammar jQuery.form.focusFirstElement(form) 
  1261.  * @param {HTMLFormElement} 
  1262.  *            form 需要查找的表单元素 
  1263.  */  
  1264. jQuery.form.focusFirstElement = function(form) {  
  1265.     var elements = null;  
  1266.     if (!(elements = form.elements) || typeof elements.length !== "number"  
  1267.             || elements.length === 0) {  
  1268.         return;  
  1269.     }  
  1270.     jQuery(elements[0]).focus();  
  1271. };  
  1272. // TODO  
  1273. // ###################################json操作相关函数###################################  
  1274. jQuery.json = jQuery.json || {};  
  1275. /** 
  1276.  * 将字符串解析成json对象。注:不会自动祛除空格 
  1277.  *  
  1278.  * @name jQuery.json.parse 
  1279.  * @function 
  1280.  * @grammar jQuery.json.parse(data) 
  1281.  * @param {string} 
  1282.  *            source 需要解析的字符串 
  1283.  * @remark 该方法的实现与ecma-262第五版中规定的JSON.parse不同,暂时只支持传入一个参数。后续会进行功能丰富。 
  1284.  * @meta standard 
  1285.  * @see jQuery.json.stringify,jQuery.json.decode 
  1286.  *  
  1287.  * @returns {JSON} 解析结果json对象 
  1288.  */  
  1289. jQuery.json.parse = function(data) {  
  1290.     // 2010/12/09:更新至不使用原生parse,不检测用户输入是否正确  
  1291.     return (new Function("return (" + data + ")"))();  
  1292. };  
  1293. /** 
  1294.  * 将json对象序列化 
  1295.  *  
  1296.  * @name jQuery.json.stringify 
  1297.  * @function 
  1298.  * @grammar jQuery.json.stringify(value) 
  1299.  * @param {JSON} 
  1300.  *            value 需要序列化的json对象 
  1301.  * @remark 该方法的实现与ecma-262第五版中规定的JSON.stringify不同,暂时只支持传入一个参数。后续会进行功能丰富。 
  1302.  * @meta standard 
  1303.  * @see jQuery.json.parse,jQuery.json.encode 
  1304.  *  
  1305.  * @returns {string} 序列化后的字符串 
  1306.  */  
  1307. jQuery.json.stringify = (function() {  
  1308.     /** 
  1309.      * 字符串处理时需要转义的字符表 
  1310.      *  
  1311.      * @private 
  1312.      */  
  1313.     var escapeMap = {  
  1314.         "\b" : '\\b',  
  1315.         "\t" : '\\t',  
  1316.         "\n" : '\\n',  
  1317.         "\f" : '\\f',  
  1318.         "\r" : '\\r',  
  1319.         '"' : '\\"',  
  1320.         "\\" : '\\\\'  
  1321.     };  
  1322.   
  1323.     /** 
  1324.      * 字符串序列化 
  1325.      *  
  1326.      * @private 
  1327.      */  
  1328.     function encodeString(source) {  
  1329.         if (/["\\\x00-\x1f]/.test(source)) {  
  1330.             source = source.replace(/["\\\x00-\x1f]/g, function(match) {  
  1331.                 var c = escapeMap[match];  
  1332.                 if (c) {  
  1333.                     return c;  
  1334.                 }  
  1335.                 c = match.charCodeAt();  
  1336.                 return "\\u00" + Math.floor(c / 16).toString(16)  
  1337.                         + (c % 16).toString(16);  
  1338.             });  
  1339.         }  
  1340.         return '"' + source + '"';  
  1341.     }  
  1342.   
  1343.     /** 
  1344.      * 数组序列化 
  1345.      *  
  1346.      * @private 
  1347.      */  
  1348.     function encodeArray(source) {  
  1349.         var result = [ "[" ], l = source.length, preComma, i, item;  
  1350.   
  1351.         for (i = 0; i < l; i++) {  
  1352.             item = source[i];  
  1353.   
  1354.             switch (typeof item) {  
  1355.             case "undefined":  
  1356.             case "function":  
  1357.             case "unknown":  
  1358.                 break;  
  1359.             default:  
  1360.                 if (preComma) {  
  1361.                     result.push(',');  
  1362.                 }  
  1363.                 result.push(jQuery.json.stringify(item));  
  1364.                 preComma = 1;  
  1365.             }  
  1366.         }  
  1367.         result.push("]");  
  1368.         return result.join("");  
  1369.     }  
  1370.   
  1371.     /** 
  1372.      * 处理日期序列化时的补零 
  1373.      *  
  1374.      * @private 
  1375.      */  
  1376.     function pad(source) {  
  1377.         return source < 10 ? '0' + source : source;  
  1378.     }  
  1379.   
  1380.     /** 
  1381.      * 日期序列化 
  1382.      *  
  1383.      * @private 
  1384.      */  
  1385.     function encodeDate(source) {  
  1386.         return '"' + source.getFullYear() + "-" + pad(source.getMonth() + 1)  
  1387.                 + "-" + pad(source.getDate()) + "T" + pad(source.getHours())  
  1388.                 + ":" + pad(source.getMinutes()) + ":"  
  1389.                 + pad(source.getSeconds()) + '"';  
  1390.     }  
  1391.   
  1392.     return function(value) {  
  1393.         switch (typeof value) {  
  1394.         case 'undefined':  
  1395.             return 'undefined';  
  1396.   
  1397.         case 'number':  
  1398.             return isFinite(value) ? String(value) : "null";  
  1399.   
  1400.         case 'string':  
  1401.             return encodeString(value);  
  1402.   
  1403.         case 'boolean':  
  1404.             return String(value);  
  1405.   
  1406.         default:  
  1407.             if (value === null) {  
  1408.                 return 'null';  
  1409.             } else if (value instanceof Array) {  
  1410.                 return encodeArray(value);  
  1411.             } else if (value instanceof Date) {  
  1412.                 return encodeDate(value);  
  1413.             } else {  
  1414.                 var result = [ '{' ], encode = jQuery.json.stringify, preComma, item;  
  1415.   
  1416.                 for ( var key in value) {  
  1417.                     if (Object.prototype.hasOwnProperty.call(value, key)) {  
  1418.                         item = value[key];  
  1419.                         switch (typeof item) {  
  1420.                         case 'undefined':  
  1421.                         case 'unknown':  
  1422.                         case 'function':  
  1423.                             break;  
  1424.                         default:  
  1425.                             if (preComma) {  
  1426.                                 result.push(',');  
  1427.                             }  
  1428.                             preComma = 1;  
  1429.                             result.push(encode(key) + ':' + encode(item));  
  1430.                         }  
  1431.                     }  
  1432.                 }  
  1433.                 result.push('}');  
  1434.                 return result.join('');  
  1435.             }  
  1436.         }  
  1437.     };  
  1438. })();  
  1439.   
  1440. // TODO  
  1441. // ###################################lang操作相关函数###################################  
  1442. jQuery.lang = jQuery.lang || {};  
  1443. /** 
  1444.  * 判断目标参数是否Array对象 
  1445.  *  
  1446.  * @name jQuery.lang.isArray 
  1447.  * @function 
  1448.  * @grammar jQuery.lang.isArray(source) 
  1449.  * @param {Any} 
  1450.  *            source 目标参数 
  1451.  * @meta standard 
  1452.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isElement,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1453.  *  
  1454.  * @returns {boolean} 类型判断结果 
  1455.  */  
  1456. jQuery.lang.isArray = function(source) {  
  1457.     return '[object Array]' == Object.prototype.toString.call(source);  
  1458. };  
  1459. /** 
  1460.  * 判断目标参数是否Boolean对象 
  1461.  *  
  1462.  * @name jQuery.lang.isBoolean 
  1463.  * @function 
  1464.  * @grammar jQuery.lang.isBoolean(source) 
  1465.  * @param {Any} 
  1466.  *            source 目标参数 
  1467.  * @version 1.3 
  1468.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isElement,jQuery.lang.isArray,jQuery.lang.isDate 
  1469.  *  
  1470.  * @returns {boolean} 类型判断结果 
  1471.  */  
  1472. jQuery.lang.isBoolean = function(o) {  
  1473.     return typeof o === 'boolean';  
  1474. };  
  1475. /** 
  1476.  * 判断目标参数是否为Date对象 
  1477.  *  
  1478.  * @name jQuery.lang.isDate 
  1479.  * @function 
  1480.  * @grammar jQuery.lang.isDate(source) 
  1481.  * @param {Any} 
  1482.  *            source 目标参数 
  1483.  * @version 1.3 
  1484.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isArray,jQuery.lang.isBoolean,jQuery.lang.isElement 
  1485.  *  
  1486.  * @returns {boolean} 类型判断结果 
  1487.  */  
  1488. jQuery.lang.isDate = function(o) {  
  1489.     // return o instanceof Date;  
  1490.     return {}.toString.call(o) === "[object Date]"  
  1491.             && o.toString() !== 'Invalid Date' && !isNaN(o);  
  1492. };  
  1493. /** 
  1494.  * 判断目标参数是否为Element对象 
  1495.  *  
  1496.  * @name jQuery.lang.isElement 
  1497.  * @function 
  1498.  * @grammar jQuery.lang.isElement(source) 
  1499.  * @param {Any} 
  1500.  *            source 目标参数 
  1501.  * @meta standard 
  1502.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isArray,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1503.  *  
  1504.  * @returns {boolean} 类型判断结果 
  1505.  */  
  1506. jQuery.lang.isElement = function(source) {  
  1507.     return !!(source && source.nodeName && source.nodeType == 1);  
  1508. };  
  1509. /** 
  1510.  * 判断目标参数是否为function或Function实例 
  1511.  *  
  1512.  * @name jQuery.lang.isFunction 
  1513.  * @function 
  1514.  * @grammar jQuery.lang.isFunction(source) 
  1515.  * @param {Any} 
  1516.  *            source 目标参数 
  1517.  * @version 1.2 
  1518.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isArray,jQuery.lang.isElement,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1519.  * @meta standard 
  1520.  * @returns {boolean} 类型判断结果 
  1521.  */  
  1522. jQuery.lang.isFunction = function(source) {  
  1523.     // chrome下,'function' == typeof /a/ 为true.  
  1524.     return '[object Function]' == Object.prototype.toString.call(source);  
  1525. };  
  1526. /** 
  1527.  * 判断目标参数是否number类型或Number对象 
  1528.  *  
  1529.  * @name jQuery.lang.isNumber 
  1530.  * @function 
  1531.  * @grammar jQuery.lang.isNumber(source) 
  1532.  * @param {Any} 
  1533.  *            source 目标参数 
  1534.  * @meta standard 
  1535.  * @see jQuery.lang.isString,jQuery.lang.isObject,jQuery.lang.isArray,jQuery.lang.isElement,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1536.  *  
  1537.  * @returns {boolean} 类型判断结果 
  1538.  * @remark 用本函数判断NaN会返回false,尽管在Javascript中是Number类型。 
  1539.  */  
  1540. jQuery.lang.isNumber = function(source) {  
  1541.     return '[object Number]' == Object.prototype.toString.call(source)  
  1542.             && isFinite(source);  
  1543. };  
  1544. /** 
  1545.  * 判断目标参数是否为Object对象 
  1546.  *  
  1547.  * @name jQuery.lang.isObject 
  1548.  * @function 
  1549.  * @grammar jQuery.lang.isObject(source) 
  1550.  * @param {Any} 
  1551.  *            source 目标参数 
  1552.  * @shortcut isObject 
  1553.  * @meta standard 
  1554.  * @see jQuery.lang.isString,jQuery.lang.isNumber,jQuery.lang.isArray,jQuery.lang.isElement,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1555.  *  
  1556.  * @returns {boolean} 类型判断结果 
  1557.  */  
  1558. jQuery.lang.isObject = function(source) {  
  1559.     return 'function' == typeof source  
  1560.             || !!(source && 'object' == typeof source);  
  1561. };  
  1562. /** 
  1563.  * 判断目标参数是否string类型或String对象 
  1564.  *  
  1565.  * @name jQuery.lang.isString 
  1566.  * @function 
  1567.  * @grammar jQuery.lang.isString(source) 
  1568.  * @param {Any} 
  1569.  *            source 目标参数 
  1570.  * @shortcut isString 
  1571.  * @meta standard 
  1572.  * @see jQuery.lang.isObject,jQuery.lang.isNumber,jQuery.lang.isArray,jQuery.lang.isElement,jQuery.lang.isBoolean,jQuery.lang.isDate 
  1573.  *  
  1574.  * @returns {boolean} 类型判断结果 
  1575.  */  
  1576. jQuery.lang.isString = function(source) {  
  1577.     return '[object String]' == Object.prototype.toString.call(source);  
  1578. };  
  1579. /** 
  1580.  * 将一个变量转换成array 
  1581.  *  
  1582.  * @name jQuery.lang.toArray 
  1583.  * @function 
  1584.  * @grammar jQuery.lang.toArray(source) 
  1585.  * @param {mix} 
  1586.  *            source 需要转换成array的变量 
  1587.  * @version 1.3 
  1588.  * @meta standard 
  1589.  * @returns {array} 转换后的array 
  1590.  */  
  1591. jQuery.lang.toArray = function(source) {  
  1592.     if (source === null || source === undefined)  
  1593.         return [];  
  1594.     if (jQuery.lang.isArray(source))  
  1595.         return source;  
  1596.   
  1597.     // The strings and functions also have 'length'  
  1598.     if (typeof source.length !== 'number' || typeof source === 'string'  
  1599.             || jQuery.lang.isFunction(source)) {  
  1600.         return [ source ];  
  1601.     }  
  1602.   
  1603.     // nodeList, IE 下调用 [].slice.call(nodeList) 会报错  
  1604.     if (source.item) {  
  1605.         var l = source.length, array = new Array(l);  
  1606.         while (l--)  
  1607.             array[l] = source[l];  
  1608.         return array;  
  1609.     }  
  1610.   
  1611.     return [].slice.call(source);  
  1612. };  
  1613. // TODO  
  1614. // ###################################number操作相关函数###################################  
  1615. jQuery.number = jQuery.number || {};  
  1616. /** 
  1617.  * 对数字进行格式化 
  1618.  *  
  1619.  * @name jQuery.number.format 
  1620.  * @function 
  1621.  * @grammar jQuery.number.format(number, pattern) 
  1622.  * @param {number} 
  1623.  *            source 需要处理的数字 
  1624.  * @param {number} 
  1625.  *            pattern 格式化规则,例如format('12432.415','#,###.0#')='12,432.42' 
  1626.  *  
  1627.  * @returns {string} 对目标数字进行格式化之后的处理结果 
  1628.  */  
  1629. jQuery.number.format = function(source, pattern) {  
  1630.     var str = source.toString();  
  1631.     var strInt;  
  1632.     var strFloat;  
  1633.     var formatInt;  
  1634.     var formatFloat;  
  1635.     if (/\./g.test(pattern)) {  
  1636.         formatInt = pattern.split('.')[0];  
  1637.         formatFloat = pattern.split('.')[1];  
  1638.     } else {  
  1639.         formatInt = pattern;  
  1640.         formatFloat = null;  
  1641.     }  
  1642.     if (/\./g.test(str)) {  
  1643.         if (formatFloat != null) {  
  1644.             var tempFloat = Math.round(parseFloat('0.' + str.split('.')[1])  
  1645.                     * Math.pow(10, formatFloat.length))  
  1646.                     / Math.pow(10, formatFloat.length);  
  1647.             strInt = (Math.floor(source) + Math.floor(tempFloat)).toString();  
  1648.             strFloat = /\./g.test(tempFloat.toString()) ? tempFloat.toString()  
  1649.                     .split('.')[1] : '0';  
  1650.         } else {  
  1651.             strInt = Math.round(source).toString();  
  1652.             strFloat = '0';  
  1653.         }  
  1654.     } else {  
  1655.         strInt = str;  
  1656.         strFloat = '0';  
  1657.     }  
  1658.     if (formatInt != null) {  
  1659.         var outputInt = '';  
  1660.         var zero = formatInt.match(/0*$/)[0].length;  
  1661.         var comma = null;  
  1662.         if (/,/g.test(formatInt)) {  
  1663.             comma = formatInt.match(/,[^,]*/)[0].length - 1;  
  1664.         }  
  1665.         var newReg = new RegExp('(\\d{' + comma + '})', 'g');  
  1666.         if (strInt.length < zero) {  
  1667.             outputInt = new Array(zero + 1).join('0') + strInt;  
  1668.             outputInt = outputInt.substr(outputInt.length - zero, zero);  
  1669.         } else {  
  1670.             outputInt = strInt;  
  1671.         }  
  1672.         var outputInt = outputInt.substr(0, outputInt.length % comma)  
  1673.                 + outputInt.substring(outputInt.length % comma).replace(newReg,  
  1674.                         (comma != null ? ',' : '') + '$1');  
  1675.         outputInt = outputInt.replace(/^,/, '');  
  1676.         strInt = outputInt;  
  1677.     }  
  1678.     if (formatFloat != null) {  
  1679.         var outputFloat = '';  
  1680.         var zero = formatFloat.match(/^0*/)[0].length;  
  1681.         if (strFloat.length < zero) {  
  1682.             outputFloat = strFloat + new Array(zero + 1).join('0');  
  1683.             // outputFloat = outputFloat.substring(0,formatFloat.length);  
  1684.             var outputFloat1 = outputFloat.substring(0, zero);  
  1685.             var outputFloat2 = outputFloat.substring(zero, formatFloat.length);  
  1686.             outputFloat = outputFloat1 + outputFloat2.replace(/0*$/, '');  
  1687.         } else {  
  1688.             outputFloat = strFloat.substring(0, formatFloat.length);  
  1689.         }  
  1690.         strFloat = outputFloat;  
  1691.     } else {  
  1692.         if (pattern != '' || (pattern == '' && strFloat == '0')) {  
  1693.             strFloat = '';  
  1694.         }  
  1695.     }  
  1696.     return strInt + (strFloat == '' ? '' : '.' + strFloat);  
  1697. };  
  1698. /** 
  1699.  * 生成随机整数,范围是[min, max] 
  1700.  *  
  1701.  * @name jQuery.number.randomInt 
  1702.  * @function 
  1703.  * @grammar jQuery.number.randomInt(min, max) 
  1704.  *  
  1705.  * @param {number} 
  1706.  *            min 随机整数的最小值 
  1707.  * @param {number} 
  1708.  *            max 随机整数的最大值 
  1709.  * @return {number} 生成的随机整数 
  1710.  */  
  1711. jQuery.number.randomInt = function(min, max) {  
  1712.     return Math.floor(Math.random() * (max - min + 1) + min);  
  1713. };  
  1714. // 链接到Math类的一些方法  
  1715. jQuery.number.abs = Math.abs;  
  1716. jQuery.number.ceil = Math.ceil;  
  1717. jQuery.number.floor = Math.floor;  
  1718. jQuery.number.round = Math.round;  
  1719. jQuery.number.min = Math.min;  
  1720. jQuery.number.max = Math.max;  
  1721. // TODO  
  1722. // ###################################page操作相关函数###################################  
  1723. jQuery.page = jQuery.page || {};  
  1724. /** 
  1725.  * 获取横向滚动量 
  1726.  *  
  1727.  * @return {number} 横向滚动量 
  1728.  */  
  1729. jQuery.page.getScrollLeft = function() {  
  1730.     var d = document;  
  1731.     return window.pageXOffset || d.documentElement.scrollLeft  
  1732.             || d.body.scrollLeft;  
  1733. };  
  1734. /** 
  1735.  * 获取纵向滚动量 
  1736.  *  
  1737.  * @name jQuery.page.getScrollTop 
  1738.  * @function 
  1739.  * @grammar jQuery.page.getScrollTop() 
  1740.  * @see jQuery.page.getScrollLeft 
  1741.  * @meta standard 
  1742.  * @returns {number} 纵向滚动量 
  1743.  */  
  1744. jQuery.page.getScrollTop = function() {  
  1745.     var d = document;  
  1746.     return window.pageYOffset || d.documentElement.scrollTop  
  1747.             || d.body.scrollTop;  
  1748. };  
  1749. /** 
  1750.  * 获取页面视觉区域高度 
  1751.  *  
  1752.  * @name jQuery.page.getViewHeight 
  1753.  * @function 
  1754.  * @grammar jQuery.page.getViewHeight() 
  1755.  * @see jQuery.page.getViewWidth 
  1756.  * @meta standard 
  1757.  * @returns {number} 页面视觉区域高度 
  1758.  */  
  1759. jQuery.page.getViewHeight = function() {  
  1760.     var doc = document, client = doc.compatMode == 'BackCompat' ? doc.body  
  1761.             : doc.documentElement;  
  1762.   
  1763.     return client.clientHeight;  
  1764. };  
  1765. /** 
  1766.  * 获取页面视觉区域宽度 
  1767.  *  
  1768.  * @name jQuery.page.getViewWidth 
  1769.  * @function 
  1770.  * @grammar jQuery.page.getViewWidth() 
  1771.  * @see jQuery.page.getViewHeight 
  1772.  *  
  1773.  * @returns {number} 页面视觉区域宽度 
  1774.  */  
  1775. jQuery.page.getViewWidth = function() {  
  1776.     var doc = document, client = doc.compatMode == 'BackCompat' ? doc.body  
  1777.             : doc.documentElement;  
  1778.   
  1779.     return client.clientWidth;  
  1780. };  
  1781.   
  1782. /** 
  1783.  * 动态在页面上加载一个外部js文件 
  1784.  *  
  1785.  * @name jQuery.page.loadJsFile 
  1786.  * @function 
  1787.  * @grammar jQuery.page.loadJsFile(path) 
  1788.  * @param {string} 
  1789.  *            path js文件路径 
  1790.  * @see jQuery.page.loadCssFile 
  1791.  */  
  1792. jQuery.page.loadJsFile = function(path) {  
  1793.     var element = document.createElement('script');  
  1794.   
  1795.     element.setAttribute('type', 'text/javascript');  
  1796.     element.setAttribute('src', path);  
  1797.     element.setAttribute('defer', 'defer');  
  1798.   
  1799.     document.getElementsByTagName("head")[0].appendChild(element);  
  1800. };  
  1801. /** 
  1802.  * 动态在页面上加载一个外部css文件 
  1803.  *  
  1804.  * @name jQuery.page.loadCssFile 
  1805.  * @function 
  1806.  * @grammar jQuery.page.loadCssFile(path) 
  1807.  * @param {string} 
  1808.  *            path css文件路径 
  1809.  * @see jQuery.page.loadJsFile 
  1810.  */  
  1811.   
  1812. jQuery.page.loadCssFile = function(path) {  
  1813.     var element = document.createElement("link");  
  1814.   
  1815.     element.setAttribute("rel", "stylesheet");  
  1816.     element.setAttribute("type", "text/css");  
  1817.     element.setAttribute("href", path);  
  1818.   
  1819.     document.getElementsByTagName("head")[0].appendChild(element);  
  1820. };  
  1821.   
  1822. // TODO  
  1823. // ###################################swf操作相关函数###################################  
  1824. jQuery.swf = jQuery.swf || {};  
  1825. /** 
  1826.  * 浏览器支持的flash插件版本 
  1827.  *  
  1828.  * @property version 浏览器支持的flash插件版本 
  1829.  * @grammar jQuery.swf.version 
  1830.  * @return {String} 版本号 
  1831.  * @meta standard 
  1832.  */  
  1833. jQuery.swf.version = (function() {  
  1834.     var n = navigator;  
  1835.     if (n.plugins && n.mimeTypes.length) {  
  1836.         var plugin = n.plugins["Shockwave Flash"];  
  1837.         if (plugin && plugin.description) {  
  1838.             return plugin.description.replace(/([a-zA-Z]|\s)+/, "").replace(  
  1839.                     /(\s)+r/, ".")  
  1840.                     + ".0";  
  1841.         }  
  1842.     } else if (window.ActiveXObject && !window.opera) {  
  1843.         for ( var i = 12; i >= 2; i--) {  
  1844.             try {  
  1845.                 var c = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + i);  
  1846.                 if (c) {  
  1847.                     var version = c.GetVariable("$version");  
  1848.                     return version.replace(/WIN/g, '').replace(/,/g, '.');  
  1849.                 }  
  1850.             } catch (e) {  
  1851.             }  
  1852.         }  
  1853.     }  
  1854. })();  
  1855. /** 
  1856.  * 创建flash对象的html字符串 
  1857.  *  
  1858.  * @name jQuery.swf.createHTML 
  1859.  * @function 
  1860.  * @grammar jQuery.swf.createHTML(options) 
  1861.  *  
  1862.  * @param {Object} 
  1863.  *            options 创建flash的选项参数 
  1864.  * @param {string} 
  1865.  *            options.id 要创建的flash的标识 
  1866.  * @param {string} 
  1867.  *            options.url flash文件的url 
  1868.  * @param {String} 
  1869.  *            options.errorMessage 未安装flash player或flash player版本号过低时的提示 
  1870.  * @param {string} 
  1871.  *            options.ver 最低需要的flash player版本号 
  1872.  * @param {string} 
  1873.  *            options.width flash的宽度 
  1874.  * @param {string} 
  1875.  *            options.height flash的高度 
  1876.  * @param {string} 
  1877.  *            options.align flash的对齐方式,允许值:middle/left/right/top/bottom 
  1878.  * @param {string} 
  1879.  *            options.base 设置用于解析swf文件中的所有相对路径语句的基本目录或URL 
  1880.  * @param {string} 
  1881.  *            options.bgcolor swf文件的背景色 
  1882.  * @param {string} 
  1883.  *            options.salign 
  1884.  *            设置缩放的swf文件在由width和height设置定义的区域内的位置。允许值:l/r/t/b/tl/tr/bl/br 
  1885.  * @param {boolean} 
  1886.  *            options.menu 是否显示右键菜单,允许值:true/false 
  1887.  * @param {boolean} 
  1888.  *            options.loop 播放到最后一帧时是否重新播放,允许值: true/false 
  1889.  * @param {boolean} 
  1890.  *            options.play flash是否在浏览器加载时就开始播放。允许值:true/false 
  1891.  * @param {string} 
  1892.  *            options.quality 
  1893.  *            设置flash播放的画质,允许值:low/medium/high/autolow/autohigh/best 
  1894.  * @param {string} 
  1895.  *            options.scale 设置flash内容如何缩放来适应设置的宽高。允许值:showall/noborder/exactfit 
  1896.  * @param {string} 
  1897.  *            options.wmode 设置flash的显示模式。允许值:window/opaque/transparent 
  1898.  * @param {string} 
  1899.  *            options.allowscriptaccess 
  1900.  *            设置flash与页面的通信权限。允许值:always/never/sameDomain 
  1901.  * @param {string} 
  1902.  *            options.allownetworking 设置swf文件中允许使用的网络API。允许值:all/internal/none 
  1903.  * @param {boolean} 
  1904.  *            options.allowfullscreen 是否允许flash全屏。允许值:true/false 
  1905.  * @param {boolean} 
  1906.  *            options.seamlesstabbing 
  1907.  *            允许设置执行无缝跳格,从而使用户能跳出flash应用程序。该参数只能在安装Flash7及更高版本的Windows中使用。允许值:true/false 
  1908.  * @param {boolean} 
  1909.  *            options.devicefont 设置静态文本对象是否以设备字体呈现。允许值:true/false 
  1910.  * @param {boolean} 
  1911.  *            options.swliveconnect 第一次加载flash时浏览器是否应启动Java。允许值:true/false 
  1912.  * @param {Object} 
  1913.  *            options.vars 要传递给flash的参数,支持JSON或string类型。 
  1914.  *  
  1915.  * @see jQuery.swf.create 
  1916.  * @meta standard 
  1917.  * @returns {string} flash对象的html字符串 
  1918.  */  
  1919. jQuery.swf.createHTML = function(options) {  
  1920.     options = options || {};  
  1921.     var version = jQuery.swf.version, needVersion = options['ver'] || '6.0.0', vUnit1, vUnit2, i, k, len, item, tmpOpt = {}, encodeHTML = jQuery.string.encodeHTML;  
  1922.   
  1923.     // 复制options,避免修改原对象  
  1924.     for (k in options) {  
  1925.         tmpOpt[k] = options[k];  
  1926.     }  
  1927.     options = tmpOpt;  
  1928.   
  1929.     // 浏览器支持的flash插件版本判断  
  1930.     if (version) {  
  1931.         version = version.split('.');  
  1932.         needVersion = needVersion.split('.');  
  1933.         for (i = 0; i < 3; i++) {  
  1934.             vUnit1 = parseInt(version[i], 10);  
  1935.             vUnit2 = parseInt(needVersion[i], 10);  
  1936.             if (vUnit2 < vUnit1) {  
  1937.                 break;  
  1938.             } else if (vUnit2 > vUnit1) {  
  1939.                 return ''; // 需要更高的版本号  
  1940.             }  
  1941.         }  
  1942.     } else {  
  1943.         return ''; // 未安装flash插件  
  1944.     }  
  1945.   
  1946.     var vars = options['vars'], objProperties = [ 'classid', 'codebase', 'id',  
  1947.             'width', 'height', 'align' ];  
  1948.   
  1949.     // 初始化object标签需要的classid、codebase属性值  
  1950.     options['align'] = options['align'] || 'middle';  
  1951.     options['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';  
  1952.     options['codebase'] = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0';  
  1953.     options['movie'] = options['url'] || '';  
  1954.     delete options['vars'];  
  1955.     delete options['url'];  
  1956.   
  1957.     // 初始化flashvars参数的值  
  1958.     if ('string' == typeof vars) {  
  1959.         options['flashvars'] = vars;  
  1960.     } else {  
  1961.         var fvars = [];  
  1962.         for (k in vars) {  
  1963.             item = vars[k];  
  1964.             fvars.push(k + "=" + encodeURIComponent(item));  
  1965.         }  
  1966.         options['flashvars'] = fvars.join('&');  
  1967.     }  
  1968.   
  1969.     // 构建IE下支持的object字符串,包括属性和参数列表  
  1970.     var str = [ '<object ' ];  
  1971.     for (i = 0, len = objProperties.length; i < len; i++) {  
  1972.         item = objProperties[i];  
  1973.         str.push(' ', item, '="', encodeHTML(options[item]), '"');  
  1974.     }  
  1975.     str.push('>');  
  1976.     var params = {  
  1977.         'wmode' : 1,  
  1978.         'scale' : 1,  
  1979.         'quality' : 1,  
  1980.         'play' : 1,  
  1981.         'loop' : 1,  
  1982.         'menu' : 1,  
  1983.         'salign' : 1,  
  1984.         'bgcolor' : 1,  
  1985.         'base' : 1,  
  1986.         'allowscriptaccess' : 1,  
  1987.         'allownetworking' : 1,  
  1988.         'allowfullscreen' : 1,  
  1989.         'seamlesstabbing' : 1,  
  1990.         'devicefont' : 1,  
  1991.         'swliveconnect' : 1,  
  1992.         'flashvars' : 1,  
  1993.         'movie' : 1  
  1994.     };  
  1995.   
  1996.     for (k in options) {  
  1997.         item = options[k];  
  1998.         k = k.toLowerCase();  
  1999.         if (params[k] && (item || item === false || item === 0)) {  
  2000.             str.push('<param name="' + k + '" value="' + encodeHTML(item)  
  2001.                     + '" />');  
  2002.         }  
  2003.     }  
  2004.   
  2005.     // 使用embed时,flash地址的属性名是src,并且要指定embed的type和pluginspage属性  
  2006.     options['src'] = options['movie'];  
  2007.     options['name'] = options['id'];  
  2008.     delete options['id'];  
  2009.     delete options['movie'];  
  2010.     delete options['classid'];  
  2011.     delete options['codebase'];  
  2012.     options['type'] = 'application/x-shockwave-flash';  
  2013.     options['pluginspage'] = 'http://www.macromedia.com/go/getflashplayer';  
  2014.   
  2015.     // 构建embed标签的字符串  
  2016.     str.push('<embed');  
  2017.     // 在firefox、opera、safari下,salign属性必须在scale属性之后,否则会失效  
  2018.     // 经过讨论,决定采用BT方法,把scale属性的值先保存下来,最后输出  
  2019.     var salign;  
  2020.     for (k in options) {  
  2021.         item = options[k];  
  2022.         if (item || item === false || item === 0) {  
  2023.             if ((new RegExp("^salign\x24", "i")).test(k)) {  
  2024.                 salign = item;  
  2025.                 continue;  
  2026.             }  
  2027.   
  2028.             str.push(' ', k, '="', encodeHTML(item), '"');  
  2029.         }  
  2030.     }  
  2031.   
  2032.     if (salign) {  
  2033.         str.push(' salign="', encodeHTML(salign), '"');  
  2034.     }  
  2035.     str.push('></embed></object>');  
  2036.   
  2037.     return str.join('');  
  2038. };  
  2039. /** 
  2040.  * 在页面中创建一个flash对象 
  2041.  *  
  2042.  * @name jQuery.swf.create 
  2043.  * @function 
  2044.  * @grammar jQuery.swf.create(options[, container]) 
  2045.  *  
  2046.  * @param {Object} 
  2047.  *            options 创建flash的选项参数 
  2048.  * @param {string} 
  2049.  *            options.id 要创建的flash的标识 
  2050.  * @param {string} 
  2051.  *            options.url flash文件的url 
  2052.  * @param {String} 
  2053.  *            options.errorMessage 未安装flash player或flash player版本号过低时的提示 
  2054.  * @param {string} 
  2055.  *            options.ver 最低需要的flash player版本号 
  2056.  * @param {string} 
  2057.  *            options.width flash的宽度 
  2058.  * @param {string} 
  2059.  *            options.height flash的高度 
  2060.  * @param {string} 
  2061.  *            options.align flash的对齐方式,允许值:middle/left/right/top/bottom 
  2062.  * @param {string} 
  2063.  *            options.base 设置用于解析swf文件中的所有相对路径语句的基本目录或URL 
  2064.  * @param {string} 
  2065.  *            options.bgcolor swf文件的背景色 
  2066.  * @param {string} 
  2067.  *            options.salign 
  2068.  *            设置缩放的swf文件在由width和height设置定义的区域内的位置。允许值:l/r/t/b/tl/tr/bl/br 
  2069.  * @param {boolean} 
  2070.  *            options.menu 是否显示右键菜单,允许值:true/false 
  2071.  * @param {boolean} 
  2072.  *            options.loop 播放到最后一帧时是否重新播放,允许值: true/false 
  2073.  * @param {boolean} 
  2074.  *            options.play flash是否在浏览器加载时就开始播放。允许值:true/false 
  2075.  * @param {string} 
  2076.  *            options.quality 
  2077.  *            设置flash播放的画质,允许值:low/medium/high/autolow/autohigh/best 
  2078.  * @param {string} 
  2079.  *            options.scale 设置flash内容如何缩放来适应设置的宽高。允许值:showall/noborder/exactfit 
  2080.  * @param {string} 
  2081.  *            options.wmode 设置flash的显示模式。允许值:window/opaque/transparent 
  2082.  * @param {string} 
  2083.  *            options.allowscriptaccess 
  2084.  *            设置flash与页面的通信权限。允许值:always/never/sameDomain 
  2085.  * @param {string} 
  2086.  *            options.allownetworking 设置swf文件中允许使用的网络API。允许值:all/internal/none 
  2087.  * @param {boolean} 
  2088.  *            options.allowfullscreen 是否允许flash全屏。允许值:true/false 
  2089.  * @param {boolean} 
  2090.  *            options.seamlesstabbing 
  2091.  *            允许设置执行无缝跳格,从而使用户能跳出flash应用程序。该参数只能在安装Flash7及更高版本的Windows中使用。允许值:true/false 
  2092.  * @param {boolean} 
  2093.  *            options.devicefont 设置静态文本对象是否以设备字体呈现。允许值:true/false 
  2094.  * @param {boolean} 
  2095.  *            options.swliveconnect 第一次加载flash时浏览器是否应启动Java。允许值:true/false 
  2096.  * @param {Object} 
  2097.  *            options.vars 要传递给flash的参数,支持JSON或string类型。 
  2098.  *  
  2099.  * @param {HTMLElement|string} 
  2100.  *            [container] flash对象的父容器元素,不传递该参数时在当前代码位置创建flash对象。 
  2101.  * @meta standard 
  2102.  * @see jQuery.swf.createHTML,jQuery.swf.getMovie 
  2103.  */  
  2104. jQuery.swf.create = function(options, target) {  
  2105.     options = options || {};  
  2106.     var html = jQuery.swf.createHTML(options) || options['errorMessage'] || '';  
  2107.   
  2108.     if (target && 'string' == typeof target) {  
  2109.         target = document.getElementById(target);  
  2110.     }  
  2111.     // TODO这个地方被我改过,原来是这样的:  
  2112.     // jQuery.dom.insertHTML(target || document.body, 'beforeEnd', html);  
  2113.     // 但这需要引入dom相关api,百度的dom相关的api不大好,所以改成jQuery的  
  2114.     $(target || document.body).append(html);  
  2115. };  



经过压缩之后的代码 

Javascript代码  一个jQuery扩展工具包_html
  1. var jQuery=jQuery||{};jQuery.string=jQuery.string||{};jQuery.string.decodeHTML=function(c){var d=String(c).replace(/&quot;/g,'"').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/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,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,"&quot;").replace(/'/g,"&#39;")};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;