jQuery(function() { // Edit this line to adjust your environment var host = '//app.pantena.jp/'; var bridgeAuth = host + 'bridge/auth'; var login = host + 'login'; var mypage = host + 'mypage'; var logout = host + 'logout'; var register = host + 'register'; jQuery.ajax(bridgeAuth, { dataType: 'json', type: 'get', xhrFields: { withCredentials: true }, success: function(response) { if (response) { jQuery('.c-header__buttons > a:eq(0)').attr('href', mypage); jQuery('.c-header__buttons > a:eq(0)').text('マイページ'); jQuery('.c-header__buttons > a:eq(1)').attr('href', logout); jQuery('.c-header__buttons > a:eq(1)').text('ログアウト'); jQuery('.c-header__buttons > a:eq(1)').off('click').on('click', function(e) { e.preventDefault(); document.getElementById('logout-form').submit(); }); jQuery('.c-header__buttons > a:eq(1)').after(''); jQuery('#logout-form').append(''); jQuery('.c-spNav .c-nav__loginLink:eq(0)').attr('href', mypage); jQuery('.c-spNav .c-nav__loginLink:eq(0)').text('マイページ'); jQuery('.c-spNav .c-nav__loginLink:eq(1)').attr('href', logout); jQuery('.c-spNav .c-nav__loginLink:eq(1)').text('ログアウト'); jQuery('.c-spNav .c-nav__loginLink:eq(1)').off('click').on('click', function(e) { e.preventDefault(); document.getElementById('logout-form').submit(); }); } else { jQuery('.c-header__buttons > a:eq(0)').attr('href', login); jQuery('.c-header__buttons > a:eq(0)').text('ログイン'); jQuery('.c-header__buttons > a:eq(1)').attr('href', register); jQuery('.c-header__buttons > a:eq(1)').text('新規会員登録'); jQuery('.c-spNav .c-nav__loginLink:eq(0)').attr('href', login); jQuery('.c-spNav .c-nav__loginLink:eq(0)').text('ログイン'); jQuery('.c-spNav .c-nav__loginLink:eq(1)').attr('href', register); jQuery('.c-spNav .c-nav__loginLink:eq(1)').text('新規会員登録'); } } }); });