1$(function () { 2 $('#reset-account').on('blur', verifyResetAccount); 3 $('#reset-code').on('blur', verifyResetCode); 4 $('#reset-pwd').on('blur', verifyResetPwd); 5 $('#reset-confirm-pwd').on('blur', verifyResetConfirmPwd); 6 $('#reset-answer').on('blur', verifyResetAnswer); 7 $('#reset-check-account').on('click', checkEmailAccount); 8 $('#reset-getcode,#reset-getcode-again').on('click', getEmailAuthCode); 9 $('#reset-checkcode').on('click', checkEmailAuthCode); 10 $('#reset-check-security-question').on('click', checkSecurityQuestion); 11 $('#reset-submit').on('click', resetPassword); 12 $('#dirct-reset-pwd-submit').on('click',directResetPassword); 13 14 $('.tips').bind('click', function () { 15 $(this).css('display', 'none'); 16 }); 17 18 $('dl.select dd ul li').click(function () { 19 $('#ret-security_question_id').val($(this).data('value')); 20 }); 21}); 22 23function checkEmailAccount() { 24 var _this = $(this); 25 _this.siblings('.loader-inner').show(); 26 27 if (verifyResetAccount()) { 28 var method = $('#reset-method').val(); 29 var account = $('#reset-account').val(); 30 account = $.trim(account); 31 var param = {account: account}; 32 33 $.ajax({
34 url: '/authUser/checkAccount', 35 data: param, 36 type: 'GET', 37 dataType: 'jsonp', 38 jsonp: 'jsoncallback', 39 success: function (data) { 40 $('.loader-inner').hide(); 41 42 if (data.code != 4001) { 43 _this.parents('li').find('.tips').show().html(L('error_account_not_exist')); 44 return false; 45 } 46 47 if (method == 'email') { 48 $('.tip_anc').html(account); 49 $('.forgot-password li.item:eq(0)').hide(); 50 $('.forgot-password li.item:eq(1),.forgot-password li.item:eq(2)').show(); 51 $('.maill_step li:eq(1)').addClass('active'); 52 } else if (method == 'phone') { 53 if (data.response.auth_phone) { 54 $('#reset-account').val('+' + data.response.country_code + ' ' + data.response.auth_phone); 55 $('.tip_anc').html('+' + data.response.country_code + ' ' + data.response.auth_phone); 56 $('.forgot-password li.item:eq(0)').hide(); 57 $('.forgot-password li.item:eq(1),.forgot-password li.item:eq(2)').show(); 58 $('.maill_step li:eq(1)').addClass('active'); 59 } else { 60 _this.parents('li').find('.tips').show().html('Unbound mobile phone, unable to retrieve it by this method!'); 61 } 62 } else if (method == 'question') { 63 $('#reset-user_id').val(data.response.id); 64 $('.forgot-password li.item:eq(0)').hide(); 65 $('.forgot-password li.item:eq(1)').show(); 66 $('.maill_step li:eq(1)').addClass('active'); 67 } 68 } 69 }); 70 } 71} 72 73var reset_lock = 0; 74function resetPassword() { 75 if (reset_lock > 0) return false; 76 77 var _this = $(this); 78 _this.siblings('.loader-inner').show(); 79 80 if (verifyResetAccount() && verifyResetPwd() && verifyResetConfirmPwd()) { 81 reset_lock++; 82 var method = $('#reset-method').val(); 83 var account = $('#reset-account').val(); 84 account = $.trim(account);//First and last spaces 85 var code = $('#reset-code').val(); 86 var password = $('#reset-pwd').val(); 87 var token = $('#reset-submit').attr('token'); 88 var param = {account: account, code: code, password: password, token: token, method: method}; 89 90 $.ajax({
91 url: '/authUser/resetPassword', 92 data: param, 93 type: 'GET', 94 dataType: 'jsonp', 95 jsonp: 'jsoncallback', 96 success: function (data) { 97 $('#reset-submit').siblings('.loader-inner').hide(); 98 if (data.code != 0) { 99 _this.parents('li').find('.tips').show().html(data.msg); 100 setTimeout(function () { 101 reset_lock--; 102 }, 3000); 103 return false; 104 } 105 106 if (method == 'question') { 107 $('.forgot-password li.item:eq(2),.forgot-password li.item:eq(3)').hide(); 108 $('.forgot-password li.item:eq(4)').show(); 109 } else { 110 $('.forgot-password li.item:eq(3),.forgot-password li.item:eq(4)').hide(); 111 $('.forgot-password li.item:eq(5)').show(); 112 } 113 $('.maill_step li:eq(3)').addClass('active'); 114 115 setTimeout(function () { 116 window.location.href = data.loginUrl; 117 }, 2000); 118 }, 119 error: function () { 120 reset_lock--; 121 } 122 }); 123 } 124} 125 126function verifyResetAccount() { 127 var obj = $('#reset-account'); 128 obj.parent().find('.tips').hide(); 129 var account = obj.val(); 130 131 if (verify.checkAccount(account) == false) { 132 obj.parent().find('.tips').show().html(verify.show_msg); 133 obj.parent().find('.loader-inner').hide(); 134 return false; 135 } 136 137 return true; 138} 139 140function verifyResetCode() { 141 var obj = $('#reset-code'); 142 obj.parent().find('.tips').hide(); 143 var code = obj.val(); 144 if (verify.checkCode(code) == false) { 145 obj.parent().find('.tips').show().html(verify.show_msg); 146 obj.parent().find('.loader-inner').hide(); 147 return false; 148 } 149 150 return true; 151} 152 153function verifyResetPwd() { 154 var obj = $('#reset-pwd'); 155 obj.parent().find('.tips').hide(); 156 var newpwd = obj.val(); 157 if (verify.checkPassword(newpwd) == false) { 158 obj.parent().find('.tips').show().html(verify.show_msg); 159 return false; 160 } 161 162 return true; 163} 164 165function verifyResetConfirmPwd() { 166 var obj = $('#reset-confirm-pwd'); 167 obj.parent().find('.tips').hide(); 168 var confirmpwd = obj.val(); 169 if (verify.checkPassword(confirmpwd) == false) { 170 obj.parent().find('.tips').show().html(verify.show_msg); 171 $('.loader-inner').hide(); 172 return false; 173 } 174 175 if ($('#reset-pwd').val() != confirmpwd) { 176 obj.parent().find('.tips').show().html(L('error_password_unmatched')); 177 $('.loader-inner').hide(); 178 return false; 179 } 180 181 return true; 182} 183 184function verifyResetAnswer() { 185 var obj = $('#reset-answer'); 186 obj.parent().find('.tips').hide(); 187 var answer = obj.val(); 188 if (!answer) { 189 obj.parent().find('.tips').show().html('Answer cannot be empty.'); 190 $('.loader-inner').hide(); 191 return false; 192 } 193 194 var question_id = $('#ret-security_question_id').val(); 195 if (!question_id) { 196 obj.parent().find('.tips').show().html('Question cannot be empty.'); 197 $('.loader-inner').hide(); 198 return false; 199 } 200 201 return true; 202} 203 204var code_lock = 0; 205function getEmailAuthCode() { 206 if (code_lock > 0) return false; 207 208 var _this = $(this); 209 _this.hide(); 210 _this.siblings('.countdown').show(); 211 var count = 120; 212 var _t = setInterval(function () { 213 if (count > 0) { 214 _this.siblings('.countdown').html(count + 's'); 215 } else { 216 _this.siblings('.countdown').hide(); 217 _this.siblings('.countdown').html('120s'); 218 _this.show(); 219 clearInterval(_t); 220 } 221 count--; 222 }, 1000); 223 224 if (verifyResetAccount()) { 225 code_lock++; 226 var account = $('#reset-account').val(); 227 account = $.trim(account); 228 var param = null; 229 var url = ''; 230 231 if (verify.isPhone(account)) { 232 param = {phone: account, type: 'findpwd'}; 233 url = '/authUser/getPhoneAuthCode'; 234 } else { 235 param = {account: account, type: 'findpwd'}; 236 url = '/authUser/getEmailAuthCode'; 237 } 238 239 $.ajax({
240 url: url, 241 data: param, 242 type: 'GET', 243 dataType: 'jsonp', 244 jsonp: 'jsoncallback', 245 success: function (data) { 246 setTimeout(function () { 247 code_lock--; 248 }, 5000); 249 if (data.code != 0) { 250 _this.parents('li').find('.tips').show().html(data.msg); 251 } 252 }, 253 error: function () { 254 code_lock--; 255 } 256 }); 257 } 258} 259 260var chcek_code_lock = 0; 261function checkEmailAuthCode() { 262 if (chcek_code_lock > 0) return false; 263 264 var _this = $(this); 265 _this.siblings('.loader-inner').show(); 266 267 if (verifyResetCode()) { 268 chcek_code_lock++; 269 code_lock++; 270 var account = $('#reset-account').val(); 271 account = $.trim(account); 272 var code = $('#reset-code').val(); 273 var param = {account: account, code: code}; 274 $.ajax({ 275 url: '/authUser/checkAccountAuthCode', 276 data: param, 277 type: 'GET', 278 dataType: 'jsonp', 279 jsonp: 'jsoncallback', 280 success: function (data) { 281 $('.loader-inner').hide(); 282 283 setTimeout(function () { 284 chcek_code_lock--; 285 code_lock--; 286 }, 5000); 287 288 if (data.code != 0) { 289 _this.parents('li').find('.tips').show().html(data.msg); 290 return false; 291 } 292 293 $('#reset-submit').attr({token: data.token}); 294 $('.forgot-password li.item:eq(1),.forgot-password li.item:eq(2)').hide(); 295 $('.forgot-password li.item:eq(3),.forgot-password li.item:eq(4)').show(); 296 $('.maill_step li:eq(2)').addClass('active'); 297 }, 298 error: function () { 299 chcek_code_lock--; 300 code_lock--; 301 } 302 }); 303 } 304} 305 306var chcek_security_question_lock = 0; 307function checkSecurityQuestion() { 308 if (chcek_security_question_lock > 0) return false; 309 310 var _this = $(this); 311 _this.siblings('.loader-inner').show(); 312 313 var account = $('#reset-account').val(); 314 account = $.trim(account); 315 var user_id = $('#reset-user_id').val(); 316 var question_id = $('#ret-security_question_id').val(); 317 var answer = $('#reset-answer').val(); 318 if (verifyResetAnswer()) { 319 chcek_security_question_lock++; 320 var param = {account: account, user_id: user_id, question_id: question_id, answer: answer}; 321 $.ajax({
322 url: '/authUser/checkSecurityAnswer', 323 data: param, 324 type: 'GET', 325 dataType: 'jsonp', 326 jsonp: 'jsoncallback', 327 success: function (data) { 328 $('.loader-inner').hide(); 329 330 setTimeout(function () { 331 chcek_security_question_lock--; 332 }, 5000); 333 334 if (data.code != 0) { 335 _this.parents('li').find('.tips').show().html(data.msg); 336 return false; 337 } 338 339 $('.forgot-password li.item:eq(1)').hide(); 340 $('.forgot-password li.item:eq(2),.forgot-password li.item:eq(3)').show(); 341 $('.maill_step li:eq(2)').addClass('active'); 342 }, 343 error: function () { 344 chcek_security_question_lock--; 345 } 346 }); 347 } 348} 349 350var direct_reset_lock = 0; 351function directResetPassword() { 352 if (direct_reset_lock > 0) return false; 353 if (verifyResetPwd() && verifyResetConfirmPwd()) { 354 $(this).siblings('.loader-inner').show(); 355 direct_reset_lock ++; 356 var account = $("#dirct-reset-pwd-submit").data('account'); 357 var password = $('#reset-pwd').val(); 358 var param = {account:account,password:password}; 359 360 $.ajax({
361 url: '/authUser/directResetPassword', 362 data: param, 363 type: "GET", 364 dataType: 'jsonp', 365 jsonp: "jsoncallback", 366 success: function (data) { 367 $(this).siblings('.loader-inner').hide(); 368 if (data.code != 0) { 369 $("#dirct-reset-pwd-submit").siblings('.tips').show().html(data.msg); 370 setTimeout(function() {direct_reset_lock--;},3000) 371 return false; 372 } 373 $(".forgot-password li:eq(1),.forgot-password li:eq(2),.forgot-password li:eq(3)").hide(); 374 $(".forgot-password li:eq(4)").show(); 375 setTimeout(function() {window.location.href = data.loginUrl;},2000); 376 }, 377 error: function () { 378 direct_reset_lock--; 379 } 380 }); 381 } 382} 383 384var verify = (function (my) { 385 var error_account_msg = [] 386 error_account_msg[1] = L('error_account_null'); 387 error_account_msg[2] = L('error_account_not_email'); 388 389 my.show_msg = ''; 390 my.checkAccount = function (str) { 391 if (str.length == 0) { 392 my.show_msg = error_account_msg[1]; 393 return false; 394 } 395 if (!my.isEmail(str) && !my.isPhone(str)) { 396 my.show_msg = error_account_msg[2]; 397 return false; 398 } 399 return true; 400 } 401 402 my.isEmail = function (str) { 403 var reg = /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/; 404 return reg.test(str); 405 } 406 407 my.isPhone = function (str) { 408 var reg = /^(\+\d{1,4} ?)?\d{3,12}$/; 409 return reg.test(str); 410 } 411 412 var error_password_msg = []; 413 error_password_msg[1] = L('error_password_null'); 414 error_password_msg[2] = L('error_password_illegal'); 415 416 my.checkPassword = function (pwd) { 417 if (pwd == '' || pwd == 'password') { 418 my.show_msg = error_password_msg[1]; 419 return false; 420 } 421 if (pwd.length < 5 || pwd.length > 16) { 422 my.show_msg = error_password_msg[2]; 423 return false; 424 } 425 return true; 426 } 427 428 var error_code_msg = [] 429 error_code_msg[1] = L('error_auth_code_null'); 430 error_code_msg[2] = L('error_auth_code_illegal'); 431 432 my.checkCode = function (code) { 433 if (code == '') { 434 my.show_msg = error_code_msg[1]; 435 return false; 436 } 437 438 var reg = /^\d{6}$/; 439 if (!reg.test(code)) { 440 my.show_msg = error_code_msg[2]; 441 return false; 442 } 443 444 return true; 445 } 446 447 return my; 448})(verify || {})
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.