$(document).ready(function() { var $window = $(window), width = $window.width(), height = $window.height(), $centerArea = $('#middle-area > div.center-area'); var $params = $('#params'); var siteType = ($params.data('device') == 'smart')? 'SP' : 'PC'; var $sectionType = $('section.section .block-area'); var $bg = $('#bg'); var $section = $bg.find('section.section'); //#4766 window 識別 if(!window.name){ var rum = Math.ceil(Math.random() * 100); var now = Date.now() /1000; var win_name = Math.ceil(now * rum); window.name = win_name; } //#2297 シングルページ 対応 if ($sectionType.length) { $params = $bg; siteType = ($params.data('device') == 'smart')? 'SP' : 'PC'; } /*******************************************************************/ //for click var mouse_moves = []; $('#bg').on('mousemove', function(e) { if (siteType != "PC") { return false; } // クリック位置の座標(コンテンツ領域のみで算出) x = e.clientX; y = e.clientY + $window.scrollTop(); mouse_moves.push({ 'x': x, 'y': y }); }).on('click tap', function(e) { var offset = 0, x, y, pageID, data; // ページID pageID = $params.data('page-id'); //#2297 シングルページ 対応 var sp_flg = false; var sp_full_flg = false; var scroll = 0; if ($sectionType.length) { var centerW = $sectionType.eq(0).width(); var sectionh = $section.eq(0).height(); var centerh = $sectionType.eq(0).height(); scroll = $window.scrollTop(); width = $bg.width(); sp_flg = true; pos2_header = 0; pos2_footer = 0; pos2_other = 0; page_bottom =0; if ($bg.data('sp-type') == 1 && siteType == 'PC') { //フッター、固定バナー、固定メニューの場合は高さ微調整(固定のときキャプチャー位置は下に) var st_index = ($('section.section').filter('.active').length)? $('section.section').index($('section.section').filter('.active')) : 0; scroll = sectionh * st_index; //フッター、固定バナー、固定メニュー対応用 page_bottom = sectionh * parseInt($('section.section').length); if($('#bg').find("#header").length && !$('#bg').find("#header.pos2").length){ page_bottom += parseInt($('#bg').find("#header").height()); } }else{ //パララックス以外は、最後のセクションの位置から計算 var lt_index = $('section.section').length - 1; var $_lt_sction = $('section.section').eq(lt_index); page_bottom = parseInt($_lt_sction.position().top) + parseInt($_lt_sction.height()); if($('#bg').find("#header").length && !$('#bg').find("#header.pos2").length){ page_bottom += parseInt($('#bg').find("#header").height()); } } //matu ヘッダー固定時対応 if($(e.target).closest("#header").length && !($('#bg').find("#header.pos2").length && !$('#bg').find("#header").hasClass("normal-header"))){ //pos2_header = $('#bg').find("#header.pos2").height(); } pageID = $bg.data('page-id'); } else { var centerW = $centerArea.width(); } //111.5 if (siteType == 'PC') { offset = (width - centerW) / 2; } // クリック位置の座標(コンテンツ領域のみで算出) if (sp_flg) { if (siteType == 'PC') { offset = (width >= centerW && !($(e.target).closest("#header").length || $(e.target).closest("#footer").length || $(e.target).closest("#fixedbanner").length)) ? (width - centerW) / 2 : 0; } x = e.clientX - offset; y = e.clientY + scroll + pos2_header; //#2297 シングルページ 対応 if ($bg.data('sp-type') == 1 && siteType == 'PC') { //パララックスタイプ //1020:573.75 = 16:9 (1020はキャプチャサイズ) y = (y - (((sectionh - centerh) / 2) * st_index)) + pos2_header; if($(e.target).closest("#header").length || $(e.target).closest("#footer").length || $(e.target).closest("#fixedbanner").length){ x = Math.round(x * (1020 / width)); }else{ x = Math.round(x * (1020 / centerW)); } y = Math.round(y * (573.75 / sectionh)); }else if(!$bg.data('sp-type') && siteType == 'PC'){ //シングルページ //ヘッダー、フッター、固定バナーは可変でうごくので調整 if(($(e.target).closest("#header").length &&!$(e.target).closest("#header").hasClass("normal-header")) || $(e.target).closest("#footer").length || $(e.target).closest("#fixedbanner").length){ //現在ヒートマップキャプチャーの1100なので //x = Math.round(x * (1100 / centerW)); x = Math.round(x * (1100 / width)); } } if($(e.target).closest("#header").length && (($('#bg').find("#header.pos2").length && !$('#bg').find("#header").hasClass("normal-header")) || $('#bg').find("#header.a-logo-fixed").length && siteType != 'PC')){ //y = e.clientY - parseInt($(e.target).closest("#header.pos2").position().top); y = e.clientY; } //フッター、固定バナー、固定メニューの場合は高さ微調整(固定のときキャプチャー位置は下に) if($(e.target).closest("#footer.pos2").length){ // || $(e.target).closest("#fixedbanner.pos2").length) { pos2_footer = $(e.target).closest("#footer.pos2").height(); y = page_bottom - pos2_footer + (e.clientY - parseInt($(e.target).closest("#footer.pos2").position().top)); } if($(e.target).closest("#fixedbanner.pos2").length) { //フッターの下にくるので if($('#bg').find("#footer").length && !$('#bg').find("#footer").hasClass("pos2")){ page_bottom += $('#bg').find("#footer").height(); } y = page_bottom + (e.clientY - parseInt($(e.target).closest("#fixedbanner.pos2").position().top)); } } else { x = e.clientX - offset; y = e.clientY + $window.scrollTop(); } if ((x > 0 && x < centerW) || ($bg.data('sp-type') == 1 && siteType == 'PC')) { // 送信データ data = { x : x, y : y, page_id : pageID, site_type : siteType, url : location.href, 'window' : width + ',' + height }; var click_count_url = analysisUrl + '/click_tracking'; $.ajax({ type : "POST", cache : false, data : data, async : true, url : click_count_url }); } }); /*******************************************************************/ /*******************************************************************/ if(SHFlg > 0){ // スクロールヒートフラグを追加。 //for scroll var scrolltimer = false; var visittimer = false; var scPageID = $params.data('page-id'); var sc_data = {}; var scroll_y = $window.scrollTop(); var scroll_x = $window.scrollLeft(); var scroll_count_url = analysisUrl + '/scroll_tracking'; // visittimer = setInterval(function() { // 送信データ sc_data = { x : scroll_x, y : scroll_y, page_id : scPageID, site_type : siteType, url : location.href, 'window' : width + ',' + height, 'height' : height, 'width' : width, 'page_size' : $('#bg').width() + ',' + $('#bg').height(), }; $.ajax({ type : "POST", cache : false, data : sc_data, async : true, url : scroll_count_url, success : function() { //console.log(sc_data); } }); // 終了時にタイマーを切る clearTimeout(visittimer); }, 2); // スクロール $(window).scroll(function() { if (visittimer !== false) { //console.log("visittimer false"); //console.log(sc_data); clearTimeout(visittimer); } if (scrolltimer !== false) { //console.log("scrolltimer false"); //console.log(sc_data) clearTimeout(scrolltimer); } scrolltimer = setTimeout(function() { scroll_y = $window.scrollTop(); scroll_x = $window.scrollLeft(); // 送信データ sc_data = { x : scroll_x, y : scroll_y, page_id : scPageID, site_type : siteType, url : location.href, 'window' : width + ',' + height, 'height' : height, 'width' : width, 'page_size' : $('#bg').width() + ',' + $('#bg').height(), }; $.ajax({ type : "POST", cache : false, data : sc_data, async : true, url : scroll_count_url, success : function() { //console.log(sc_data); } }); }, 2000); }); } /*******************************************************************/ /*******************************************************************/ //for access var access_count_url = analysisUrl + '/access_count'; var paerntUrl = ""; // #2828 if (window.parent && (window.parent !== window) && (document.location.search.indexOf('sp_preview_flg=1') == -1)) { paerntUrl = parent.location.href; } //個別ブロックカウント対応(商品紹介など) var block_id = 0; var record_id = 0; if ($('#one-detail').length) { block_id = $('#one-detail').data('block-id'); record_id = $('#one-detail').data('record-id'); } var data = { url : location.href, page_id : $params.data('page-id'), page_device : $params.data('device'), referer : document.referrer, parent_url : paerntUrl, block_id : block_id, record_id : record_id, win_name : window.name, //#4766 }; $.ajax({ type : "POST", cache : false, data : data, async : true, url : access_count_url }); /*******************************************************************/ });