/** * @fileOverview * * @author * @version 1.0.1 * */ var OTM = OTM || {}; (function($) { OTM.cookie = ( function() { var COOKIE_DOMAIN = /eposcard\.co\.jp/.test(location.hostname) ? '.eposcard.co.jp' : '', COOKIE_NAME_SKIP_SPLASH = '_OTM_SKIPSPLASH', CARD_SELECTED_COOKIE = '_OTOME_SELECTEDNO', LOGIN_URL = 'cardchange', LOGIN_COOKIE = 'login', //2015.12.11社講機能付カード申込用 SHAKOU_URL = 'otomate_shakou', //2017.7.20カード再発行申込用 REISSUE_URL = 'cardreissue', //2022.2.10 ウェブチャネル遷移用追加修正 VOI_URL = 'webchannel', cookieSetting = { domain : COOKIE_DOMAIN, expires : 30, path : '/' }, /* */ cookieSettingOnce = { domain : COOKIE_DOMAIN, path : '/' }, cardsQuerys = { 't' : 'otomate_', 'dsn' : '' }, _readCookie = function(key) { return $.cookie(key); }, _writeCookie = function(key, val, opt) { $.cookie(key, val, opt); }, _cardReplaceVals = function (params) { var replaced = ""; for ( var i in cardsQuerys ) { if ( typeof params[i] !== 'undefined' ) { replaced = params[i].replace(cardsQuerys[i], ''); break; } } return replaced; }; return { /* * */ hasVisitedIndex : function() { return _readCookie(COOKIE_NAME_SKIP_SPLASH) == 'sec' }, setVisitedCookie : function() { _writeCookie(COOKIE_NAME_SKIP_SPLASH, 'sec', cookieSettingOnce) }, /* * */ setSelectedDesignNo : function(no) { _writeCookie(CARD_SELECTED_COOKIE, jQuery.trim(no + ''), cookieSetting); }, getSelectedDesignNo : function() { var no = _readCookie(COOKIE_NAME_CARD_SELECTED); return ( typeof (no) == 'string') ? no : false; }, getDesignNumber : function($elm) { if (!$elm.find('a').length) return; var params = this.queryString($elm.find('a').attr('href')); return _cardReplaceVals(params); }, /* QueryString And Cookie Value */ //2017.7.20カード再発行申込用追加修正 isLogin : function() { var param = this.queryString(location.href); if(!$.cookie(LOGIN_URL) || $.cookie(LOGIN_URL) != "true"){ if(param[LOGIN_URL] && param[LOGIN_URL] === "true"){ $.cookie(LOGIN_URL, "true", {path:"/"}); $.cookie(REISSUE_URL,null, {path:"/"}); $.cookie(SHAKOU_URL,null, {path:"/"}); $.cookie(VOI_URL, "null", {path:"/"}); } } if(!$.cookie(REISSUE_URL) || $.cookie(REISSUE_URL) != "true"){ if(param[REISSUE_URL] && param[REISSUE_URL] === "true"){ $.cookie(REISSUE_URL, "true", {path:"/"}); $.cookie(LOGIN_URL, null, {path:"/"}); $.cookie(SHAKOU_URL,null, {path:"/"}); $.cookie(VOI_URL, "null", {path:"/"}); } } if(!$.cookie(VOI_URL) || $.cookie(VOI_URL) != "true"){ if(param['from'] && param['from'] === 'voi0101'){ $.cookie(VOI_URL, "true", {path:"/"}); $.cookie(REISSUE_URL, null, {path:"/"}); $.cookie(LOGIN_URL, null, {path:"/"}); $.cookie(SHAKOU_URL,null, {path:"/"}); } } if(!$.cookie(SHAKOU_URL) || $.cookie(SHAKOU_URL) != "true"){ if(param[SHAKOU_URL] && param[SHAKOU_URL] === "true"){ $.cookie(LOGIN_URL,null, {path:"/"}); $.cookie(REISSUE_URL,null, {path:"/"}); $.cookie(VOI_URL, "null", {path:"/"}); } } return $.cookie(LOGIN_URL) && $.cookie(LOGIN_URL) === "true" && $.cookie(LOGIN_COOKIE) == 1 }, isShakou : function() { if(!$.cookie(SHAKOU_URL) || $.cookie(SHAKOU_URL) != "true"){ var param = this.queryString(location.href); if(param[SHAKOU_URL] && param[SHAKOU_URL] === "true"){ $.cookie(SHAKOU_URL, "true", {path:"/"}); $.cookie(LOGIN_URL,null, {path:"/"}); } }else{ var param = this.queryString(location.href); if(param[LOGIN_URL] && param[LOGIN_URL] === "true"){ $.cookie(SHAKOU_URL,null, {path:"/"}); } } return $.cookie(SHAKOU_URL) && $.cookie(SHAKOU_URL) === "true" }, queryString : function (param) { var strpos = param.indexOf ('?'), results = {}, params, i, j, tmp; if (strpos !== -1) { param = param.substring(strpos + 1); } if ( /&/.test(param) ) { params = param.split(/&/); for (i = 0, j = params.length; i < j; i++) { if ( /=/.test(params[i])) { tmp = params[i].split(/=/); results[tmp[0]] = tmp[1]; } } } else { if ( /=/.test(param)) { tmp = param.split(/=/); results[tmp[0]] = tmp[1]; } } return results; } }; }()); //20151214 add OTM.cookie.isLogin();OTM.cookie.isShakou(); //20151214 add })(jQuery);