一个js的工具类

/**
 * 通用工具类
 */
;(function ($) {
    "use strict";

    /**
     * 对ie8浏览器数组map函数的支持
     */
    if (!Array.prototype.map) {
        Array.prototype.map = function (callback, thisArg) {

            var T, A, k;

            if (this == null) {
                throw new TypeError(" this is null or not defined");
            }

            // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
            var O = Object(this);

            // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
            // 3. Let len be ToUint32(lenValue).
            var len = O.length >>> 0;

            // 4. If IsCallable(callback) is false, throw a TypeError exception.
            // See: http://es5.github.com/#x9.11
            if (typeof callback !== "function") {
                throw new TypeError(callback + " is not a function");
            }

            // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
            if (thisArg) {
                T = thisArg;
            }

            // 6. Let A be a new array created as if by the expression new Array(len) where Array is
            // the standard built-in constructor with that name and len is the value of len.
            A = new Array(len);

            // 7. Let k be 0
            k = 0;

            // 8. Repeat, while k < len
            while (k < len) {

                var kValue, mappedValue;

                // a. Let Pk be ToString(k).
                //   This is implicit for LHS operands of the in operator
                // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
                //   This step can be combined with c
                // c. If kPresent is true, then
                if (k in O) {

                    // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
                    kValue = O[k];

                    // ii. Let mappedValue be the result of calling the Call internal method of callback
                    // with T as the this value and argument list containing kValue, k, and O.
                    mappedValue = callback.call(T, kValue, k, O);

                    // iii. Call the DefineOwnProperty internal method of A with arguments
                    // Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
                    // and false.

                    // In browsers that support Object.defineProperty, use the following:
                    // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });

                    // For best browser support, use the following:
                    A[k] = mappedValue;
                }
                // d. Increase k by 1.
                k++;
            }

            // 9. return A
            return A;
        };
    }


    /**
     * js数组克隆
     * @returns {Array.<*>}
     */
    Array.prototype.clone = function () {
        return [].concat(this);
    };

    /**
     * js数组去重
     * @returns {Array}
     */
    Array.prototype.unique = function () {
        var n = {}, r = []; //n为hash表,r为临时数组
        for (var i = 0; i < this.length; i++) //遍历当前数组
        {
            if (!n[this[i]]) //如果hash表中没有当前项
            {
                n[this[i]] = true; //存入hash表
                r.push(this[i]); //把当前数组的当前项push到临时数组里面
            }
        }
        return r;
    }

    /**
     * 扩展Date的format方法
     */
    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds()
        }
        if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
            }
        }
        return format;
    }

    /**
     * 扩展String的长度计算方式,中文算三个字节
     * @returns {Number}
     */
    String.prototype.len = function() {
        return this.replace(/[^\x00-\xff]/g, 'xxx').length;
    };

    var strGB = "啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川穿椽传船喘串疮窗幢床闯创吹炊捶锤垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递缔颠掂滇碘点典靛垫电佃甸店惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺废沸费芬酚吩氛分纷坟焚汾粉奋份忿愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共钩勾沟苟狗垢构购够辜菇咕箍估沽孤姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪户花哗华猾滑画划化话槐徊怀淮坏欢环桓还缓换患唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几脊己蓟技冀季伎祭剂悸济寄寂计记既忌际妓继纪嘉枷夹佳家加荚颊贾甲钾假稼价架驾嫁歼监坚尖笺间煎兼肩艰奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋禁近烬浸尽劲荆兢茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯窘揪究纠玖韭久灸九酒厩救旧臼舅咎就疚鞠拘狙疽居驹菊局咀矩举沮聚拒据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵觉决诀绝均菌钧军君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾历利傈例俐痢立粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱零龄铃伶羚凌灵陵岭领另令溜琉榴硫馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥米秘觅泌蜜密幂棉眠绵冕免勉娩缅面苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨烹澎彭蓬棚硼篷膨朋鹏捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片骗飘漂瓢票撇瞥拼频贫品聘乒坪苹萍平凭瓶评屏坡泼颇婆破魄迫粕剖扑铺仆莆葡菩蒲埔朴圃普浦谱曝瀑期欺栖戚妻七凄漆柒沏其棋奇歧畦崎脐齐旗祈祁骑起岂乞企启契砌器气迄弃汽泣讫掐恰洽牵扦钎铅千迁签仟谦乾黔钱钳前潜遣浅谴堑嵌欠歉枪呛腔羌墙蔷强抢橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍切茄且怯窃钦侵亲秦琴勤芹擒禽寝沁青轻氢倾卿清擎晴氰情顷请庆琼穷秋丘邱球求囚酋泅趋区蛆曲躯屈驱渠取娶龋趣去圈颧权醛泉全痊拳犬券劝缺炔瘸却鹊榷确雀裙群然燃冉染瓤壤攘嚷让饶扰绕惹热壬仁人忍韧任认刃妊纫扔仍日戎茸蓉荣融熔溶容绒冗揉柔肉茹蠕儒孺如辱乳汝入褥软阮蕊瑞锐闰润若弱撒洒萨腮鳃塞赛三叁伞散桑嗓丧搔骚扫嫂瑟色涩森僧莎砂杀刹沙纱傻啥煞筛晒珊苫杉山删煽衫闪陕擅赡膳善汕扇缮墒伤商赏晌上尚裳梢捎稍烧芍勺韶少哨邵绍奢赊蛇舌舍赦摄射慑涉社设砷申呻伸身深娠绅神沈审婶甚肾慎渗声生甥牲升绳省盛剩胜圣师失狮施湿诗尸虱十石拾时什食蚀实识史矢使屎驶始式示士世柿事拭誓逝势是嗜噬适仕侍释饰氏市恃室视试收手首守寿授售受瘦兽蔬枢梳殊抒输叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠属术述树束戍竖墅庶数漱恕刷耍摔衰甩帅栓拴霜双爽谁水睡税吮瞬顺舜说硕朔烁斯撕嘶思私司丝死肆寺嗣四伺似饲巳松耸怂颂送宋讼诵搜艘擞嗽苏酥俗素速粟僳塑溯宿诉肃酸蒜算虽隋随绥髓碎岁穗遂隧祟孙损笋蓑梭唆缩琐索锁所塌他它她塔獭挞蹋踏胎苔抬台泰酞太态汰坍摊贪瘫滩坛檀痰潭谭谈坦毯袒碳探叹炭汤塘搪堂棠膛唐糖倘躺淌趟烫掏涛滔绦萄桃逃淘陶讨套特藤腾疼誊梯剔踢锑提题蹄啼体替嚏惕涕剃屉天添填田甜恬舔腆挑条迢眺跳贴铁帖厅听烃汀廷停亭庭挺艇通桐酮瞳同铜彤童桶捅筒统痛偷投头透凸秃突图徒途涂屠土吐兔湍团推颓腿蜕褪退吞屯臀拖托脱鸵陀驮驼椭妥拓唾挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误昔熙析西硒矽晰嘻吸锡牺稀息希悉膝夕惜熄烯溪汐犀檄袭席习媳喜铣洗系隙戏细瞎虾匣霞辖暇峡侠狭下厦夏吓掀锨先仙鲜纤咸贤衔舷闲涎弦嫌显险现献县腺馅羡宪陷限线相厢镶香箱襄湘乡翔祥详想响享项巷橡像向象萧硝霄削哮嚣销消宵淆晓小孝校肖啸笑效楔些歇蝎鞋协挟携邪斜胁谐写械卸蟹懈泄泻谢屑薪芯锌欣辛新忻心信衅星腥猩惺兴刑型形邢行醒幸杏性姓兄凶胸匈汹雄熊休修羞朽嗅锈秀袖绣墟戌需虚嘘须徐许蓄酗叙旭序畜恤絮婿绪续轩喧宣悬旋玄选癣眩绚靴薛学穴雪血勋熏循旬询寻驯巡殉汛训讯逊迅压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧仰痒养样漾邀腰妖瑶摇尧遥窑谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕匝砸杂栽哉灾宰载再在咱攒暂赞赃脏葬遭糟凿藻枣早澡蚤躁噪造皂灶燥责择则泽贼怎增憎曾赠扎喳渣札轧铡闸眨栅榨咋乍炸诈摘斋宅窄债寨瞻毡詹粘沾盏斩辗崭展蘸栈占战站湛绽樟章彰漳张掌涨杖丈帐账仗胀瘴障招昭找沼赵照罩兆肇召遮折哲蛰辙者锗蔗这浙珍斟真甄砧臻贞针侦枕疹诊震振镇阵蒸挣睁征狰争怔整拯正政帧症郑证芝枝支吱蜘知肢脂汁之织职直植殖执值侄址指止趾只旨纸志挚掷至致置帜峙制智秩稚质炙痔滞治窒中盅忠钟衷终种肿重仲众舟周州洲诌粥轴肘帚咒皱宙昼骤珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱主著柱助蛀贮铸筑住注祝驻抓爪拽专砖转撰赚篆桩庄装妆撞壮状椎锥追赘坠缀谆准捉拙卓桌琢茁酌啄着灼浊兹咨资姿滋淄孜紫仔籽滓子自渍字鬃棕踪宗综总纵邹走奏揍租足卒族祖诅阻组钻纂嘴醉最罪尊遵昨左佐柞做作坐座亍丌兀丐廿卅丕亘丞鬲孬噩丨禺丿匕乇夭爻卮氐囟胤馗毓睾鼗丶亟鼐乜乩亓芈孛啬嘏仄厍厝厣厥厮靥赝匚叵匦匮匾赜卦卣刂刈刎刭刳刿剀剌剞剡剜蒯剽劂劁劐劓冂罔亻仃仉仂仨仡仫仞伛仳伢佤仵伥伧伉伫佞佧攸佚佝佟佗伲伽佶佴侑侉侃侏佾佻侪佼侬侔俦俨俪俅俚俣俜俑俟俸倩偌俳倬倏倮倭俾倜倌倥倨偾偃偕偈偎偬偻傥傧傩傺僖儆僭僬僦僮儇儋仝氽佘佥俎龠汆籴兮巽黉馘冁夔勹匍訇匐凫夙兕亠兖亳衮袤亵脔裒禀嬴蠃羸冫冱冽冼凇冖冢冥讠讦讧讪讴讵讷诂诃诋诏诎诒诓诔诖诘诙诜诟诠诤诨诩诮诰诳诶诹诼诿谀谂谄谇谌谏谑谒谔谕谖谙谛谘谝谟谠谡谥谧谪谫谮谯谲谳谵谶卩卺阝阢阡阱阪阽阼陂陉陔陟陧陬陲陴隈隍隗隰邗邛邝邙邬邡邴邳邶邺邸邰郏郅邾郐郄郇郓郦郢郜郗郛郫郯郾鄄鄢鄞鄣鄱鄯鄹酃酆刍奂劢劬劭劾哿勐勖勰叟燮矍廴凵凼鬯厶弁畚巯坌垩垡塾墼壅壑圩圬圪圳圹圮圯坜圻坂坩垅坫垆坼坻坨坭坶坳垭垤垌垲埏垧垴垓垠埕埘埚埙埒垸埴埯埸埤埝堋堍埽埭堀堞堙塄堠塥塬墁墉墚墀馨鼙懿艹艽艿芏芊芨芄芎芑芗芙芫芸芾芰苈苊苣芘芷芮苋苌苁芩芴芡芪芟苄苎芤苡茉苷苤茏茇苜苴苒苘茌苻苓茑茚茆茔茕苠苕茜荑荛荜茈莒茼茴茱莛荞茯荏荇荃荟荀茗荠茭茺茳荦荥荨茛荩荬荪荭荮莰荸莳莴莠莪莓莜莅荼莶莩荽莸荻莘莞莨莺莼菁萁菥菘堇萘萋菝菽菖萜萸萑萆菔菟萏萃菸菹菪菅菀萦菰菡葜葑葚葙葳蒇蒈葺蒉葸萼葆葩葶蒌蒎萱葭蓁蓍蓐蓦蒽蓓蓊蒿蒺蓠蒡蒹蒴蒗蓥蓣蔌甍蔸蓰蔹蔟蔺蕖蔻蓿蓼蕙蕈蕨蕤蕞蕺瞢蕃蕲蕻薤薨薇薏蕹薮薜薅薹薷薰藓藁藜藿蘧蘅蘩蘖蘼廾弈夼奁耷奕奚奘匏尢尥尬尴扌扪抟抻拊拚拗拮挢拶挹捋捃掭揶捱捺掎掴捭掬掊捩掮掼揲揸揠揿揄揞揎摒揆掾摅摁搋搛搠搌搦搡摞撄摭撖摺撷撸撙撺擀擐擗擤擢攉攥攮弋忒甙弑卟叱叽叩叨叻吒吖吆呋呒呓呔呖呃吡呗呙吣吲咂咔呷呱呤咚咛咄呶呦咝哐咭哂咴哒咧咦哓哔呲咣哕咻咿哌哙哚哜咩咪咤哝哏哞唛哧唠哽唔哳唢唣唏唑唧唪啧喏喵啉啭啁啕唿啐唼唷啖啵啶啷唳唰啜喋嗒喃喱喹喈喁喟啾嗖喑啻嗟喽喾喔喙嗪嗷嗉嘟嗑嗫嗬嗔嗦嗝嗄嗯嗥嗲嗳嗌嗍嗨嗵嗤辔嘞嘈嘌嘁嘤嘣嗾嘀嘧嘭噘嘹噗嘬噍噢噙噜噌噔嚆噤噱噫噻噼嚅嚓嚯囔囗囝囡囵囫囹囿圄圊圉圜帏帙帔帑帱帻帼帷幄幔幛幞幡岌屺岍岐岖岈岘岙岑岚岜岵岢岽岬岫岱岣峁岷峄峒峤峋峥崂崃崧崦崮崤崞崆崛嵘崾崴崽嵬嵛嵯嵝嵫嵋嵊嵩嵴嶂嶙嶝豳嶷巅彳彷徂徇徉後徕徙徜徨徭徵徼衢彡犭犰犴犷犸狃狁狎狍狒狨狯狩狲狴狷猁狳猃狺狻猗猓猡猊猞猝猕猢猹猥猬猸猱獐獍獗獠獬獯獾舛夥飧夤夂饣饧饨饩饪饫饬饴饷饽馀馄馇馊馍馐馑馓馔馕庀庑庋庖庥庠庹庵庾庳赓廒廑廛廨廪膺忄忉忖忏怃忮怄忡忤忾怅怆忪忭忸怙怵怦怛怏怍怩怫怊怿怡恸恹恻恺恂恪恽悖悚悭悝悃悒悌悛惬悻悱惝惘惆惚悴愠愦愕愣惴愀愎愫慊慵憬憔憧憷懔懵忝隳闩闫闱闳闵闶闼闾阃阄阆阈阊阋阌阍阏阒阕阖阗阙阚丬爿戕氵汔汜汊沣沅沐沔沌汨汩汴汶沆沩泐泔沭泷泸泱泗沲泠泖泺泫泮沱泓泯泾洹洧洌浃浈洇洄洙洎洫浍洮洵洚浏浒浔洳涑浯涞涠浞涓涔浜浠浼浣渚淇淅淞渎涿淠渑淦淝淙渖涫渌涮渫湮湎湫溲湟溆湓湔渲渥湄滟溱溘滠漭滢溥溧溽溻溷滗溴滏溏滂溟潢潆潇漤漕滹漯漶潋潴漪漉漩澉澍澌潸潲潼潺濑濉澧澹澶濂濡濮濞濠濯瀚瀣瀛瀹瀵灏灞宀宄宕宓宥宸甯骞搴寤寮褰寰蹇謇辶迓迕迥迮迤迩迦迳迨逅逄逋逦逑逍逖逡逵逶逭逯遄遑遒遐遨遘遢遛暹遴遽邂邈邃邋彐彗彖彘尻咫屐屙孱屣屦羼弪弩弭艴弼鬻屮妁妃妍妩妪妣妗姊妫妞妤姒妲妯姗妾娅娆姝娈姣姘姹娌娉娲娴娑娣娓婀婧婊婕娼婢婵胬媪媛婷婺媾嫫媲嫒嫔媸嫠嫣嫱嫖嫦嫘嫜嬉嬗嬖嬲嬷孀尕尜孚孥孳孑孓孢驵驷驸驺驿驽骀骁骅骈骊骐骒骓骖骘骛骜骝骟骠骢骣骥骧纟纡纣纥纨纩纭纰纾绀绁绂绉绋绌绐绔绗绛绠绡绨绫绮绯绱绲缍绶绺绻绾缁缂缃缇缈缋缌缏缑缒缗缙缜缛缟缡缢缣缤缥缦缧缪缫缬缭缯缰缱缲缳缵幺畿巛甾邕玎玑玮玢玟珏珂珑玷玳珀珉珈珥珙顼琊珩珧珞玺珲琏琪瑛琦琥琨琰琮琬琛琚瑁瑜瑗瑕瑙瑷瑭瑾璜璎璀璁璇璋璞璨璩璐璧瓒璺韪韫韬杌杓杞杈杩枥枇杪杳枘枧杵枨枞枭枋杷杼柰栉柘栊柩枰栌柙枵柚枳柝栀柃枸柢栎柁柽栲栳桠桡桎桢桄桤梃栝桕桦桁桧桀栾桊桉栩梵梏桴桷梓桫棂楮棼椟椠棹椤棰椋椁楗棣椐楱椹楠楂楝榄楫榀榘楸椴槌榇榈槎榉楦楣楹榛榧榻榫榭槔榱槁槊槟榕槠榍槿樯槭樗樘橥槲橄樾檠橐橛樵檎橹樽樨橘橼檑檐檩檗檫猷獒殁殂殇殄殒殓殍殚殛殡殪轫轭轱轲轳轵轶轸轷轹轺轼轾辁辂辄辇辋辍辎辏辘辚軎戋戗戛戟戢戡戥戤戬臧瓯瓴瓿甏甑甓攴旮旯旰昊昙杲昃昕昀炅曷昝昴昱昶昵耆晟晔晁晏晖晡晗晷暄暌暧暝暾曛曜曦曩贲贳贶贻贽赀赅赆赈赉赇赍赕赙觇觊觋觌觎觏觐觑牮犟牝牦牯牾牿犄犋犍犏犒挈挲掰搿擘耄毪毳毽毵毹氅氇氆氍氕氘氙氚氡氩氤氪氲攵敕敫牍牒牖爰虢刖肟肜肓肼朊肽肱肫肭肴肷胧胨胩胪胛胂胄胙胍胗朐胝胫胱胴胭脍脎胲胼朕脒豚脶脞脬脘脲腈腌腓腴腙腚腱腠腩腼腽腭腧塍媵膈膂膑滕膣膪臌朦臊膻臁膦欤欷欹歃歆歙飑飒飓飕飙飚殳彀毂觳斐齑斓於旆旄旃旌旎旒旖炀炜炖炝炻烀炷炫炱烨烊焐焓焖焯焱煳煜煨煅煲煊煸煺熘熳熵熨熠燠燔燧燹爝爨灬焘煦熹戾戽扃扈扉礻祀祆祉祛祜祓祚祢祗祠祯祧祺禅禊禚禧禳忑忐怼恝恚恧恁恙恣悫愆愍慝憩憝懋懑戆肀聿沓泶淼矶矸砀砉砗砘砑斫砭砜砝砹砺砻砟砼砥砬砣砩硎硭硖硗砦硐硇硌硪碛碓碚碇碜碡碣碲碹碥磔磙磉磬磲礅磴礓礤礞礴龛黹黻黼盱眄眍盹眇眈眚眢眙眭眦眵眸睐睑睇睃睚睨睢睥睿瞍睽瞀瞌瞑瞟瞠瞰瞵瞽町畀畎畋畈畛畲畹疃罘罡罟詈罨罴罱罹羁罾盍盥蠲钅钆钇钋钊钌钍钏钐钔钗钕钚钛钜钣钤钫钪钭钬钯钰钲钴钶钷钸钹钺钼钽钿铄铈铉铊铋铌铍铎铐铑铒铕铖铗铙铘铛铞铟铠铢铤铥铧铨铪铩铫铮铯铳铴铵铷铹铼铽铿锃锂锆锇锉锊锍锎锏锒锓锔锕锖锘锛锝锞锟锢锪锫锩锬锱锲锴锶锷锸锼锾锿镂锵镄镅镆镉镌镎镏镒镓镔镖镗镘镙镛镞镟镝镡镢镤镥镦镧镨镩镪镫镬镯镱镲镳锺矧矬雉秕秭秣秫稆嵇稃稂稞稔稹稷穑黏馥穰皈皎皓皙皤瓞瓠甬鸠鸢鸨鸩鸪鸫鸬鸲鸱鸶鸸鸷鸹鸺鸾鹁鹂鹄鹆鹇鹈鹉鹋鹌鹎鹑鹕鹗鹚鹛鹜鹞鹣鹦鹧鹨鹩鹪鹫鹬鹱鹭鹳疒疔疖疠疝疬疣疳疴疸痄疱疰痃痂痖痍痣痨痦痤痫痧瘃痱痼痿瘐瘀瘅瘌瘗瘊瘥瘘瘕瘙瘛瘼瘢瘠癀瘭瘰瘿瘵癃瘾瘳癍癞癔癜癖癫癯翊竦穸穹窀窆窈窕窦窠窬窨窭窳衤衩衲衽衿袂袢裆袷袼裉裢裎裣裥裱褚裼裨裾裰褡褙褓褛褊褴褫褶襁襦襻疋胥皲皴矜耒耔耖耜耠耢耥耦耧耩耨耱耋耵聃聆聍聒聩聱覃顸颀颃颉颌颍颏颔颚颛颞颟颡颢颥颦虍虔虬虮虿虺虼虻蚨蚍蚋蚬蚝蚧蚣蚪蚓蚩蚶蛄蚵蛎蚰蚺蚱蚯蛉蛏蚴蛩蛱蛲蛭蛳蛐蜓蛞蛴蛟蛘蛑蜃蜇蛸蜈蜊蜍蜉蜣蜻蜞蜥蜮蜚蜾蝈蜴蜱蜩蜷蜿螂蜢蝽蝾蝻蝠蝰蝌蝮螋蝓蝣蝼蝤蝙蝥螓螯螨蟒蟆螈螅螭螗螃螫蟥螬螵螳蟋蟓螽蟑蟀蟊蟛蟪蟠蟮蠖蠓蟾蠊蠛蠡蠹蠼缶罂罄罅舐竺竽笈笃笄笕笊笫笏筇笸笪笙笮笱笠笥笤笳笾笞筘筚筅筵筌筝筠筮筻筢筲筱箐箦箧箸箬箝箨箅箪箜箢箫箴篑篁篌篝篚篥篦篪簌篾篼簏簖簋簟簪簦簸籁籀臾舁舂舄臬衄舡舢舣舭舯舨舫舸舻舳舴舾艄艉艋艏艚艟艨衾袅袈裘裟襞羝羟羧羯羰羲籼敉粑粝粜粞粢粲粼粽糁糇糌糍糈糅糗糨艮暨羿翎翕翥翡翦翩翮翳糸絷綦綮繇纛麸麴赳趄趔趑趱赧赭豇豉酊酐酎酏酤酢酡酰酩酯酽酾酲酴酹醌醅醐醍醑醢醣醪醭醮醯醵醴醺豕鹾趸跫踅蹙蹩趵趿趼趺跄跖跗跚跞跎跏跛跆跬跷跸跣跹跻跤踉跽踔踝踟踬踮踣踯踺蹀踹踵踽踱蹉蹁蹂蹑蹒蹊蹰蹶蹼蹯蹴躅躏躔躐躜躞豸貂貊貅貘貔斛觖觞觚觜觥觫觯訾謦靓雩雳雯霆霁霈霏霎霪霭霰霾龀龃龅龆龇龈龉龊龌黾鼋鼍隹隼隽雎雒瞿雠銎銮鋈錾鍪鏊鎏鐾鑫鱿鲂鲅鲆鲇鲈稣鲋鲎鲐鲑鲒鲔鲕鲚鲛鲞鲟鲠鲡鲢鲣鲥鲦鲧鲨鲩鲫鲭鲮鲰鲱鲲鲳鲴鲵鲶鲷鲺鲻鲼鲽鳄鳅鳆鳇鳊鳋鳌鳍鳎鳏鳐鳓鳔鳕鳗鳘鳙鳜鳝鳟鳢靼鞅鞑鞒鞔鞯鞫鞣鞲鞴骱骰骷鹘骶骺骼髁髀髅髂髋髌髑魅魃魇魉魈魍魑飨餍餮饕饔髟髡髦髯髫髻髭髹鬈鬏鬓鬟鬣麽麾縻麂麇麈麋麒鏖麝麟黛黜黝黠黟黢黩黧黥黪黯鼢鼬鼯鼹鼷鼽鼾齄";
    var qswhSpell = ["a", 0, "ai", 2, "an", 15, "ang", 24, "ao", 27, "ba", 36, "bai", 54, "ban", 62, "bang", 77, "bao", 89, "bei", 106, "ben", 121, "beng", 125, "bi", 131, "bian", 155, "biao", 167, "bie", 171, "bin", 175, "bing", 181, "bo", 190, "bu", 211, "ca", 220, "cai", 221, "can", 232, "cang", 239, "cao", 244, "ce", 249, "ceng", 254, "cha", 256, "chai", 267, "chan", 270, "chang", 280, "chao", 293, "che", 302, "chen", 308, "cheng", 318, "chi", 333, "chong", 349, "chou", 354, "chu", 366, "chuai", 382, "chuan", 383, "chuang", 390, "chui", 396, "chun", 401, "chuo", 408, "ci", 410, "cong", 422, "cou", 428, "cu", 429, "cuan", 433, "cui", 436, "cun", 444, "cuo", 447, "da", 453, "dai", 459, "dan", 471, "dang", 486, "dao", 491, "de", 503, "deng", 506, "di", 513, "dian", 532, "diao", 548, "die", 557, "ding", 564, "diu", 573, "dong", 574, "dou", 584, "du", 591, "duan", 606, "dui", 612, "dun", 616, "duo", 625, "e", 637, "en", 650, "er", 651, "fa", 659, "fan", 667, "fang", 684, "fei", 695, "fen", 707, "feng", 722, "fo", 737, "fou", 738, "fu", 739, "ga", 784, "gai", 786, "gan", 792, "gang", 803, "gao", 812, "ge", 822, "gei", 839, "gen", 840, "geng", 842, "gong", 849, "gou", 864, "gu", 873, "gua", 891, "guai", 897, "guan", 900, "guang", 911, "gui", 914, "gun", 930, "guo", 933, "ha", 939, "hai", 940, "han", 947, "hang", 966, "hao", 969, "he", 978, "hei", 996, "hen", 998, "heng", 1002, "hong", 1007, "hou", 1016, "hu", 1023, "hua", 1041, "huai", 1050, "huan", 1055, "huang", 1069, "hui", 1083, "hun", 1104, "huo", 1110, "ji", 1120, "jia", 1173, "jian", 1190, "jiang", 1230, "jiao", 1243, "jie", 1271, "jin", 1298, "jing", 1318, "jiong", 1343, "jiu", 1345, "ju", 1362, "juan", 1387, "jue", 1394, "jun", 1404, "ka", 1415, "kai", 1419, "kan", 1424, "kang", 1430, "kao", 1437, "ke", 1441, "ken", 1456, "keng", 1460, "kong", 1462, "kou", 1466, "ku", 1470, "kua", 1477, "kuai", 1482, "kuan", 1486, "kuang", 1488, "kui", 1496, "kun", 1507, "kuo", 1511, "la", 1515, "lai", 1522, "lan", 1525, "lang", 1540, "lao", 1547, "le", 1556, "lei", 1558, "leng", 1569, "li", 1572, "lia", 1606, "lian", 1607, "liang", 1621, "liao", 1632, "lie", 1645, "lin", 1650, "ling", 1662, "liu", 1676, "long", 1687, "lou", 1696, "lu", 1702, "lv", 1722, "luan", 1736, "lue", 1742, "lun", 1744, "luo", 1751, "ma", 1763, "mai", 1772, "man", 1778, "mang", 1787, "mao", 1793, "me", 1805, "mei", 1806, "men", 1822, "meng", 1825, "mi", 1833, "mian", 1847, "miao", 1856, "mie", 1864, "min", 1866, "ming", 1872, "miu", 1878, "mo", 1879, "mou", 1896, "mu", 1899, "na", 1914, "nai", 1921, "nan", 1926, "nang", 1929, "nao", 1930, "ne", 1935, "nei", 1936, "nen", 1938, "neng", 1939, "ni", 1940, "nian", 1951, "niang", 1958, "niao", 1960, "nie", 1962, "nin", 1969, "ning", 1970, "niu", 1976, "nong", 1980, "nu", 1984, "nv", 1987, "nuan", 1988, "nue", 1989, "nuo", 1991, "o", 1995, "ou", 1996, "pa", 2003, "pai", 2009, "pan", 2015, "pang", 2023, "pao", 2028, "pei", 2035, "pen", 2044, "peng", 2046, "pi", 2060, "pian", 2077, "piao", 2081, "pie", 2085, "pin", 2087, "ping", 2092, "po", 2101, "pu", 2110, "qi", 2125, "qia", 2161, "qian", 2164, "qiang", 2186, "qiao", 2194, "qie", 2209, "qin", 2214, "qing", 2225, "qiong", 2238, "qiu", 2240, "qu", 2248, "quan", 2261, "que", 2272, "qun", 2280, "ran", 2282, "rang", 2286, "rao", 2291, "re", 2294, "ren", 2296, "reng", 2306, "ri", 2308, "rong", 2309, "rou", 2319, "ru", 2322, "ruan", 2332, "rui", 2334, "run", 2337, "ruo", 2339, "sa", 2341, "sai", 2344, "san", 2348, "sang", 2352, "sao", 2355, "se", 2359, "sen", 2362, "seng", 2363, "sha", 2364, "shai", 2373, "shan", 2375, "shang", 2391, "shao", 2399, "she", 2410, "shen", 2422, "sheng", 2438, "shi", 2449, "shou", 2496, "shu", 2506, "shua", 2539, "shuai", 2541, "shuan", 2545, "shuang", 2547, "shui", 2550, "shun", 2554, "shuo", 2558, "si", 2562, "song", 2578, "sou", 2586, "su", 2589, "suan", 2602, "sui", 2605, "sun", 2616, "suo", 2619, "ta", 2627, "tai", 2636, "tan", 2645, "tang", 2663, "tao", 2676, "te", 2687, "teng", 2688, "ti", 2692, "tian", 2707, "tiao", 2715, "tie", 2720, "ting", 2723, "tong", 2733, "tou", 2746, "tu", 2750, "tuan", 2761, "tui", 2763, "tun", 2769, "tuo", 2772, "wa", 2783, "wai", 2790, "wan", 2792, "wang", 2809, "wei", 2819, "wen", 2852, "weng", 2862, "wo", 2865, "wu", 2874, "xi", 2903, "xia", 2938, "xian", 2951, "xiang", 2977, "xiao", 2997, "xie", 3015, "xin", 3036, "xing", 3046, "xiong", 3061, "xiu", 3068, "xu", 3077, "xuan", 3096, "xue", 3106, "xun", 3112, "ya", 3126, "yan", 3142, "yang", 3175, "yao", 3192, "ye", 3207, "yi", 3222, "yin", 3275, "ying", 3291, "yo", 3309, "yong", 3310, "you", 3325, "yu", 3346, "yuan", 3390, "yue", 3410, "yun", 3420, "za", 3432, "zai", 3435, "zan", 3442, "zang", 3446, "zao", 3449, "ze", 3463, "zei", 3467, "zen", 3468, "zeng", 3469, "zha", 3473, "zhai", 3487, "zhan", 3493, "zhang", 3510, "zhao", 3525, "zhe", 3535, "zhen", 3545, "zheng", 3561, "zhi", 3576, "zhong", 3619, "zhou", 3630, "zhu", 3644, "zhua", 3670, "zhuai", 3672, "zhuan", 3673, "zhuang", 3679, "zhui", 3686, "zhun", 3692, "zhuo", 3694, "zi", 3705, "zong", 3720, "zou", 3727, "zu", 3731, "zuan", 3739, "zui", 3741, "zun", 3745, "zuo", 3747];
    /**
     * url编码
     * @param str
     * @returns {string}
     * @constructor
     */
    $.UrlEncode = function (str) {
        var i, c, p, q, ret = "", strSpecial = "!\"#$%&'()*+,/:;<=>?@[\]^`{|}~%";
        for (i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) >= 0x4e00) {
                var p = strGB.indexOf(str.charAt(i));
                if (p >= 0) {
                    q = p % 94;
                    p = (p - q) / 94;
                    ret += ("%" + (0xB0 + p).toString(16) + "%" + (0xA1 + q).toString(16)).toUpperCase();
                }
            }
            else {
                c = str.charAt(i);
                if (c == " ")
                    ret += "+";
                else if (strSpecial.indexOf(c) != -1)
                    ret += "%" + str.charCodeAt(i).toString(16);
                else
                    ret += c;
            }
        }
        return ret;
    }

    /**
     * 解析地址栏请求参数
     * @returns {{}}
     */
    $.urlParse = function (url) {
        if(!url) {
            url = window.location.search;
        }
        var result = {};
        var regx = /[?&][^?&]+=[^?&]+/g;
        var arr = url.match(regx);
        // ['?id=123','&a=b']
        if (arr) {
            arr.forEach(function(item){
                var tempArr = item.substring(1).split("=");
                var key = decodeURIComponent(tempArr[0]);
                var value = decodeURIComponent(tempArr[1]);
                result[key] = value;
            });
        }

        return result;
    }

    /**
     * 获取拼音
     * @param str
     * @param sp
     * @returns {string}
     */
    $.getSpell = function (str, sp) {
        var i, c, t, p, ret = "";
        if (sp == null) sp = "";
        for (i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) >= 0x4e00) {
                p = strGB.indexOf(str.charAt(i));
                if (p > -1 && p < 3755) {
                    for (t = qswhSpell.length - 1; t > 0; t = t - 2) if (qswhSpell[t] <= p) break;
                    if (t > 0) ret += qswhSpell[t - 1] + sp;
                }
            } else {
                ret += str.charAt(i);
            }
        }
        return ret.substr(0, ret.length - sp.length);
    }

    /**
     * 获取简短中文拼音
     * @param str
     * @returns {string}
     */
    $.getShortSpell = function (str) {
        var i, c, t, p, ret = "";
        for (i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) >= 0x4e00) {
                p = strGB.indexOf(str.charAt(i));
                if (p > -1 && p < 3755) {
                    for (t = qswhSpell.length - 1; t > 0; t = t - 2) if (qswhSpell[t] <= p) break;
                    if (t > 0) ret += qswhSpell[t - 1].substr(0, 1);
                }
            } else {
                ret += str.charAt(i);
            }
        }
        return ret;
    }
    /**
     *转换日期对象为日期字符串
     * @param date 日期对象
     * @param isFull 是否为完整的日期数据,
     *               为true时, 格式如"2000-03-05 01:05:04"
     *               为false时, 格式如 "2000-03-05"
     * @return 符合要求的日期字符串
     */
    $.getSmpFormatDate = function (date, isFull) {
        var pattern = "";
        if (isFull == true || isFull == undefined) {
            pattern = "yyyy-MM-dd hh:mm:ss";
        } else {
            pattern = "yyyy-MM-dd";
        }
        return $.getFormatDate(date, pattern);
    }
    /**
     *转换当前日期对象为日期字符串
     * @param date 日期对象
     * @param isFull 是否为完整的日期数据,
     *               为true时, 格式如"2000-03-05 01:05:04"
     *               为false时, 格式如 "2000-03-05"
     * @return 符合要求的日期字符串
     */

    $.getSmpFormatNowDate = function (isFull) {
        return $.getSmpFormatDate(new Date(), isFull);
    }
    /**
     *转换long值为日期字符串
     * @param l long值
     * @param isFull 是否为完整的日期数据,
     *               为true时, 格式如"2000-03-05 01:05:04"
     *               为false时, 格式如 "2000-03-05"
     * @return 符合要求的日期字符串
     */

    $.getSmpFormatDateByLong = function (l, isFull) {
        return l ? $.getSmpFormatDate(new Date(l), isFull) : '';
    }
    /**
     *转换long值为日期字符串
     * @param l long值
     * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
     * @return 符合要求的日期字符串
     */

    $.getFormatDateByLong = function (l, pattern) {
        return l ? $.getFormatDate(new Date(l), pattern) : '';
    }
    /**
     *转换日期对象为日期字符串
     * @param l long值
     * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
     * @return 符合要求的日期字符串
     */
    $.getFormatDate = function (date, pattern) {
        if (date == undefined) {
            date = new Date();
        }
        if (pattern == undefined) {
            pattern = "yyyy-MM-dd hh:mm:ss";
        }
        return date.format(pattern);
    }

    /**
     * 判断字符串是否是纯数字
     */
    $.strIsNumber = function (param) {
        var reg = new RegExp(/^(-?\d+)(\.\d+)?$/);
        return reg.test(param);
    }

    /**
     * 字符串转换为json
     */
    $.strToJson = function (str) {
        if (typeof str === 'string') {
            return JSON && JSON.parse(str);
        }
    }

    /**
     * json转换为字符串
     */
    $.jsonToStr = function (json) {
        if (typeof json === 'object') {
            return JSON && JSON.stringify(json);
        }
    }

    /**
     * 过滤字符串,去掉头尾空格
     *
     * @method trim
     * @param {String}
     *            str 必选 字符串
     * @returns {String} 去掉空格的字符串
     */
    $.trim = function (str) {
        if (String.prototype.trim) {
            return !str ? "" : String.prototype.trim.call(str);
        } else {
            return !str ? "" : str.replace(/(^\s*)|(\s*$)/g, "");
        }
    }

    /**
     * 过滤所有字符串,去掉所有的空格
     *
     * @method trimAll
     * @param {String}
     *            str 必选 字符串
     * @returns {String} 去掉空格的字符串
     */
    $.trimAll = function (str) {
        return str.replace(/\s*/g, '');
    }

    // 将字符串转化成dom对象;string转换为xml
    $.strToXml = function (xmlString) {
        var xmlDoc;
        if (typeof xmlString == "string") {
            // FF
            if (document.implementation.createDocument) {
                var parser = new DOMParser();
                xmlDoc = parser.parseFromString(xmlString, "text/xml");
            } else if (window.ActiveXObject) {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async = false;
                xmlDoc.loadXML(xmlString);
            }
        } else {
            xmlDoc = xmlString;
        }
        return xmlDoc;
    }

    // xml转换为string
    $.xmlToStr = function (xmlDoc) {
        if (window.ActiveXObject) {
            return xmlDoc.xml; // IE
        } else {
            return (new XMLSerializer()).serializeToString(xmlDoc); // FF
        }
    }

    // 格式化xml
    $.formatXmlStr = function (str) {
        return str.replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll(
            "\"", "&quot;");
    }

    /**
     * 过滤所有字符串,将匹配正则表达式字符替换为指定的字符
     *
     * @method replaceAll
     * @param {String}
     *            regexp 必选 正则表达式
     * @param {String}
     *            str 必选 指定替换的字符
     * @returns {String} 处理后的字符串
     */
    String.prototype.replaceAll = function (regexp, str) {
        return this.replace(new RegExp(regexp, "gm"), str);
    }

    /**
     * 将null或者undefined转换为字符串
     * @param str
     * @param def
     * @returns {*}
     */
    $.nullToBlank = function (str, def) {
        if (str === '' || str === null || str === undefined) {
            return def || ''
        }
        return str
    }

    $.getCode = function (codeNo, success, failure) {
        $.requestServer({
            url: $.globvar.basePath + '/capinfoCommon/getCode',
            data: {
                codeNo: codeNo
            },
            mask: false,
            success: success,
            error: failure
        })
    }

    $.getCodes = function (codeNos, success, failure) {
        $.requestServer({
            url: $.globvar.basePath + '/capinfoCommon/getCodes',
            data: {
                codeNos: codeNos
            },
            mask: false,
            success: success,
            error: failure
        })
    }

    /**
     * ajax封装
     *
     */
    $.pendingRequestList = {};
    $.requestServer = function (options) {
        var defaultOpts = {
            type: "post",
            dataType: "json",
            url: "",
            beforeSend: function (xhr, settings) {
                // 统一处理ajax重复提交
                var key = settings.url + settings.data;
                if (!$.pendingRequestList[key]) {
                    $.pendingRequestList[key] = xhr;
                } else {
                    return false;// 直接终止本次请求,不调用error方法
                }
                var complete = settings.complete;
                settings.complete = function (status, xhr, settings) {
                    $.pendingRequestList[key] = null;
                    if ($.isFunction(complete)) {
                        complete.apply(this, arguments);
                    }
                };
            },
            success: function (data, xhr, settings) {
            },
            error: function (error, type, xhr, settings) {
            },
            async: true,
            traditional: true,//设置为true时可以直接传递数组参数
            mask: true,
            masktitle: "提示",
            maskmsg: "程序处理中,请稍候...",
            masktext: "loading..."
        };
        var opts = $.extend(true, {}, defaultOpts, options);
        if (opts["mask"]) {
            $.messager.mask({
                title: opts["masktitle"],
                msg: opts["maskmsg"],
                text: opts["masktext"]
            });
        }
        opts["success"] = function (data, xhr, settings) {
            if (opts['mask']) {
                $.messager.mask("close");
            }
            if (data && data[$.RV]) {
                if (data[$.RV] === $.RV_S) {
                    $.messager.alert("提示", data[$.RM], "info", function () {
                        (options["success"] || function (data, xhr,
                                                         settings) {
                        })(data, xhr, settings);
                    });
                } else {
                    $.messager.alertError(data);
                }
            } else {
                var success = options['success'];
                if (success && typeof success === 'function'){
                    success.apply(this,arguments);
                }
            }
        };
        opts["error"] = function (xhr, type, error) {
            if (opts['mask']) {
                $.messager.mask("close");
            }
            if (type !== "abort" && type !== "parsererror") {// 如果是手动阻止的请求,不显示错误信息
                $.messager.alert("提示", "网络连接错误,请稍后重试", "error");
            }
            var error = options['error'];
            if (error && typeof error === 'function'){
                error.apply(this,arguments);
            }
        };
        // 初始session失效后的重定向
        opts["complete"] = function (xhr, status) {
            /*
             * var rt = xhr.responseText; if (rt && rt.indexOf("!need login!") >
             * -1) { // $("body").append(rt);
             * $.messager.alert("提示","您的会话已过期","error") } (options["complete"] ||
             * function(xhr, status) { })(xhr, status);
             */
        };
        // delete opts["mask"];
        // delete opts["maskmsg"];
        // delete opts["masktitle"];
        // delete opts["masktext"];
        $.ajax(opts);
    }

    //简单校验身份证合法性
    $.simpleCheckIdcard = function (idcard) {
        return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(idcard);
    }

    //复杂校验身份证合法性
    $.checkIdcard = function (idcard) {
        var Errors = ["验证通过!",
            "身份证号码位数不对!",
            "身份证号码出生日期超出范围或含有非法字符!",
            "身份证号码校验错误!",
            "身份证地区非法!"];
        var area = {
            11: "北京",
            12: "天津",
            13: "河北",
            14: "山西",
            15: "内蒙古",
            21: "辽宁",
            22: "吉林",
            23: "黑龙江",
            31: "上海",
            32: "江苏",
            33: "浙江",
            34: "安徽",
            35: "福建",
            36: "江西",
            37: "山东",
            41: "河南",
            42: "湖北",
            43: "湖南",
            44: "广东",
            45: "广西",
            46: "海南",
            50: "重庆",
            51: "四川",
            52: "贵州",
            53: "云南",
            54: "西藏",
            61: "陕西",
            62: "甘肃",
            63: "青海",
            64: "宁夏",
            65: "新疆",
            71: "台湾",
            81: "香港",
            82: "澳门",
            91: "国外"
        };

        //var idcard=idcard;
        var Y, JYM;
        var S, M;
        var idcard_array = new Array();
        idcard_array = idcard.split("");
        //地区检验
        if (area[parseInt(idcard.substr(0, 2))] == null) {
            //alert(Errors[4]);
            //setItemFocus(0, 0, "CertID");
            return Errors[4];
        }
        var ereg;

        //身份号码位数及格式检验
        switch (idcard.length) {
            case 15:
                if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 )) {
                    ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
                } else {
                    ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
                }

                if (ereg.test(idcard)) {
                    //alert(Errors[0]);
                    //setItemFocus(0, 0, "CertID");
                    return true;

                } else {
                    //alert(Errors[2]);
                    //setItemFocus(0, 0, "CertID");
                    return Errors[2];
                }
                break;
            case 18:
                //18位身份号码检测
                //出生日期的合法性检查
                //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
                //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
                if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0 )) {
                    ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
                } else {
                    ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
                }
                if (ereg.test(idcard)) {//测试出生日期的合法性
                    //计算校验位
                    S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
                        + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
                        + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
                        + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
                        + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
                        + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
                        + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
                        + parseInt(idcard_array[7]) * 1
                        + parseInt(idcard_array[8]) * 6
                        + parseInt(idcard_array[9]) * 3;
                    Y = S % 11;
                    M = "F";
                    JYM = "10X98765432";
                    M = JYM.substr(Y, 1);//判断校验位
                    if (M == idcard_array[17]) {
                        return true;
                        //Errors[0];        //检测ID的校验位
                    } else {
                        //alert(Errors[3]);
                        //setItemFocus(0, 0, "CertID");
                        return Errors[3];
                    }
                } else {
                    //alert(Errors[2]);
                    //setItemFocus(0, 0, "CertID");
                    return Errors[2];
                }
                break;
            default:
                //alert(Errors[1]);
                //setItemFocus(0, 0, "CertID");
                return Errors[1];
                break;
        }
    };

    /*
     * 比较两个日期的大小
     * 传入的参数推荐是"yyyy-mm-dd"的格式,其他的日期格式也可以,但要保证一致
     */
    $.dateCompare = function (date1, date2) {
        if (date1 && date2) {
            var a = new Date(date1);
            var b = new Date(date2);
            return a < b;
        }
    };
    /* 
     * @author : zhanghaonan
     * @desc: 比较两个时间的大小(传入的参数是"HH:mm"的格式,)
     * @param: time1:目标时间;time2:被比较时间
     */
    $.timeCompare = function (time1, time2) {
        //console.info(time1+"-"+time2);
        try {
            if (time1 && time2) {
                var t1 = parseInt(time1.split(":")[0] * 60) + parseInt(time1.split(":")[1]);
                var t2 = parseInt(time2.split(":")[0] * 60) + parseInt(time2.split(":")[1]);
                return t1 < t2;
            }
            return false;
        } catch (e) {
            return false;
        }
    };
    /* 
     * @author : zhanghaonan
     * @desc: 比较两个时间的大小,支持的格式可在formatArr扩展
     * @param: datetime1:目标时间;datetime2:被比较时间
     */
    $.dateTimeCompare = function (datetime1, datetime2) {

        var formatArr = ['YYYY-MM-DD',
            'YYYY-MM-DD HH:mm',
            'YYYY-MM-DD HH:mm:ss'];//支持的格式
        try {
            if (datetime1 && datetime2) {
                var dt1 = moment(datetime1, formatArr);
                var dt2 = moment(datetime2, formatArr);
//                console.info(dt1+","+dt2);
                return dt1 < dt2;
            }
            return false;
        } catch (e) {
            return false;
        }
    };
    //获取服务器时间
    $.getServerTime = function (){
            var date = new Date($.ajax({async: false}).getResponseHeader("Date"));
            var bombay = date + (3600000 * 8);
            var time = new Date(bombay);
            return time;
        }

    /**
     * 获取元素的outerHTML
     */
    $.fn.outerHTML = function () {

        // IE, Chrome & Safari will comply with the non-standard outerHTML, all others (FF) will have a fall-back for cloning
        return (!this.length) ? this : (this[0].outerHTML ||
            (function (el) {
                var div = document.createElement('div');
                div.appendChild(el.cloneNode(true));
                var contents = div.innerHTML;
                div = null;
                return contents;
            })(this[0]));

    };

})(jQuery);


