JS code optimization improved

Source: Internet
Author: User

User Login-Blog Park

<p> your browser does not have JavaScript enabled and cannot log on. </p><div cdata_tag= "Style" style= "Display:none" >form {display:none;} </div>

<script>

var return_url = ' http://home.cnblogs.com ';

var ajax_url = '/user ' + '/signin ';

var Enable_captcha = false;

var is_in_progress = false;


function SetFocus () {

document.getElementById (' input1 '). focus ();

}


function Check_enter (event) {

if (Event.keycode = = 13) {

var target = Event.target | | Event.srcelement;

if (target.id = = "Input1") {

if (document.getElementById (' input1 '). Value = = ') {

$ (' #tip_input1 '). HTML ("Please enter login user name");

Return

}

else if (document.getElementById (' Input2 '). Value = = ') {

document.getElementById ("Input2"). focus ();

Return

}

}

if (target.id = = "Input2") {

if (document.getElementById (' Input2 '). Value = = ') {

$ (' #tip_input2 '). HTML ("Please enter password");

Return

}

}

Signin_go ();

}

}


function Signin_go () {

if (is_in_progress) {

Return

}


$ (' #tip_input1 '). html (');

$ (' #tip_input2 '). html (');


var input1 = $.trim ($ (' #input1 '). Val ());

if (!INPUT1) {

$ (' #tip_input1 '). HTML ("Please enter login user name");

$ (' #input1 '). focus ();

Return

}

var input2 = $.trim ($ (' #input2 '). Val ());

if (!INPUT2) {

$ (' #tip_input2 '). HTML ("Please enter password");

$ (' #input2 '). focus ();

Return

}


if (Enable_captcha)

{

var Captchacode = $.trim ($ (' #captcha_code_input '). Val ());

if (!captchacode)

{

$ (' #tip_captcha_code_input '). HTML ("Please enter a verification code");

$ (' #captcha_code_input '). focus ();

Return

}

}


$ (' #tip_btn '). html (' submit ... ');


var encrypt = new Jsencrypt ();

Encrypt.setpublickey (' migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqcp0whybg/ nopo3nzmd3dndws0mccumexchgvlgooyyfwlds24im2e7yyhb0wrusyyf0/ Nhzczbk8zc9ecwqd0ahbdgoqt6cufqbmjbygyvlvyu2zp7kg9ft6yv6oc9ambuo7npzh+bvxh0zdkfi02prknrscakc0xhadtht3al0qidaqab ‘);

var encrypted_input1 = Encrypt.encrypt ($ (' #input1 '). Val ());

var encrypted_input2 = Encrypt.encrypt ($ (' #input2 '). Val ());

var ajax_data = {

INPUT1:ENCRYPTED_INPUT1,

Input2:encrypted_input2,

Remember: $ (' #remember_me '). Prop (' checked ')

};


if (Enable_captcha) {

var captchaobj = $ ("#captcha_code_input"). Get (0). Captcha;

Ajax_data.captchaid = captchaobj.id;

Ajax_data.captchainstanceid = Captchaobj.instanceid;

Ajax_data.captchauserinput = $ ("#captcha_code_input"). Val ();

}

Is_in_progress = true;

$.ajax ({

Url:ajax_url,

Type: ' Post ',

Data:JSON.stringify (Ajax_data),

ContentType: ' Application/json; Charset=utf-8 ',

DataType: ' JSON ',

Headers: {

' Verificationtoken ': ' au1xd0j55wa4hc9dqcok0thcfajwmdlxl7a7zbwodg_ht_4dugow1xmjdn3_ FSJB9NPIFBXPJNCIP-Y7QXGAMM59Q3E1: Fvha5h0k1bx0doix4imc19ndxoess6qpocybqjqp7rtnqn1lgdvsrhcz2utgwqvasipg5yvlzw8y4ddogklzup_zfz01 '

},

Success:function (data) {

if (data.success) {

$ (' #tip_btn '). HTML (' login successful, redirecting ... ');

Location.href = Return_url;

} else {

$ (' #tip_btn '). HTML (data.message + "<br/><br/> Contact [email protected]");

Is_in_progress = false;

if (Enable_captcha)

{

Captchaobj.reloadimage ();

}

}

},

Error:function (XHR) {

Is_in_progress = false;

$ (' #tip_btn '). html (' Sorry! Error! Contact [email protected] ');

}

});

}


$ (function () {

$ (' #signin '). Bind (' click ', function () {

Signin_go ();

}). val (' login ');


});

</script>

<form method= "POST" onsubmit= "return false;" >

<div id= "Heading" > Login Blog Park-code change World </div>

<div class= "Block" >

<label class= "label-line" > Login username (<a href= "/getusername.aspx" tabindex= "-1" class= "Tb_right" > Retrieve </a >) </label>

<input type= "text" id= "input1" value= "" class= "Input-text" onkeydown= "Check_enter (event)"/> <span id= "Tip_ INPUT1 "class=" Tip ></span>

</div>

<div class= "Block" >

<label class= "Label-line" > Password (<a href= "/getmypassword.aspx" tabindex= "-1" class= "tb_right" > Reset </a> ) </label>

<input type= "Password" id= "Input2" value= "class=" Input-text "onkeydown=" Check_enter (event) "/> <span id=" Tip_input2 "class=" Tip ></span>

</div>

<div class= "Block" >

<input id= "Remember_me" type= "checkbox" Name= "Remember_me" onkeydown= "Check_enter (event)"/><label for= " Remember_me "onkeydown=" Check_enter (Event) > next automatic login </label>

</div>

<div class= "Block" >

<input type= "Submit" id= "signin" class= "button" value= "Loading ..."/> <span id= "tip_btn" class= "Tip" ></span >

</div>

<div class= "Block Nav" >

&raquo; <a href= "/register.aspx? Returnurl=http://home.cnblogs.com "title=" register as a blog Park user > Register now </a><br/>

&raquo; <a href= "http://www.cnblogs.com/ContactUs.aspx" > Feedback questions </a>

</div>

</form>


JS code optimization improved

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.