import OptionPage from './optionPage' ; export default class OptionAuth { authenticated : boolean ; password : string ; authenticate ( evt ) { const passwordInput = document . getElementById ( 'passwordInput' ) as HTMLInputElement ; if ( passwordInput . value == this . password ) { this . authenticated = true ; OptionPage . closeModal ( 'passwordModal' ) ; OptionPage . show ( document . getElementById ( 'main' ) ) ; OptionPage . hideInputError ( passwordInput ) ; } else { OptionPage . showInputError ( passwordInput ) ; } } constructor ( password ? ) { this . password = password ; this . authenticated = false ; } setPassword ( optionPage ) { const password = document . getElementById ( 'setPassword' ) as HTMLInputElement ; optionPage . cfg . password = password . value ; optionPage . saveProp ( 'password' ) ; password . value = '' ; this . setPasswordButton ( optionPage ) ; } setPasswordButton ( optionPage ) { const passwordText = document . getElementById ( 'setPassword' ) as HTMLInputElement ; const passwordBtn = document . getElementById ( 'setPasswordBtn' ) as HTMLButtonElement ; if ( optionPage . cfg . password ) { OptionPage . enableBtn ( passwordBtn ) ; if ( passwordText . value ) { passwordBtn . innerText = 'SET' ; } else { passwordBtn . innerText = 'REMOVE' ; } } else { passwordBtn . innerText = 'SET' ; if ( passwordText . value ) { OptionPage . enableBtn ( passwordBtn ) ; } else { OptionPage . disableBtn ( passwordBtn ) ; } } } }