class LoginViewController extends OnTimeViewController { viewWillAppear() { this.accountKeyField.value = localStorage.getItem("last_account_key"); this.usernameField.value = localStorage.getItem("last_username"); this.passwordField.value = ""; } onLoginButtonPressed(event) { this.startLogin(); } onKeyUp(event) { if (event.keyCode == 13) { this.onLoginButtonPressed(event); } } startLogin() { this.loginErrorBox.style.display = "none"; //Save the entered account key in the local storage. localStorage.setItem("last_account_key", this.accountKeyField.value); localStorage.setItem("last_username", this.usernameField.value); var request = new Request(OnTime.REQUEST_URI + "Login", Request.POST, this.onLoginSuccess.bind(this), this.onLoginError.bind(this)); request.send({ account_key: this.accountKeyField.value, username: this.usernameField.value, password: this.passwordField.value }, true); } onLoginSuccess(response) { //Clear the password field for security reasons. this.passwordField.value = ""; if (response === true) { UIKit.onHashChanged(); } } onLoginError(request, status, error) { this.loginErrorBox.style.display = ""; } } UIKit.registerViewControllerType(LoginViewController);