$(function () { var chain = new jcchain.JCChain() var toggleLoginBtn = function () { if (chain.logined) { $('#header_loginbtn').hide() $('#header_logoutbtn').show() } else { $('#header_loginbtn').show() $('#header_logoutbtn').hide() } } toggleLoginBtn() var logSuccess = function () { console.log('login success') toggleLoginBtn() } $('#header_loginbtn').click(function () { chain.login().then(logSuccess.bind(this)) }) $('#header_logoutbtn').click(function () { chain.logout().then(() => { toggleLoginBtn() }) }) jcchain.EventBus.$on(jcchain.SHOW_CHAIN_MODAL, function () { console.log('show chain modal') $('#wallet_modal').show() }) $('#metamask_card').click(function () { chain.selectWalletAndLogin(1).then(logSuccess.bind(this)) $('#wallet_modal').hide() }) $('#wc_card').click(function () { chain.selectWalletAndLogin(2).then(logSuccess.bind(this)) $('#wallet_modal').hide() }) })