PageSourceSearch

https://res.jzyx.com/themes/commons/js/jz.base_v2.js

js jzyx.com collected 2026-09-25 02:46:42 UTC 45,286 bytes, 1,291 lines download raw bytes

1/**
2 * date 2011-11-21
3 * descript 此js文件为公共js文件包括以下组件, 依赖与jquery库
4     1、html5的支持
5     2、跨域的问题domain设置
6     3、ie6 背景图片修复
7    4、Ajax不做缓存
8     5、遮罩层
9     6、基础层
10     7、表单校验
11     8、登录层
12     9、简单事件处理EventBus
13    10、user layer
14*/
15
16
17(function(){
18    //-----------------------------
19    //1、html5的支持
20    //-----------------------------
21    var naviAgent = navigator.userAgent;
22    var naviVer = "MSIE";
23    var isIE = naviAgent.indexOf(naviVer)!=-1;
24    var flag = false;
25    if(isIE){flag = true;}
26
27    if(flag){
28    // iepp v2.1pre @jon_neal & @aFarkas github.com/aFarkas/iepp
29    // html5shiv @rem remysharp.com/html5-enabling-script
30    // Dual licensed under the MIT or GPL Version 2 licenses
31    /*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");return a.innerHTML="<elem></elem>",a.childNodes.length!==1}())return;a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|subline|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=b.getElementsByTagName("script")[0].parentNode,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){try{if(a+""===undefined)return""}catch(d){return""}var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,p.test(b)&&h.push(c.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},c.parseCSS=function(a){var b=[],c;while((c=j.exec(a))!=null)b.push(((i.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(g,"$1.iepp-$2")+c[4]);return b.join("\n")},c.writeHTML=function(){var a=-1;q=q||b.body;while(++a<f){var c=b.getElementsByTagName(e[a]),d=c.length,g=-1;while(++g<d)c[g].className.indexOf("iepp-")<0&&(c[g].className+=" iepp-"+e[a])}k.appendChild(q),l.appendChild(n),n.className=q.className,n.id=q.id,n.innerHTML=q.innerHTML.replace(h,"<$1font")},c._beforePrint=function(){if(c.disablePP)return;o.styleSheet.cssText=c.parseCSS(c.getCSS(b.styleSheets,"all")),c.writeHTML()},c.restoreHTML=function(){if(c.disablePP)return;n.swapNode(q)},c._afterPrint=function(){c.restoreHTML(),o.styleSheet.cssText=""},r(b),r(k);if(c.disablePP)return;m.insertBefore(o,m.firstChild),o.media="print",o.className="iepp-printshim",a.attachEvent("onbeforeprint",c._beforePrint),a.attachEvent("onafterprint",c._afterPrint)})(this,document)@*/
32    }
33
34    //-----------------------------
35    //2、跨域的问题domain设置
36    //-----------------------------
37    if($(document).find("script").attr("src").indexOf("WdatePicker.js") < 0){
38        if(window.location.href && window.location.href.indexOf("woobest.com") > 0) {
39            document.domain = "woobest.com";
40        }else if(window.location.href && window.location.href.indexOf("2288wxy.cn") > 0){
41            document.domain = "2288wxy.cn";
42        }else{
43            document.domain = "jzyx.com";
44        }
45    }
46
47    //-----------------------------
48    //3、修复ie6图片载入bug
49    //-----------------------------
50    try{document.execCommand("BackgroundImageCache", false, true);}catch(e){}
51
52    //-----------------------------
53    //4、Ajax不做缓存
54    //-----------------------------
55    $.ajaxSetup ({cache: false});
56})();
57
58/**
59    给Function的原型添加了两个方法
60    createDelegate(obj,args,appendArgs) obj 来改变function的this,args为传入的参数
61*/
62Function.prototype.createDelegate = function(obj, args, appendArgs){
63    var method = this;
64    return function() {
65        var callArgs = args || arguments;
66        if(appendArgs === true){
67            callArgs = Array.prototype.slice.call(arguments, 0);
68            callArgs = callArgs.concat(args);
69        }else if(typeof appendArgs == "number"){
70            callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
71            var applyArgs = [appendArgs, 0].concat(args); // create method call params
72            Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
73        }
74        return method.apply(obj || window, callArgs);
75    };
76};
77
78var Jz = {
79    namespace : function() {
80        var a=arguments, o=null, i, j, d;
81        for (i=0; i<a.length; i=i+1) {
82            d=a[i].split(".");
83            o=Jz;
84
85            for (j=(d[0] == "Jz") ? 1 : 0; j<d.length; j=j+1) {
86                o[d[j]]=o[d[j]] || {};
87                o=o[d[j]];
88            }
89        }
90        return o;
91    },
92    extend : function(subc, superc, overrides) {
93            var F = function() {};
94            F.prototype=superc.prototype;
95            subc.prototype=new F();
96            subc.prototype.constructor=subc;
97            subc.superclass=superc.prototype;
98
99            if (superc.prototype.constructor == Object.prototype.constructor) {
100                superc.prototype.constructor=superc;
101            }
102
103            if (overrides) {
104                for (var i in overrides) {
105                    subc.prototype[i]=overrides[i];
106                }
107            }
108    },
109    apply : function(o, c){
110        if(o && c && typeof c == 'object'){
111            for(var p in c){
112                o[p] = c[p];
113            }
114        }
115        return o;
116    },
117    unique : 0,
118    getUnique : function() {
119        return "Jz-"+(++Jz.unique);
120    },
121    get : function(el) {
122        return (typeof el == "string"?$("#"+el):el);
123    },
124    getBodyMask :function() {
125        if(!Jz.bodyMaskInst) {
126            Jz.bodyMaskInst = new Jz.mask($(document.body), {isLoading: false});
127        }
128        return Jz.bodyMaskInst;
129    },
130    isJson :function(text){
131        try {
132            var json = eval("("+text+")");
133            if (typeof json == 'xml') {
134                return false;
135            }
136            return json;
137        } catch(e) {
138            return false;
139        }
140    },
141    focus :function(id){
142          var input = (typeof id=="string")?$("#"+id):id;
143          if($.trim(input.val()) == '') {
144              $(function(){input.focus();});
145          }
146    },
147    refresh :function (captchaImg, captchaUrl, captchaInput, captchaFocus){
148        if (captchaUrl.indexOf("?") == -1) {
149            $("#" + captchaImg).attr({src:captchaUrl + "?t=" + Math.random()});
150        } else {
151            $("#" + captchaImg).attr({src:captchaUrl + "&t=" + Math.random()});
152        }
153
154        var input = $("#" + captchaInput).val("");
155        if (captchaFocus) {
156            input.focus();
157        }
158    },
159    loginTimeout :function(request, url, message){
160          if (request.status == 0) {
161            return;
162        }
163
164          if (request.status == 403) {
165            var json = Jz.isJson(request.responseText);
166            if( json && json.respCode == 6000 ) {
167                alert("对不起,登录超时,请重新登录");
168                window.location.href=url;
169                return true;
170            }
171        }
172        alert(message||"对不起,请求超时,请重新连接");
173    },
174    showAjaxFormError :function(formV,json){
175          for(var name in json){
176            var field = formV.form.find("input[name="+name+"]");
177              formV.setState("toError", field, json[name]);
178        }
179    },
180    showLoginLayer :function(oparams) {
181        if (oparams && oparams.url && oparams.tips) {
182            oparams.tips = encodeURI(oparams.tips);
183            if(oparams.url.indexOf("?") != -1) {
184                oparams.url += ("&t="+oparams.tips);
185            } else {
186                oparams.url += ("?t="+oparams.tips);
187            }
188        }
189
190        if (!Jz.loginLayerInst) {
191            Jz.loginLayerInst = new Jz.loginLayer("", {url: oparams.url});
192        }else {
193            Jz.loginLayerInst.loadUrl(oparams.url);
194        }
195        Jz.loginLayerInst.show();
196    },
197    resetLoginHeight :function() {
198        if (Jz.loginLayerInst) {
199            Jz.loginLayerInst.resetHeight();
200        }
201    },
202    showUserLayer: function (oparams) {
203        if (!Jz.userLayerInst) {
204            Jz.userLayerInst = new Jz.userLayer("", {url: oparams.url, title: oparams.title});
205        }else {
206            Jz.userLayerInst.loadUrl(oparams.url, oparams.title);
207        }
208        Jz.userLayerInst.show();
209    },
210    resetUserLayerHigh: function () {
211        if (Jz.userLayerInst) {
212            Jz.userLayerInst.resetHeight();
213        }
214    },
215    resetUserLayerPosition: function () {
216        if (Jz.userLayerInst) {
217            Jz.userLayerInst.rePosition();
218            Jz.userLayerInst.el.css(Jz.userLayerInst.pos);
219        }
220    },
221
222    // 框架层内关闭
223    closeFrameLayerHandle: function (data) {
224        var data = data || {};
225        if (window.parent) {
226            var key = data.frameKey;
227            var url = data.frameUrl ? data.frameUrl : location.href;
228
229            switch (key) {
230                // 关闭层并跳转到指定地址
231                case "outer":
232                    window.parent.location.replace(url);
233                    break;
234
235                // 层内跳转到指定地址
236                case "inner":
237                    window.location.replace(url);
238                    break;
239
240                // 关闭层不刷新址
241                case "hold":
242                    window.parent.Jz.userLayerInst.hide();
243                    break;
244
245                // 关闭层并刷新当前页(默认)
246                default:
247                    window.parent.location.reload();
248                    break;
249            }
250        }
251    },
252    msie: function () {
253        var ua = navigator.userAgent,
254            ie = !!ua.match(/MSIE/i),
255            ver = null;
256
257        if (ie) {
258            ua = ua.slice(ua.indexOf('MSIE '));
259            ver = Number(ua.slice(ua.indexOf(' ') + 1, ua.indexOf('.')));
260        }
261
262        return ver;
263    }
264};
265
266Jz.namespace("util","form");
267
268/**
269 * 观察者类
270 * 主要用来处理事件机制的
271 */
272Jz.util.Observer = function() {
273    if(!this.listeners) {
274        this.listeners = {};
275    }
276}
277Jz.util.Observer.prototype = {
278    addEvent :function(event) {
279        for(var eventName in event){
280            this.listeners[eventName] = new Jz.util.CustomEvent(eventName,this);
281        }
282    },
283    on :function(eventName,fn) {
284        this.listeners[eventName].on(fn);
285    },
286    un :function(eventName,fn) {
287        return this.listeners[eventName].un(fn);
288    },
289    fireEvent :function(eventName,args) {
290        this.listeners[eventName].fire(args);
291    },
292    unsubscribeAll :function() {
293        this.listeners[eventName].unsubscribeAll();
294    }
295};
296
297Jz.util.CustomEvent = function(type, oScope) {
298
299    this.type = type;
300    this.subscribers = [];
301    this.scope = oScope || window;
302}
303Jz.util.CustomEvent.prototype = {
304    on: function(fn) {
305        this.subscribers.push(new Jz.util.Subscriber(fn, this.scope));
306    },
307    un: function(fn) {
308        var found = false;
309        for (var i=0, len=this.subscribers.length; i<len; ++i) {
310            var s = this.subscribers[i];
311            if (s && s.contains(fn, s.scope)) {
312                this._delete(i);
313                found = true;
314            }
315        }
316        return found;
317    },
318    fire: function(args) {
319         var length = this.subscribers.length;
320         for(var i=0;i<length;i++){
321             var s = this.subscribers[i];
322             s.fn.apply(s.obj, args);
323         }
324    },
325    unsubscribeAll: function() {
326        for (var i=this.subscribers.length-1; i>-1; i--) {
327            this._delete(i);
328        }
329
330        this.subscribers=[];
331        return i;
332    },
333    _delete :function(index) {
334        var s = this.subscribers[index];
335        if (s) {
336            delete s.fn;
337            delete s.obj;
338        }
339        this.subscribers.splice(index, 1);
340    }
341};
342
343
344Jz.util.Subscriber = function(fn, obj) {
345    this.fn = fn;
346    this.obj =  obj||null;
347};
348
349Jz.util.Subscriber.prototype = {
350    contains : function(fn, obj) {
351        if (obj) {
352            return (this.fn == fn && this.obj == obj);
353        } else {
354            return (this.fn == fn);
355        }
356    }
357};
358
359//-----------------------------
360//遮罩层组件 开始,一般情况下一个也没只有一个遮罩层
361//-----------------------------
362Jz.mask = function(parent, config){
363
364    this.parent = Jz.get(parent);
365    this.config = config || {};
366    Jz.mask.superclass.constructor.call(this);
367}
368Jz.extend(Jz.mask,Jz.util.Observer,{
369
370    rendered :false,
371    init :function() {
372
373        if(this.rendered===true) {
374            return ;
375        }
376        this.rendered = true;
377
378        var html = [
379            '<div class="jz-mask">',
380                '<iframe frameborder="0"></iframe>',
381                '<div class="jz-mask-opacity" style="opacity:0.4;filter:alpha(opacity=40)"></div>',
382                (this.config.isLoading?'<div class="jz-mask-text">加载中请稍后...</div>':""),
383            '</div>'
384        ].join("");
385
386        this.el = $(html);
387        this.el.css({left:-10000,top:-10000});
388        this.maskText = this.el.find(".jz-mask-text");
389
390        //var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
391        this.maskText.css({position:"absolute"});
392
393        this.parent.append(this.el);
394    },
395    setMaskTextPos :function() {
396        var top = (($(window).height() / 2) - (this.maskText.outerHeight() / 2)) ;
397        var left = (($(window).width() / 2) - (this.maskText.outerWidth() / 2)) + 80;
398        if( top < 0 ) top = 0;
399        if( left < 0 ) left = 0;
400
401        //if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
402
403        this.maskText.css({top: top, left: left});
404    },
405    show :function() {
406        this.init();
407        this.el.css({top:0,left:0});
408        this.el.height($(document).height());
409        this.el.css({display:"block"});
410    },
411    hide :function() {
412        this.el.css({top:-10000,left:-10000});
413    },
414    reset :function() {
415        if(this.el && this.el.css("display") == "block" && this.el.css("top") == "0px"){
416            this.el.css({top:0,left:0});
417            this.el.height($(document).height());
418        }
419    }
420});
421//-----------------------------
422//遮罩层组件 结束
423//-----------------------------
424
425
426//-----------------------------
427//基础层的结构
428//如果有特殊层需要自己继承Jz.layer来实现
429//-----------------------------
430Jz.layer = function(el,config){
431
432    this.config = config;
433    this.el = Jz.get(el);
434
435    if (this.el.parent().get(0) != document.body) {
436        $(document.body).append(this.el);
437    }
438    Jz.layer.superclass.constructor.call(this);
439    this.addEvent({"hide": true});
440}
441
442Jz.extend(Jz.layer, Jz.util.Observer,{
443    rended:false,
444    init :function() {
445        if(this.readed)return;
446        this.readed = true;
447        this.el.find(".closeLayer").click(this.hide.createDelegate(this));
448        this.initDomImp();
449        this.initPos();
450    },
451    initDomImp :function(){
452        //构造你的layer中的结构
453    },
454    show :function(params){
455        this.init();
456        this.showImp(params);
457
458        if (this.config.animate) {
459            var width = this.el.width();
460            var height = this.el.height();
461            this.el.css({width:0,height:0});
462
463            this.el.animate({top:this.pos.top,left:this.pos.left, opacity:"toggle",width:width,height:height},function(){
464                $(this).css({height:""});
465            });
466        } else {
467            this.initPos();
468            this.el.css({top:this.pos.top,left:this.pos.left});
469            this.el.show();
470        }
471
472        if(this.config.showMask!==false){
473            this.mask.show();
474        }
475
476        if(this.config.escKey !== false) {
477            //this.addEscKey();
478        }
479
480        if(this.config.dragable){
481            this.initDrag();
482        }
483
484    },
485    initDrag :function(){
486        var self = this;
487        var distanceW = 0;
488        var distanceH = 0;
489        var layerOffset = {left:0,top:0};
490
491        var startDragFlag = true;
492
493        var dragEl = null;
494
495        var onMouseUp = function(){
496            startDragFlag = true;
497            $(dragEl).css({cursor:""});
498            $(document).unbind("mousemove",onDraging);
499            $(document).unbind("mouseup",onMouseUp);
500        }
501
502        var onDraging = function(e){
503            var currentX = e.pageX;
504            var currentY = e.pageY;
505            var settingTop = currentY-distanceH;
506            var settingLeft = currentX-distanceW;
507            if(settingTop<=0){settingTop=0}
508            if(settingLeft<=0){settingLeft=0}
509            self.el.css({top:settingTop,left:settingLeft});
510        }
511
512        var onStartDrag = function(x,y){
513            if(!startDragFlag)return;
514            $(dragEl).css({cursor:"move"});
515            $(document).bind("mousemove",onDraging);
516            $(document).bind("mouseup",onMouseUp);
517
518            distanceW = x - layerOffset.left;
519            distanceH = y - layerOffset.top;
520
521            startDragFlag = false;
522        }
523
524        var onMouseDown = function(e){
525            layerOffset = self.el.offset();
526            var x = e.pageX;
527            var y = e.pageY;
528            dragEl = $(this);
529            onStartDrag(x,y);
530        }
531
532        this.el.find(".layerTop").bind("mousedown",onMouseDown);
533
534        if (Jz.msie() !== null){
535            this.el.find(".layerTop").get(0).onselectstart = function(){
536                return false;
537            }
538        }
539
540    },
541    showImp :function(params){
542        //如果show,有需要的初始化,实现它
543    },
544    hide :function(){
545        if(this.config.animate) {
546            this.el.animate({top:this.popPos.top,left:this.popPos.left,width:"toggle",he
546ight:"toggle", opacity:"toggle"},function(){
547                $(this).css({height:""});
548            });
549        }
550        else{
551            this.el.hide();
552        }
553        if(this.config.showMask!==false){
554            this.mask.hide();
555        }
556        this.hideImp();
557        this.fireEvent("hide", this);
558    },
559    hideImp :function(){
560        //如果hide后需要清理一些东西,这个地方实现一下
561    },
562    setCurrPos :function(pos) {
563        this.popPos = pos;
564        this.el.css(pos);
565    },
566    initPos :function(){
567        //var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
568        this.el.css({
569            position: this.config.fix ? 'fixed' : 'absolute',
570            zIndex: 99999
571        });
572        var self = this;
573        $(window).bind('resize',function(){
574            self.rePosition.call(self);
575            self.el.css(self.pos);
576        });
577        this.mask = Jz.getBodyMask();
578        this.rePosition();
579    },
580    rePosition :function(){
581        var top = (($(window).height() / 2) - (this.el.outerHeight() / 2)) ;
582        var left = (($(window).width() / 2) - (this.el.outerWidth() / 2)) + 0;
583        if( top < 0 ) top = 0;
584        if( left < 0 ) left = 0;
585
586        top = this.config.fix ? top : top + $(window).scrollTop();
587
588        if(typeof(this.config.setTop) == "number") {
589            top = this.config.setTop;
590        }
591
592        if(typeof(this.config.setLeft) == "number") {
593            left = this.config.setLeft;
594        }
595
596        this.pos = {top:top,left:left};
597
598        try {
599            this.mask.reset();
600        } catch(e) {
601        }
602    },
603    addEscKey :function() {
604        var self = this
605        var onKeyUp = function(e){
606            if(e.keyCode==27){
607                if(e.target&&e.target.type=="file"){return;}
608                 self.hide();
609                 $(document.body).unbind("keyup",onKeyUp);
610             }
611        }
612        $(document.body).bind("keyup",onKeyUp);
613    }
614});
615
616//-----------------------------
617//基础层的结构 结束
618//-----------------------------
619
620
621//-----------------------------
622//表单校验功能
623// 1、滚动到某一个焦点功能
624// 2、成功和错误提示
625//-----------------------------
626Jz.form.Validator = function(el,config) {
627
628    this.form = Jz.get(el);
629    this.config = config;
630    this.valids = {}
631
632    Jz.form.Validator.superclass.constructor.call(this);
633    this.init();
634}
635
636Jz.extend(Jz.form.Validator,Jz.util.Observer,{
637    init :function() {
638        this.form.bind("submit",this.submit.createDelegate(this));
639
640        this.form.find("input[type='submit']").hover(function () {
641            $(this).addClass("hover");
642        }, function () {
643            $(this).removeClass("hover");
644        });
645    },
646    breakInputFn :function(input) {
647
648        if(this.config.breakInput !== true) {
649            return false;
650        }
651
652        if(input && this.breakInput == null) {
653            this.breakInput = input;
654            window.scrollTo(0, input.offset().top-10);
655        }else if(!input) {
656            this.breakInput = null;
657        }
658    },
659    execute :function(type, valids){
660        var $obj = null;
661        var val = "";
662        for(var i = 0 ; i < valids.length ; i++) {
663            var valid = valids[i];
664            $obj = this.getItem(valid);
665            if($obj.length==0){
666                continue;
667            }
668            if(this.config.hiddenBreak === true) {
669                if($obj.parents("fieldset").css("display") == "none") {
670                    return true;
671                }
672            }
673            val = $.trim($obj.val());
674            var result = valid.rule(type,val,$obj,valid.params);
675            if(result!==true){
676                this.setState("toError",$obj,result);
677                this.breakInputFn($obj);
678                return false;
679            }
680        }
681
682        if(this.config.successFlag) {
683            if(val == "") {
684                this.setState("toHelp",$obj);
685            } else {
686                this.setState("toSuccess",$obj);
687            }
688        } else {
689            this.setState("toHelp",$obj);
690        }
691
692        return true;
693    },
694    executeAll :function() {
695
696        this.breakInputFn();
697
698        var flag = true;
699        for(var id in this.valids) {
700            var result = this.execute("submit",this.valids[id]);
701
702            if(result!==true){
703                flag = false;
704                if(this.config.errorBreak){
705                    break;
706                }
707            }
708        }
709
710        if(flag !== true) {
711            return false;
712        }
713
714        return (typeof this.config.onsubmit=="function")?this.config.onsubmit():true;
715    },
716    hiddenBreakLast :false,
717    setHiddenBreakLast :function(hiddenBreakLast) {
718        this.hiddenBreakLast = hiddenBreakLast;
719    },
720    submit :function(e) {
721        // 提交前需要处理自定义的东西的时候
722        if (this.config.beforeOnSubmit && typeof this.config.beforeOnSubmit === 'function' && this.config.beforeOnSubmit() !== true) {
723            e.stopPropagation();
724            e.preventDefault();
725            return false;
726        }
727
728        //隐藏时候不实现回车提交功能
729        if(this.config.hiddenBreak === true && !this.hiddenBreakLast) {
730            e.stopPropagation();
731            e.preventDefault();
732            return false;
733        }
734        if(this.executeAll() !== true){
735            e.stopPropagation();
736            e.preventDefault();
737        } else if (typeof this.config.submitTip != "undefined"){
738
739            var submit_btn = this.form.find("input[type=submit]");
740            submit_btn.attr({disabled:true}).addClass(this.config.disCls);
741            submit_btn.val(this.config.submitTip);
742        }
743    },
744    add :function($query, rule, paramsObj){
745
746        var item = {id:$query,rule:rule,params:paramsObj};
747        if(this.valids[$query]) {
748
749            this.valids[$query].push(item);
750        } else {
751
752            this.valids[$query] = [item];
753            this.addEvent(item);
754        }
755    },
756    setState :function(state, $obj, tips) {
757        if(!$obj.get(0)){return;}
758        var tdEl,help,error;
759
760        fieldObj = $obj.parents("div.field");
761        help = fieldObj.find("p.help");
762        error = fieldObj.find("p.error");
763
764        var hasSuccess = fieldObj.hasClass("jz-success");
765        fieldObj.removeClass("jz-error").removeClass("jz-focus").removeClass("jz-help").removeClass("jz-success").removeClass("jz-check");
766
767        if(state == "toHelp") {
768            fieldObj.addClass("jz-help");
769            if(tips) {
770                help.text(tips);
771            }
772            error.empty();
773
774            if(hasSuccess) {
775                fieldObj.addClass("jz-success");
776            }
777        }
778        else if(state == "toError") {
779            error.html(tips);
780            fieldObj.addClass("jz-error");
781        }else if(state == "toFocus"){
782            if(hasSuccess){
783                fieldObj.addClass("jz-success");
784            }
785            fieldObj.addClass("jz-focus");
786        }else if(state == "toSuccess"){
787            fieldObj.addClass("jz-success");
788        }else if(state == "toCheck"){
789            fieldObj.addClass("jz-check");
790        }
791    },
792    addEvent :function(item) {
793        var self = this;
794        var $obj = this.getItem(item);
795        var tagName = $obj.get(0)?$obj.get(0).tagName:"";
796            tagName = tagName.toUpperCase();
797
798        if(tagName == "INPUT" || tagName == "TEXTAREA") {
799            $obj.bind("focus",function(){
800                self.setState("toFocus",$obj);
801            });
802            $obj.bind("blur",function(){
803                self.execute.call(self,"blur",self.valids[item.id]);
804            });
805            if(item.params.keyup===true){
806                $obj.bind("keyup",function(){
807                    self.execute.call(self,"keyup",self.valids[item.id]);
808                });
809            }
810        } else if(tagName=="SELECT") {
811            $obj.bind("change",function(){
812                self.execute.call(self,"change",self.valids[item.id]);
813            });
814        }
815    },
816    getItem :function(item) {
817        var query = item.id;
818        if(query.indexOf(".")==-1 && query.indexOf("#")==-1){
819            query = '[name=\''+query+'\']';
820        }
821
822        var $obj = this.form.find(query);
823        return $obj;
824    },
825    remove :function(id) {
826        this.valids[id] = null;
827        delete this.valids[id];
828    }
829});
830
831
832//-----------------------------
833//公共校验方法
834//-----------------------------
835Jz.form.Rule = {
836    EmailReg :/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/,
837    Email :function(type,val,el,paramsObj){
838        if(val.length>50){
839            return "邮箱地址不能超过50个字符";
840        }
841        paramsObj.reg = Jz.form.Rule.EmailReg;
842        return Jz.form.Rule.Format(type,val,el,paramsObj);
843    },
844    Format :function(type,val,el,paramsObj){
845        if(val != ""){
846            if(!paramsObj.reg.test(val)){
847                return paramsObj.tips;
848            }
849        }
850        return true;
851    },
852    Presence :function(type,val,el,paramsObj){
853        if("submit" == type){
854            if(val=="") {
855                return paramsObj.tips;
856            }
857            if(el.get(0).tagName.toUpperCase()=="SELECT" && (val == -1 || val == "")){
858                return paramsObj.tips;
859            }
860        }
861
862        return true;
863    },
864    Length :function(type,val,el,paramsObj){
865        var length = val.length;//Jz.getLength(val);
866
867        if("submit" == type || type == "blur") {
868            if(paramsObj.maxLength){
869
870                if(val!="" && length > paramsObj.maxLength) {
871                    return paramsObj.maxTip;
872                }
873            }
874            if(paramsObj.minLength) {
875                if(val!="" && length < paramsObj.minLength) {
876                    return paramsObj.minTip;
877                }
878            }
879        }
880        return true;
881    },
882    IdNameReg :/^[\u4E00-\u9FA5]+(\W[\u4E00-\u9FA5]+)*$/,
883    IdName :function(type,val,el,paramsObj){
884        paramsObj.reg = Jz.form.Rule.IdNameReg;
885        return Jz.form.Rule.Format(type,val,el,paramsObj);
886    },
887    IdCard :function(type,id,el,paramsObj){
888         if(id==''){
889              return true;
890          }
891         if(type == "submit") {
892
893         }
894         else if(type == "blur"){
895
896         }
897         else {
898             return true;
899         }
900
901         if(id.match(/^\d{6}(19|20)\d{2}[01]\d{1}[0-3]\d{1}(\d{4}|\d{3}x)$/i))
902         {
903             var weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
904             var checkCode = [1, 0, 'x', 9, 8, 7, 6, 5, 4, 3, 2];
905             var s = 0;
906             for(var i=0; i<17; i++)
907             {
908                 s += id.substr(i, 1) * weight[i];
909             }
910             if(checkCode[s%11] != id.substr(17, 1).toLowerCase( )) {
911                 return paramsObj.tips;
912             }
913             var year = parseInt(id.substr(6,4),10);
914             var month = parseInt(id.substr(10,2),10);
915             var day = parseInt(id.substr(12,2),10);
916             var date=new Date(month + '/' + day + '/' + year);
917             if(date.getFullYear()!=year || date.getDate()!=day || date.getMonth()!=(month-1))
918             {
919                 return paramsObj.tips;
920             }
921         }
922         else if(id.match(/^\d{6}\d{2}[01]\d{1}[0-3]\d{1}(\d{3}|\d{2}x)$/i))
923         {
924             var year = parseInt('19'+id.substr(6,2),10);
925
926             if (year < 1913) return paramsObj.tips;
927
928             var month = parseInt(id.substr(8,2),10);
929             var day = parseInt(id.substr(10,2),10);
930             var date=new Date(month + '/' + day + '/' + year);
931             if(date.getFullYear()!=year || date.getDate()!=day || date.getMonth()!=(month-1))
932             {
933                 return paramsObj.tips;
934             }
935         }else{
936             return paramsObj.tips;
937         }
938
939         return true;
940    },
941    AnswerCheck :function(type, val, el, paramsObj) {
942        if(val == "") {
943            return true;
944        }
945        if(!/^([\u4e00-\u9fa5]{2,6}|[A-Za-z ]{3,38})$/.test(val)) {
946            return paramsObj.tips;
947        }
948        return true;
949    },
950    ImgReg :/\.(?:png|jpg|gif|jpeg)$/i,
951    Img :function(type,val,el,paramsObj){
952        paramsObj.reg = Jz.form.Rule.ImgReg;
953        return Jz.form.Rule.Format(type,val,el,paramsObj);
954    },
955    PhoneReg :/^\d{3,4}\-\d{7,8}$/,
956    Phone :function(type,val,el,paramsObj){
957        paramsObj.reg = Jz.form.Rule.PhoneReg;
958        return Jz.form.Rule.Format(type,val,el,paramsObj);
959    },
960    Not :function(){
961        return true;
962    },
963    DigitalReg :/^[0-9]+$/,
964    Digital :function(type,val,el,paramsObj){
965        if (val != "") {
966            paramsObj.reg = Jz.form.Rule.DigitalReg;
967            return Jz.form.Rule.Format(type,val,el,paramsObj);
968        }
969        return true;
970    },
971    EnAndDigitalReg :/^[A-Za-z0-9]+$/,
972    EnAndDigital :function(type,val,el,paramsObj){
973        paramsObj.reg = Jz.form.Rule.EnAndDigitalReg;
974        return Jz.form.Rule.Format(type,val,el,paramsObj);
975    },
976    IntegerReg :/^[1-9][0-9]*$/,
977    Integer :function(type,val,el,paramsObj){
978        paramsObj.reg = Jz.form.Rule.IntegerReg;
979        return Jz.form.Rule.Format(type,val,el,paramsObj);
980    },
981    ZipReg :/^\d{6}$/,
982    Zip :function(type,val,el,paramsObj){
983        paramsObj.reg = Jz.form.Rule.ZipReg;
984        return Jz.form.Rule.Format(type,val,el,paramsObj);
985    },
986    ZwReg :/^[\u4E00-\u9FA5]+$/,
987    Zw :function(type,val,el,paramsObj){
988        paramsObj.reg = Jz.form.Rule.ZwReg;
989        return Jz.form.Rule.Format(type,val,el,paramsObj);
990    },
991    MobileReg :/^1\d{10}$/,
992    Mobile :function(type,val,el,paramsObj){
993        paramsObj.reg = Jz.form.Rule.MobileReg;
994        return Jz.form.Rule.Format(type,val,el,paramsObj);
995    },
996    PhoneAndMobile :function(type,val,el,paramsObj){
997        if(val != ""){
998            if(Jz.form.Rule.MobileReg.test(val)||Jz.form.Rule.PhoneReg.test(val)){return true;}
999            else{ return paramsObj.tips}
1000        }
1001        return true;
1002    },
1003    RmbReg :/^(([1-9]\d*)|0)(\.\d{1,2})?$/,
1004    Rmb :function(type,val,el,paramsObj){
1005        paramsObj.reg = Jz.form.Rule.RmbReg;
1006        return Jz.form.Rule.Format(type,val,el,paramsObj);
1007    },
1008    Rmb5000 :function(type,val,el,paramsObj){
1009        paramsObj.reg = Jz.form.Rule.RmbReg;
1010        var result = Jz.form.Rule.Format(type,val,el,paramsObj);
1011        if(result === true) {
1012            var rmb = parseFloat(val);
1013            if(rmb>5000||rmb==0){
1014                return paramsObj.maxTip;
1015            }
1016        }else{
1017            return result;
1018        }
1019        return true;
1020    },
1021    Account :function(type,val,el,paramsObj){
1022        if (val=="") {
1023            if(type=="blur")return true;
1024            return "请输入账号";
1025        }
1026        if (val.match(/^\d{11}$/)) {
1027            return "暂不支持11位纯数字账号,手机号码可尝试  <a href='http://account.jzyx.com/member/signup.html?w=phone'>手机注册</a>";
1028        }
1029        if (val.match(/^0/) || val.match(/^([0-9])\1{5,}$/) || '0123456789876543210'.indexOf(val) !== -1) return '账号已经被注册';
1030        if (!val.match(Jz.form.Rule.EnAndDigitalReg)) {
1031            return "账号由字母或数字组成";
1032        }
1033        return true;
1034    },
1035    AccountCode: function (type, val, el, paramsObj) { // 快速注册账号验证
1036        if (val != "") {
1037            if (val.indexOf("@") === -1) {
1038                // 个性账号验证
1039                if (val.length < 6 || val.length > 20) return "账号长度为6~20位";
1040                if (val.match(/^\d{11}$/)) return "暂不支持11位纯数字账号";
1041                if (val.match(/^0/) || val.match(/^([0-9])\1{5,}$/) || '0123456789876543210'.indexOf(val) !== -1) return '账号已经被注册';
1042                if (!val.match(Jz.form.Rule.EnAndDigitalReg)) return "账号由字母或数字组成";
1043            } else {
1044                // 邮箱账号验证
1045                if (val.length > 50) return "邮箱账号不超过50个字符";
1046                if (!val.match(Jz.form.Rule.EmailReg)) return "请输入有效的邮箱地址";
1047            }
1048        } else if (type !== "blur") {
1049            return paramsObj.tips;
1050        }
1051        return true;
1052    },
1053    AccountPassword :function (type, val, el, paramsObj) {
1054        if(val != ""){
1055            //判断是否重复
1056            var valArr = val.split("");
1057            var isRepeat = false;
1058            for (var i = 0; i < valArr.length - 1; i++) {
1059                if (valArr[i] == valArr [i + 1]) {
1060                    isRepeat = true;
1061                } else {
1062                    isRepeat = false;
1063                    break;
1064                }
1065            }
1066
1067            //判断是否连续
1068            var numberStr = "01234567890";
1069            var numberStr_io = "09876543210";
1070            var lowercaseStr = "abcdefghijklmnopqrstuvwxyz";
1071            var lowercaseStr_io = "zyxwvutsrqponmlkjihgfedcba";
1072            var capitalStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1073            var capitalStr_io = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
1074
1075            if (isRepeat == true || numberStr.indexOf(val) != -1 || numberStr_io.indexOf(val) != -1 || lowercaseStr.indexOf(val) != -1 || lowercaseStr_io.indexOf(val) != -1 || capitalStr.indexOf(val) != -1 || capitalStr_io.indexOf(val) != -1) {
1076                return paramsObj.tips;
1077            }
1078        }
1079        return true;
1080    },
1081    QQ :function(type,val,el,paramsObj){
1082        if(val != ""){
1083            if(!Jz.form.Rule.EmailReg.test(val) && !(/^[\d]+$/.test(val))) {
1084                return paramsObj.tips;
1085            }
1086        }
1087        return true;
1088    },
1089    CType :function(type,val,el,paramsObj){
1090        if(val != ""){
1091            if(val.length<6||val.length>=15){
1092                return "证件号码格式不正确";
1093            }
1094            if(!/^[a-zA-Z0-9\-\u4e00-\u9fa5]+$/.test(val)){return "证件号码格式不正确";}
1095        }
1096        return true;
1097    },
1098    DateCheck :function(type, val, el, paramsObj) {
1099        if (val == "") {
1100            return true;
1101        }
1102
1103        if(!/((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/.test(val)) {
1104            return "请输入有效的日期,格式为2000-01-01";
1105        }
1106
1107        if(new Date() < new Date(Date.parse(val.replace(/-/g, "/")))) {
1108            return "请输入有效的日期,格式为2000-01-01";
1109        }
1110
1111        return true;
1112    },
1113    Captcha :function(type, val, el, paramsObj){
1114
1115        var inputTip = $("#" + paramsObj.inputTip);
1116        var $em = inputTip.find("em").removeClass("reTrue").removeClass("reFalse");
1117
1118        if(type == "blur" && val == "") {
1119            return true;
1120        }
1121
1122        if(val == "") {
1123            return "请输入验证码";
1124        }
1125        if(val.length!=4) {
1126            return "验证码输入错误";
1127        }
1128
1129        if(inputTip.length == 0) {
1130            inputTip = $('<span class="inputTip" id="captcha-input-tip" ><em></em></span>');
1131            inputTip.insertAfter(el.parent());
1132        }
1133
1134        if(type == "blur") {
1135            if(!paramsObj.url){
1136                return true;
1137            }
1138            $em.removeClass("reTrue").removeClass("reFalse").addClass("loading");
1139            $.ajax({
1140                url:paramsObj.url,
1141                data:{'jza_code' : val, 'jza_position': paramsObj.position},
1142                dataType :"json",
1143                type :"post",
1144                success:function(data){
1145                    if(data.respCode == 0){
1146                        $em.removeClass("loading").addClass("reTrue");
1147                    }else{
1148                        $em.removeClass("loading").addClass("reFalse");
1149                        Jz.form.Validator.prototype.setState("toError", el, paramsObj.tips);
1150                    }
1151                }
1152            });
1153        }else if(type == "submit") {
1154            if($em.hasClass("reFalse")) {
1155                return paramsObj.tips;
1156            }
1157        }
1158
1159        return true;
1160    }
1161};
1162
1163//-----------------------------
1164//登录层的
1165//-----------------------------
1166Jz.loginLayer = function (el, config) {
1167    el = $([
1168        '<div class="jz-signPopup' + ((!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/) || !!navigator.userAgent.match(/Mobile.*Gecko.*/)) ? ' jz-signPopup-mobile' : '') + '">',
1169            '<p class="jz-signPopup-hd"><a class="closeLayer" href="javascript:void(0);">关闭</a></p>',
1170            '<div class="jz-signPopup-cont">',
1171                '<iframe name="loginFrame" src="'+(Jz.msie() !== null?"":config.url)+'" frameborder="no" scrolling="no" allowtransparency="true" style="width: 100%; height: 100%;"></iframe>',
1172            '</div>',
1173        '</div>'
1174    ].join(""));
1175    $(document.body).append(this.el);
1176    Jz.loginLayer.superclass.constructor.call(this, el, config);
1177}
1178
1179Jz.extend(Jz.loginLayer, Jz.layer, {
1180    initDomImp: function () {
1181        //this.el.find("iframe").css({width:this.config.width||384,height:this.config.height||258});
1182        if (Jz.msie() !== null) {
1183            this.el.find("iframe").attr("src", this.config.url);
1184        }
1185    },
1186    hideImp: function () {
1187        if (Jz.msie() === null) {
1188            this.el.find("iframe").remove();
1189        }
1190    },
1191    loadUrl: function (url) {
1192        if (Jz.msie() !== null) {
1193            this.el.find("iframe").attr("src", url);
1194        } else {
1195            this.el.find(".jz-signPopup-cont").append('<iframe name="loginFrame" src="' + url + '" frameborder="no" scrolling="no" allowtransparency="true" style="width: 100%; height: 100%;"></iframe>');
1196        }
1197        //this.el.find("iframe").css({width:this.config.width||384,height:this.config.height||258});
1198    },
1199    resetHeight: function () {
1200        this.el.find("iframe").css("height",270);
1201        this.el.css("height",326);
1202        this.el.find("div.layer-body").css("height",290);
1203        this.el.find("div.layer-bg").css("height",326);
1204    }
1205});
1206
1207/**
1208* Jz.userLayer(user layer)
1209* @author [email protected]
1210* @config
1211*/
1212Jz.userLayer = function (el, config) {
1213    $("head").append('<style>' +
1214                        '#JZ_UserLayer {display: none; position: absolute; font-size: 14px; width: 480px; background-color: #fff; color: #545445;}' +
1215                        '#JZ_UserLayer-close {position: absolute; top: 12px; right: 12px; width: 23px; height: 22px; background: url(http://res.jzyx.com/themes/commons/userLayer/ico-close.png) no-repeat 0 0; text-indent: -99999px; outline: none;}' +
1216                        '#JZ_UserLayer-close:hover {background-position: -23px 0;}' +
1217                        '#JZ_UserLayer-title {padding: 12px 0 4px; margin: 0 12px; border-bottom: 1px solid #e6e6e6; font: 700 16px/1.6 "Microsoft YaHei";}' +
1218                        '#JZ_UserLayer-box {padding: 12px 12px 28px;}' +
1219                        '#JZ_UserLayer-box iframe {width: 100%;}' +
1220                    '</style>');
1221
1222    el = $('<div id="JZ_UserLayer">' +
1223                '<a id="JZ_UserLayer-close" class="closeLayer" href="javascript:void(0);">关闭</a>' +
1224                '<p id="JZ_UserLayer-title"></p>' +
1225                '<div id="JZ_UserLayer-box"></div>' +
1226            '</div>');
1227
1228    Jz.userLayer.superclass.constructor.call(this, el, config);
1229}
1230
1231Jz.extend(Jz.userLayer, Jz.layer, {
1232    initDomImp: function () {
1233        this.layerTitle = this.el.find("#JZ_UserLayer-title");
1234        this.layerBox = this.el.find("#JZ_UserLayer-box");
1235        this.loadUrl(this.config.url, this.config.title);
1236    },
1237    hideImp: function () {
1238        if (Jz.msie() !== null) {
1239            this.el.find("iframe").attr("src", "");
1240        } else {
1241            this.el.find("iframe").remove();
1242        }
1243        this.layerBox.find("iframe").unbind("load");
1244    },
1245    loadUrl: function (url, title) {
1246        if (Jz.msie() !== null) {
1247            if (this.layerBox.find("iframe").length < 1) {
1248                this.layerBox.append('<iframe name="iframeLayer" src="" frameborder="no" scrolling="no"></iframe>');
1249            }
1250            this.layerBox.find("iframe").attr("src", url);
1251        } else {
1252            this.layerBox.append('<iframe name="iframeLayer" src="' + url + '" frameborder="no" scrolling="no"></iframe>');
1253        }
1254        this.layerTitle.text(title ? title : '极致游戏');
1255        this.resetHeight();
1256    },
1257    resetHeight: function () {
1258        var _this = this;
1259        var _high = 200;
1260        this.layerBox.find("iframe").bind("load", function () {
1261            if (this.contentDocument && this.contentDocument.body.offsetHeight) {
1262                _high = this.contentDocument.body.offsetHeight;
1263            } else if (this.Document && this.Document.body.scrollHeight) {
1264                	_high = this.Document.body.scrollHeight;
1265            }
1266            $(this).css("height", _high);
1267            _this.layerBox.css("height", _high);
1268            Jz.resetUserLayerPosition();
1269        });
1270    }
1271});
1272
1273//-----------------------------
1274//事件处理机制
1275//-----------------------------
1276Jz.EventBus = {
1277    listener :{},
1278    add :function(name, fn){
1279        var events = Jz.EventBus.listener[name] || [];
1280            events.push(fn);
1281            Jz.EventBus.listener[name] = events;
1282    },
1283    fire :function(name,args){
1284        var events = Jz.EventBus.listener[name] || [];
1285        for(var i=0;i<events.length;i++){
1286            if(events[i]){
1287                events[i](args);
1288            }
1289        }
1290    }
1291}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.