(function ($) {
    /**
     * ajax完成后判断登录权限
     */
    $(document).ajaxComplete(function (event, request, settings) {
        var rt = request.responseText;
        if (rt && rt.indexOf("!need login!") > -1) {
            $(event.currentTarget).find("body").append(rt);
        }
    });

})(jQuery);

// jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support
(function(jQuery){

    if(jQuery.browser) return;

    jQuery.browser = {};
    jQuery.browser.mozilla = false;
    jQuery.browser.webkit = false;
    jQuery.browser.opera = false;
    jQuery.browser.msie = false;

    var nAgt = navigator.userAgent;
    jQuery.browser.name = navigator.appName;
    jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion);
    jQuery.browser.majorVersion = parseInt(navigator.appVersion,10);
    var nameOffset,verOffset,ix;

    // In Opera, the true version is after "Opera" or after "Version"
    if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
        jQuery.browser.opera = true;
        jQuery.browser.name = "Opera";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+6);
        if ((verOffset=nAgt.indexOf("Version"))!=-1)
            jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
    }
    // In MSIE, the true version is after "MSIE" in userAgent
    else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
        jQuery.browser.msie = true;
        jQuery.browser.name = "Microsoft Internet Explorer";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+5);
    }
    // In Chrome, the true version is after "Chrome"
    else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
        jQuery.browser.webkit = true;
        jQuery.browser.name = "Chrome";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+7);
    }
    // In Safari, the true version is after "Safari" or after "Version"
    else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
        jQuery.browser.webkit = true;
        jQuery.browser.name = "Safari";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+7);
        if ((verOffset=nAgt.indexOf("Version"))!=-1)
            jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
    }
    // In Firefox, the true version is after "Firefox"
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
        jQuery.browser.mozilla = true;
        jQuery.browser.name = "Firefox";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
    }
    // In most other browsers, "name/version" is at the end of userAgent
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) <
        (verOffset=nAgt.lastIndexOf('/')) )
    {
        jQuery.browser.name = nAgt.substring(nameOffset,verOffset);
        jQuery.browser.fullVersion = nAgt.substring(verOffset+1);
        if (jQuery.browser.name.toLowerCase()==jQuery.browser.name.toUpperCase()) {
            jQuery.browser.name = navigator.appName;
        }
    }
    // trim the fullVersion string at semicolon/space if present
    if ((ix=jQuery.browser.fullVersion.indexOf(";"))!=-1)
        jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix);
    if ((ix=jQuery.browser.fullVersion.indexOf(" "))!=-1)
        jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix);

    jQuery.browser.majorVersion = parseInt(''+jQuery.browser.fullVersion,10);
    if (isNaN(jQuery.browser.majorVersion)) {
        jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion);
        jQuery.browser.majorVersion = parseInt(navigator.appVersion,10);
    }
    jQuery.browser.version = jQuery.browser.majorVersion;
})(jQuery);

 

转载于:https://www.cnblogs.com/learnjfm/p/8057431.html

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值