function couponBnr(urlList){ var ref = document.referrer, // リファラ情報を得る hereHost = window.location.hostname, // 現在ページのホスト(ドメイン)名を得る fromParam = getParam('utm_source'), // URLパラメータ(fr)を得る paramArray, // 許可URLパラメータを配列に paramFlg, // URLパラメータ判断フラグ sStr = '^https?://' + hereHost, // ホスト名が含まれるか探す正規表現テキスト rExp = new RegExp( sStr, 'i' ), // 大文字・小文字を区別しない正規表現オブジェクト url = location.href,//自身のURLを取得 $couponUrlList = urlList,//獲得バナー表示許可配列 commonFlg = false, $imgHost = 'www.live-tag.com', //src用host名取得 bigBnrDiv, miniBnr, setTime = 2000, userAgent = window.navigator.userAgent.toLowerCase(), bnrFlg = true, overlay = document.createElement('div'); //ミニバナー表示 overlay.className = 'overlayWrap'; paramArray = [ 'twitter', 'facebook', 'mailmagazine', 'app', 'hp' ]; for(var p = 0; p < paramArray.length; p++){ if(fromParam == paramArray[p]){ paramFlg = true; } } //リファラのドメインが'omni7.jp'もしくは自身と同じ、もしくはsnsパラメータがある場合 if(ref.indexOf('omni7.jp') != -1 || ref.match(rExp) || paramFlg || userAgent.match(/(msie|MSIE)/) || userAgent.match(/(T|t)rident/)){ if(paramFlg){//snsパラメータがある場合 setTime = 1000;//待ち時間を1秒にする } commonFlg = true;//次ステップtrue if(url.indexOf('detail') !== -1){ var $title = document.title; if(chanelCheck($title) || diorCheck($title) || bottegavenetaCheck($title) || DSQUARED2Check($title) || TOMOKISSIMACheck($title) || VERSACECheck($title) || document.title.indexOf('クレ・ド・ポー ボーテ') !== -1){ //タイトルタグに特定のブランド名がある場合はなにもしない commonFlg = false;//次ステップfalse } if(url.indexOf('detail/0010017') !== -1){ // 学生服 commonFlg = false;//次ステップfalse } // パンくず取得 var pankuzuClass = document.getElementsByClassName('mod-breadcrumbList'); if(pankuzuClass.length){//パンくずが存在する var pankuzu = pankuzuClass.item(0).innerHTML; if (pankuzu.indexOf('ふるさと納税') !== -1 || pankuzu.indexOf('ヴェルサーチ') !== -1 || pankuzu.indexOf('VERSACE') !== -1) { //ふるさと納税とヴェルサーチとVERSACEが含まれる commonFlg = false; } } } } function chanelCheck(title){ //chanelの正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(C|c|C|c)(H|h|H|h)(A|a|A|a)(N|n|N|n)(E|e|E|e)(L|l|L|l)/; //与えられた引数にchanelが含まれていればtrueを返す return regex.test(title); } function diorCheck(title){ //diorの正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(d|D|d|D)(i|I|i|I)(o|O|o|O)(r|R|r|R)/; //与えられた引数にdiorが含まれていればtrueを返す return regex.test(title); } function bottegavenetaCheck(title){ //bottega venetaの正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(b|B|B|b)(o|O|O|o)(t|T|T|t)(t|T|T|t)(e|E|E|e)(g|G|G|g)(a|A|A|a)(\s| )(v|V|V|v)(e|E|E|e)(n|N|N|n)(e|E|E|e)(t|T|T|t)(a|A|A|a)/; //与えられた引数にbottega venetaが含まれていればtrueを返す return regex.test(title); } function DSQUARED2Check(title){ //DSQUARED2の正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(D|d|D|d)(S|s|S|s)(Q|q|Q|q)(U|u|U|u)(A|a|A|a)(R|r|R|r)(E|e|E|e)(D|d|D|d)(2|2)/; //与えられた引数にDSQUARED2が含まれていればtrueを返す return regex.test(title); } function TOMOKISSIMACheck(title){ //TOMOKISSIMAの正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(T|t|T|t)(O|o|O|o)(M|m|M|m)(O|o|O|o)(K|k|K|k)(I|i|I|i)(S|s|S|s)(S|s|S|s)(I|i|I|i)(M|m|M|m)(A|a|A|a)/; //与えられた引数にTOMOKISSIMAが含まれていればtrueを返す return regex.test(title); } function VERSACECheck(title){ //VERSACEの正規表現(半角大文字/半角小文字/全角大文字/全角小文字) var regex = /(V|v|V|v)(E|e|E|e)(R|r|R|r)(S|s|S|s)(A|a|A|a)(C|c|C|c)(E|e|E|e)/; //与えられた引数にVERSACEが含まれていればtrueを返す return regex.test(title); } if(commonFlg){//次ステップ var $siteBnrLen = $couponUrlList.allPageList.length; for (var i=0 ; i<$siteBnrLen ; i++){ if(url.indexOf($couponUrlList.allPageList[i].url) !== -1){ if(getCookie('project_id') != ''){ //企画IDがある if(getCookie('project_id').indexOf($couponUrlList.allPageList[i].project_id) !== -1){ //企画ID内に同じものがある } else { var $projectIdVal = getCookie('project_id') +','+ $couponUrlList.allPageList[i].project_id; setCookie('project_id',$projectIdVal); } projectTimeAjax($couponUrlList.allPageList[i].project_id); } else { //企画IDがない(初期) setCookie('project_id',$couponUrlList.allPageList[i].project_id); projectTimeAjax($couponUrlList.allPageList[i].project_id); } } } } function projectTimeAjax(projectIdList) { var $projectTimeUrl = 'https://'+$imgHost+'/sogo-seibu/php/projectTime.php'; var xhr = new XMLHttpRequest(); xhr.open('post',$projectTimeUrl); xhr.responseType = 'json'; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { var response; if(userAgent.match(/(msie|MSIE)/) || userAgent.match(/(T|t)rident/) ) { response = JSON.parse(xhr.response); } else { response = xhr.response; } var projectIdCheckList = response.project_time; if(projectIdCheckList == ''){ } else { //DB書き込み成功・クーポンキー取得完了 var projectIdListLen = projectIdCheckList.length; for (var v=0 ; v', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '
', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '', couponBigBnr = couponBigBnr+ '
'; var couponMiniBnr = ''; var bigBnrWrap = document.getElementsByClassName('bigBnrWrap'), miniBnrWrap = document.getElementsByClassName('miniBnrWrap'), closeBtn = document.getElementsByClassName('closeBtn'); bigBnrWrap.item(0).innerHTML = couponBigBnr; miniBnrWrap.item(0).innerHTML = couponMiniBnr; } var $spsw = getCookie('spsw'); if ($spsw == 'on'){ miniBnr.classList.remove('spCoupon'); bigBnrDiv.classList.remove('spCoupon'); } else { miniBnr.classList.add('spCoupon'); bigBnrDiv.classList.add('spCoupon'); } miniBnr.addEventListener('click', function() { overlay.classList.remove('dispNone'); bnrPosition(bigBnrDiv); miniBnr.classList.add('dispNone'); }, false); closeBtn.item(0).addEventListener('click', function() { overlay.classList.add('dispNone'); bigBnrDiv.classList.add('dispNone'); miniBnr.classList.remove('dispNone'); }, false); overlay.addEventListener('click', function() { overlay.classList.add('dispNone'); bigBnrDiv.classList.add('dispNone'); miniBnr.classList.remove('dispNone'); }, false); var nanacoLinkA = document.getElementsByClassName('nanacoLink'); nanacoLinkA.item(0).addEventListener('click', function(){ dataPush('methodLink'); }); if(getCookie('coupon_key_' + projectIdCheckList[v].split(',')[0]) == ''){ //発行鍵がない couponKeyAjax(projectIdCheckList[v].split(',')[0]); } else { couponKeyDayAjax(projectIdCheckList[v].split(',')[0],getCookie('coupon_key_' + projectIdCheckList[v].split(',')[0])); } } } } } }; var data = new FormData(); data.append('project_id',projectIdList); xhr.send(data); } function couponKeyDayAjax(projectId,couponKey) { var $couponKeyUrl = 'https://'+$imgHost+'/sogo-seibu/php/couponKeyDay.php'; var $href = location.href; var xhr = new XMLHttpRequest(); xhr.open('post',$couponKeyUrl); xhr.responseType = 'json'; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { var response; if(userAgent.match(/(msie|MSIE)/) || userAgent.match(/(T|t)rident/) ) { response = JSON.parse(xhr.response); } else { response = xhr.response; } var couponKeyDay = response.couponKeyDay; if(couponKeyDay == 'false'){ } else { //DB書き込み成功・クーポンキー取得完了 var couponDate = couponKeyDay[0].insert_datetime; if(couponDate.indexOf(couponKeyDay[1]) !== -1){ //当日発行されたもの if(getCookie('coupon_use_' + projectId) == ''){ //利用フラグがない miniBnr.classList.remove('dispNone'); dataPush('miniBnrShow'); } } else { //別日発行されたもの removeCookie('coupon_key_' + projectId); removeCookie('coupon_issue_' + projectId); removeCookie('coupon_use_' + projectId); couponKeyAjax(projectId); } } } }; var data = new FormData(); data.append('url',$href); data.append('project_id',projectId); data.append('coupon_key',couponKey); xhr.send(data); } function couponKeyAjax(projectId) { setTimeout(function(){ var $couponKeyUrl = 'https://'+$imgHost+'/sogo-seibu/php/couponBnr.php'; var $href = location.href; var xhr = new XMLHttpRequest(); xhr.open('post',$couponKeyUrl); xhr.responseType = 'json'; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { var response; if(userAgent.match(/(msie|MSIE)/) || userAgent.match(/(T|t)rident/) ) { response = JSON.parse(xhr.response); } else { response = xhr.response; } if(response.coupon_key == '' || response.coupon_key == 'ng'){ } else { //DB書き込み成功・クーポンキー取得完了 overlay.classList.remove('dispNone'); bnrPosition(bigBnrDiv); var $coupon_key = 'coupon_key_' + projectId; setCookie($coupon_key,response.coupon_key); } } }; var data = new FormData(); data.append('url',encodeURI($href)); data.append('project_id',encodeURI(projectId)); xhr.send(data); }, setTime); } function dataPush(eventName) { var $couponKeyUrl = 'https://'+$imgHost+'/sogo-seibu/php/link.php'; var $href = location.href; var xhr = new XMLHttpRequest(); xhr.open('post',$couponKeyUrl); xhr.responseType = 'json'; var data = new FormData(); data.append('url',encodeURI($href)); data.append('event',encodeURI(eventName)); xhr.send(data); } function setCookie(c_name,value){ var domain = document.domain; var domains = new Array(); domains = domain.split("."); domain = domains[domains.length-2]+'.'+domains[domains.length-1]; var extime = new Date().getTime(); var cltime = new Date(extime + (60*60*24*1000*365)); var exdate = cltime.toUTCString(); var s=""; s += c_name +"="+ escape(value); s += "; path=/; domain="+domain; s += "; expires=" +exdate+"; "; document.cookie=s; } function getCookie(c_name){ var st = ""; var ed = ""; if(document.cookie.length>0){ st = document.cookie.indexOf(c_name + "="); if(st != -1){ st = st+c_name.length+1; ed = document.cookie.indexOf(";",st); if(ed == -1) ed = document.cookie.length; return unescape(document.cookie.substring(st,ed)); } } return ""; } function removeCookie(c_name){ var domain = document.domain; var domains = new Array(); domains = domain.split("."); domain = domains[domains.length-2]+'.'+domains[domains.length-1]; var extime = new Date().getTime(); var cltime = new Date(extime + (60*60*24*1000*365)); var exdate = cltime.toUTCString(); var s=""; s += c_name +"="; s += "; path=/; domain="+domain; s += "; expires=" +exdate+"; max-age=0;"; document.cookie=s; } function bnrPosition(bnr){ var $scrollTop; $scrollTop = document.documentElement.scrollTop; bnr.style.top = 'calc(10% + ' + $scrollTop + 'px)'; bnr.classList.remove('dispNone'); } }; function getParam(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); }