1class ScriptLogin extends Script { 2 constructor(params) { 3 super(params) 4 this.msg = params.msg 5 this.$form = document.querySelector(`#${this.attrId} form`) 6 } 7 /** åå§åï¼æ¯æå¼æ¥ */ 8 async init() { 9 // å·²ç»å½çæ åµå éåº 10 if (window.app.info.user.is_login) window.app.utilts.logout() 11 // 表åæäº¤äºä»¶ 12 this.$form.onsubmit = event => { 13 // åæ¶é»è®¤äºä»¶ 14 event.preventDefault() 15 this.check(event) 16 // æäº¤ 17 this.submit() 18 } 19 // æäºæ åµä¸åè°ä¸æ¬¡æäº¤ 20 } 21 22 check(event) { 23 const $username = document.getElementById('username') 24 const $password = document.getElementById('password') 25 const emailRexp = /[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*(\.[a-zA-Z]{2,})$/ 26 if (!emailRexp.test($username.value)) { 27 new Message().warn(Utilts.ins().$t('email format does not match')) 28 return false 29 } 30 if ($password.value.length < 6) { 31 new Message().warn(Utilts.ins().$t('Password length should be 6-20')) 32 return false 33 } 34 } 35 36 /** æäº¤ */ 37 submit() { 38 this.$form.classList.add('was-validated') 39 if (!this.$form.checkValidity()) return 40 else this.$form.classList.remove('was-validated') 41 this.$form.querySelector('[type=submit]').setAttribute('disabled', 'disabled') 42 setTimeout(() => { 43 this.$form.querySelector('[type=submit]').removeAttribute('disabled') 44 }, 3000) 45 const formData = new FormData(this.$form) 46 window.app.utilts.login({ username: formData.get('username'), password: formData.get('password') }) 47 } 48}
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.