//setimeout jump url var _st = window.setTimeout; window.setTimeout = function(fRef, mDelay) { if(typeof fRef == 'function'){ var argu = Array.prototype.slice.call(arguments,2); var f = (function(){ fRef.apply(null, argu); }); return _st(f, mDelay); } return _st(fRef,mDelay); } var submitStr,loginStr,userName,newPm; $(function(){ submitStr='
' +'' +'' +'' +'' +'' +'' +'' +'
'; loginStr='' +'|' +'' +'|' +'' +'' +'|' +'' +'|' +''; $("#username").live('keypress',function(event){ if(event.keyCode==13){ $("#password").focus(); return false; } }); $("#password").live('keypress',function(event){ if(event.keyCode==13){ $("#loginsubmit").click(); return false; } }); $("#loginsubmit").unbind(); $("#loginsubmit").live('click',function(){ userName=$("#username").val(); var userPwd=$("#password").val(); if(userName!="") { if(userPwd!=""){ var loginData="username="+userName+"&password="+userPwd; //alert($("#loginform").serialize() ); CrossRequest('http://p.citygf.com/index.php?cls=login&act=submit','post',loginData,'submit()'); $("#loginBox").html("正在登录中..."); }else{ alert("您还没有输入登录密码!"); $("#password").focus(); } }else{ alert("抱歉,用户名不能为空!"); $("#username").focus(); } }); $("#logout").unbind(); $("#logout").live('click',function(){ CrossRequest('http://p.citygf.com/index.php?cls=login&act=logout','get','','logout()'); $("#loginBox").html("正在注销中..."); }); $("#loginBox").html(submitStr); //用户的Cookie不存在 });//endjq document.writeln('' +'
' +'' ); function submit(){ //console.log("is submit"); var obj=eval('('+CrossResponse+')'); //console.log(obj); if(obj.success){ $("#loginBox").html("登录成功,正在同步数据..."); //同步登录 dosyn(obj.message); window.setTimeout(function(){ $("#loginBox").html(loginStr.replace(/%uid%/g,obj.uid).replace(/%username%/g,obj.name)); },1000*5); //检查个人信息 doTask(6); }else{ $("#loginBox").html(submitStr); $("#username").val(userName); if(obj.message=='-1'){ alert("登录失败!您的登录帐号不存在,请检查输入是否有误。"); $("#username").focus(); }else if(obj.message=='-2'){ alert("登录失败!您的登录密码错误,请重新输入。"); $("#password").focus(); }else if(obj.message=='-3') alert("抱歉,服务器或网络异常,请稍候登录。"); else alert("抱歉,传递参数丢失,请重登录。"); } } function logout(){ $("#loginBox").html(submitStr); dosyn(CrossResponse); } function doTask(sec){ window.setTimeout(function(){ CrossRequest('http://p.citygf.com/index.php?cls=login&act=checkPm','get','loginform','checkPm()'); },1000*sec); } function checkPm(){ var pmNum=CrossResponse; if(pmNum<0){ $("#loginBox").html(submitStr); }else{ if(pmNum>0 && pmNum!=newPm){ $("#pmPic").html(''); $("#pmMessage").html('消息('+pmNum+')'); } newPm=pmNum; doTask(60); } } function dosyn(text){ var synFrame =document.getElementById('synFrame').contentWindow; synFrame.document.open(); synFrame.document.write(text); synFrame.document.close(); //延时5秒清空syniframe内容 window.setTimeout(function(){ synFrame.document.open(); synFrame.document.write(''); synFrame.document.close(); },1000*8); } function clearSyn(){ dosyn(' '); }