1Widgets.SiteUserLogin = function (options = null) { 2 this.className = "defaultSiteUserLoginContainer"; 3 4 Widgets.BaseWidget.call(this, "/Widgets/SiteUser/SiteUserLogin", this.className); 5 6 //custom overriding options 7 BaseHelper.MergeIntoObject(this, options); 8 9 this._setup = function () { 10 Widgets.BaseWidget.prototype._setup.call(this); 11 this.onLogin = []; 12 }; 13 this.animTime = 300; 14 15 this.getLoadData = async function () { 16 let result = Widgets.BaseWidget.prototype.getLoadData.call(this); 17 return result; 18 }; 19 20 this.clearFields = () => { 21 this.btnSave.innerText = "Sign In"; 22 this.txtEmail.value = ""; 23 this.txtPassword.value = ""; 24 this.txtFirstName.value = ""; 25 this.txtLastName.value = ""; 26 this.txtPhoneNumber.value = ""; 27 $(this.row_password).hide(); 28 $(this.row_firstname).hide(); 29 $(this.row_lastname).hide(); 30 $(this.row_phonenumber).hide(); 31 }; 32 33 this.updateFields = function (data) { 34 if (data.LoggedIn == true) { 35 this.SetLoggedIn(true); 36 return; 37 } 38 let sulInfo = data.SiteUserLoginInfo; 39 let SiteUserID = sulInfo.SiteUserID; 40 let ValidPassword = sulInfo.ValidPassword; 41 if (SiteUserID == 0) { 42 $(this.row_password).show(this.animTime); 43 $(this.row_firstname).show(this.animTime); 44 $(this.row_lastname).show(this.animTime); 45 $(this.row_phonenumber).show(this.animTime); 46 this.btnSave.innerText = "Sign Up"; 47 } 48 else { 49 if (ValidPassword == false) { 50 $(this.row_password).show(this.animTime); 51 $(this.row_firstname).hide(this.animTime); 52 $(this.row_lastname).hide(this.animTime); 53 $(this.row_phonenumber).hide(this.animTime); 54 this.btnSave.innerText = "Sign In"; 55 } 56 } 57 }; 58 59 this.refresh = async () => { 60 this.clearFields(); 61 this.ToggleLoading(true); 62 let json_data = await BaseHelper.MakeAJAXPostJSONRequest("/api/SiteUser/SiteUserStatus"); 63 this.ToggleLoading(false); 64 let data = JSON.parse(json_data); 65 this.currentData = data; 66 this.prevLoggedIn = this.currentData.LoggedIn; 67 this.currentLoggedIn = data.LoggedIn; 68 this.SetLoggedIn(data.LoggedIn); 69 }; 70 71 this.SetLoggedIn = async (loggedIn) => { 72 if (loggedIn == true) { 73 this.sulLoggedIn.style.display = "block" 74 this.sulContent.style.display = "none" 75 } 76 else { 77 this.sulLoggedIn.style.display = "none" 78 this.sulContent.style.display = "block" 79 } 80 }; 81 82 this.onTemplateLoad = function () { 83 let sulForm = this.element.querySelector("form"); 84 let row_email = this.row_email = this.element.querySelector(".row_email"); 85 let row_password = this.row_password = this.element.querySelector(".row_password"); 86 let row_firstname = this.row_firstname = this.element.querySelector(".row_firstname"); 87 let row_lastname = this.row_lastname = this.element.querySelector(".row_lastname"); 88 let row_phonenumber = this.row_phonenumber = this.element.querySelector(".row_phonenumber"); 89 90 let txtEmail = this.txtEmail = this.element.querySelector(".txtEmail"); 91 let txtPassword = this.txtPassword = this.element.querySelector(".txtPassword"); 92 let txtFirstName = this.txtFirstName = this.element.querySelector(".txtFirstName"); 93 let txtLastName = this.txtLastName = this.element.querySelector(".txtLastName"); 94 let txtPhoneNumber = this.txtPhoneNumber = this.element.querySelector(".txtPhoneNumber"); 95 96 this.sulLoggedIn = this.element.querySelector(".sulLoggedIn"); 97 this.sulContent = this.element.querySelector(".sulContent"); 98 99 let btnSave = this.btnSave = this.element.querySelector(".btnSave"); 100 101 btnSave.addEventListener("click", async (e) => { 102 e.preventDefault(); 103 let loginData = { 104 "Email": this.txtEmail.value, 105 "Password": this.txtPassword.value, 106 "FirstName": this.txtFirstName.value, 107 "LastName": this.txtLastName.value, 108 "PhoneNumber": this.txtPhoneNumber.value 109 }; 110 this.ToggleLoading(true); 111 let json_data = await BaseHelper.MakeAJAXPostJSONRequest("/api/SiteUser/SiteUserLogin", loginData) 112 this.ToggleLoading(false); 113 let data = JSON.parse(json_data); 114 if ( 115 data != null && 116 data.LoggedIn != true && 117 data.SiteUserLoginInfo != null && 118 data.SiteUserLoginInfo.SiteUserID != 0 && 119 $(this.row_password).is(":visible")) { 120 Swal.fire("Oops", "Password is incorrect!", "error"); 121 } 122 this.updateFields(data); 123 if (this.onSaveComplete != null) { 124 this.onSaveComplete(this); 125 } 126 if (this.onSaveCompleteArr != null && this.onSaveCompleteArr.length > 0) { 127 this.onSaveCompleteArr.forEach((f) => { 128 f(this); 129 }) 130 } 131 if (data != null) { 132 if (this.onLogin != null && this.onLogin.length > 0) { 133 this.onLogin.forEach((cb) => { 134 cb(data.LoggedIn); 135 }); 136 } 137 } 138 }); 139 }; 140 this.onSaveComplete = null; 141 this.onSaveCompleteArr = []; 142} 143Widgets.SiteUserLogin.prototype = new Widgets.SiteUserLogin();
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.