var maxScrollPosition = 0; var totalTaizaiJikan = 0; var firstAccessTime = 1761336840; var title_tag; var date = new Date(); var uniqueID = date.getTime() + "_" + "216.73.216.180"; var accessTimestamp = date.getTime(); var saveData; var jikan=0; var startDate; var startTimestamp; var timing=500; var goal_jikan=null; var source = {}; var idx=[]; var param = getUrlVars(); var clickmap; var scrollmap; var analyzeFlag = false; var scrpllPointer2_top = 0; var mode; var totalJikan=0; var trans_byte = 0; if(GetCookie("mode") == "setting"){ mode = "setting"; } if(param['mode'] == "setting"){ mode = "setting"; document.cookie = 'mode=' + mode; } if(param['play_unique_id'] == undefined){ play_unique_id = null; }else{ play_unique_id = param['play_unique_id']; analyzeFlag = true; } if(param['clickmap'] == "on"){ clickmap = true; analyzeFlag = true; }else{ clickmap = false; } if(param['scrollmap'] == "on"){ scrollmap = true; analyzeFlag = true; }else{ scrollmap = false; } if(play_unique_id != null){ mode = "play"; } if(play_unique_id != null){ //再生用 $.ajax({ type: "get", url: "http://atout.jp/ac/movie.php?play_unique_id=" + play_unique_id + "&callback=getsavedata", dataType: "jsonp", crossDomain: true, success:function(data){ if(data.kubun == "single"){ fStart(data.recdata[play_unique_id]); } if(data.kubun == "multi"){ fMultiStart(data.recdata); } } }); } $(function(){ $(window).load(function(){ if(clickmap){ $.ajax({ type: "get", url: "http://atout.jp/ac/clickmap.php?callback=getsavedata", dataType: "jsonp", data: {"url":location.href}, crossDomain: true, success:function(data){ fClickmapView(data); } }); } if(scrollmap){ $.ajax({ type: "get", url: "http://atout.jp/ac/scrollmap.php?callback=getsavedata", dataType: "jsonp", data: {"url":location.href}, crossDomain: true, success:function(data){ fScrollmapView(data); } }); } }) }) function getsavedata(){ } function viewHeat(params){ var i=0; $.each(params , function(key , row){ i++; $('body').append(''); }) i=0; $.each(params , function(key , row){ i++; draw($("#click_canvas_" + i)); }) } function draw(canvas_pram) { var canvas = canvas_pram[0]; if ( ! canvas || ! canvas.getContext ) { return false; } var ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.globalAlpha = 0.5; var grad = ctx.createRadialGradient(15,15,3,15,15,10,15,15,15); grad.addColorStop(0,'red'); // 赤 grad.addColorStop(0.4,'yellow'); // 黄 grad.addColorStop(0.8,'green'); // 緑 grad.addColorStop(1,'rgba(0,0,0,0)'); // 青 ctx.fillStyle = grad; ctx.rect(0,0, 30,30); ctx.fill(); } function getColor(value){ var r,g,b; if(value <= 255){ r = 0; g = value; b = 255; } if(value > 255 && value <= 510){ r = 255 - value; g = 0; b = 255; } if(value > 510){ r = 255; g = 0; b = value; } return "rgb(" + r + "," + g + "," + b + ")"; } function viewScroll(area_id , count , maxCount){ var startTop = area_id * 300; var endTop = (parseInt(area_id) + 1) * 300; value = Math.ceil(count / maxCount * 755); rgb = getColor(value); $(document.body).append("
');
}
$("#pointer").animate({top:(data.mouseY + data.ScrollPosition),left:data.mouseX},{duration: timing,easing:"linear"});
// $("#pointer").css("top",data.mouseY);
// $("#pointer").css("left",data.mouseX);
}
}
function move_multi(k){
if(source[k][idx[k]] == undefined){
return false;
}else{
data = source[k][idx[k]];
var ClientHeight = getClientHeight();
var ScrollHeight = getScrollHeight();
var barHeight = 400 / ScrollHeight * $(window).height();
if(data.ScrollPosition > ScrollHeight) data.ScrollPosition = ScrollHeight;
scrpllPointer2_top = (data.ScrollPosition / ScrollHeight) * ($(window).height() - barHeight);
if($("#scrollPoint_" + k).attr("id") == undefined){
$("body").append("");
$("body").append("");
}
$("#scrollPoint_" + k).animate({top:data.ScrollPosition},{duration: timing,easing:"linear"});
$("#scrollPoint_B_" + k).animate({top:scrpllPointer2_top},{duration: timing,easing:"linear"});
}
}
function setProgressDatetime(dt){
var y = dt.getFullYear();
var m = ("0" + parseInt(dt.getMonth() + 1)).slice(-2);
var d = ("0" + dt.getDate()).slice(-2);
var h = ("0" + dt.getHours()).slice(-2);
var i = ("0" + dt.getMinutes()).slice(-2);
var s = ("0" + dt.getSeconds()).slice(-2);
$("#current_time").val(h + ":" + i + ":" + s);
}
function timecount(){
if(pause == false){
ret = true;
//$("#console3").val("次の時間:" + (source[parseInt(idx[0])+1].jikan);
if(playMode == "front"){
if(jikan >= totalJikan){
setTimeout(timecount,1 * timing);
return;
}else{
jikan = jikan + 5;
}
}
if(playMode == "back"){
if(jikan <= 0){
setTimeout(timecount,1 * timing);
return;
}else{
jikan = jikan - 5;
}
}
if(source[idx[0]] != undefined){
// $("#console2").val("時間:" + source[idx[0]].Jikan);
}
//$("#console3").val("時間:" + jikan);
setDigital();
var currentDate = new Date(parseInt(startTimestamp) + parseInt(jikan * 100));
setProgressDatetime(currentDate);
if(source[idx[0]]){
if(playMode == "front"){
if(idx[0] <= maxIdx[0]){
if(source[idx[0]].Jikan <= jikan){
ret = move();
if(idx[0] < maxIdx[0]) idx[0]++;
}
}
}else{
if(idx[0] >= -1){
if(source[idx[0]].Jikan + 5 >= jikan){
ret = move();
if(idx[0] >= 0) idx[0]--;
}
}
}
}else{
pause = true;
}
//$("#console1").val("インデックス:" + idx[0]);
if(step){
pause = true;
step = false
}
if(jikan <= 0) pause = true;
if(jikan > totalJikan) pause = true;
}
if(trans_byte > -1){
setTimeout(timecount,1 * timing);
}
}
function timecount_multi(){
if(pause == false){
ret = true;
//$("#console3").val("次の時間:" + (source[parseInt(idx[0])+1].jikan);
if(playMode == "front"){
if(jikan >= totalJikan){
setTimeout(timecount_multi,1 * timing);
return;
}else{
jikan = jikan + 5;
}
}
if(playMode == "back"){
if(jikan <= 0){
setTimeout(timecount_multi,1 * timing);
return;
}else{
jikan = jikan - 5;
}
}
//$("#console3").val("時間:" + jikan);
setDigital();
var currentDate = new Date(parseInt(startTimestamp) + parseInt(jikan * 100));
setProgressDatetime(currentDate);
$.each(source , function(k , data){
if(source[k][idx[0]]){
if(playMode == "front"){
if(idx[k] <= maxIdx[k]){
if(source[k][idx[k]].Jikan <= jikan){
ret = move_multi(k);
if(idx[k] < maxIdx[k]) idx[k]++;
}
}
}else{
if(idx[k] >= -1){
if(source[k][idx[k]].Jikan + 5 >= jikan){
ret = move_multi(k);
if(idx[k] >= 0) idx[k]--;
}
}
}
}
})
if(step){
pause = true;
step = false
}
if(jikan <= 0) pause = true;
if(jikan > totalJikan) pause = true;
}
if(trans_byte > -1){
setTimeout(timecount_multi,1 * timing);
}
}
//録画用
var mouse_x = 0;
var mouse_y = 0;
var data = "";
var preData = "";
var saveData = "";
var preTime = new Date();
var startTime = new Date();
var value = [];
var preValue = [];
var unloadEventComp = 0;
var slowScrollJikan = 0;
var slowValue = 0;
var preScrollPosition = null;
var scrollMoveFlag = false;
var startScrollPosition = null;
var scrollData="";
var pause = false;
var maxIdx=[];
var playMode = "front";
var step = false;
preValue.ScrollPosition = -1;
preValue.windowHeight = -1;
preValue.windowWidth = -1;
preValue.mouseX = -1;
preValue.mouseY = -1;
preValue.height = -1;
$(function(){
$(".controlbutton").click(function(){
var kubun = $(this).attr("controltype");
if(kubun == "step"){
pause = false;
step = true;
}
if(kubun == "rewind"){
$.each(idx , function(i , val){
idx[i]--;
})
pause = false;
if(playMode == "front"){
timing = 500;
}else{
if(timing == 500){
timing = 100;
}else{
if(timing == 100){
timing = 50;
}else{
if(timing == 50){
timing = 1000;
}else{
if(timing == 1000){
timing = 500;
}
}
}
}
}
playMode = "back";
}
if(kubun == "pause"){
pause = true;
}
if(kubun == "play"){
pause = false;
timing = 500;
playMode = "front";
}
if(kubun == "start"){
$.each(idx , function(i , val){
idx[i] = -1;
})
if(rec_id_data != null && rec_id == null){
$.each(idx , function(i , val){
move_multi(i);
})
}else{
move();
}
jikan = 0;
setDigital();
}
if(kubun == "end"){
$.each(idx , function(i , val){
idx[i] = maxIdx[i];
})
if(rec_id_data != null && rec_id == null){
$.each(idx , function(i , val){
move_multi(i);
})
}else{
move();
}
jikan = totalJikan;
setDigital();
}
if(kubun == "fast"){
pause = false;
if(timing == 500){
timing = 100;
}else{
if(timing == 100){
timing = 50;
}else{
if(timing == 50){
timing = 1000;
}else{
if(timing == 1000){
timing = 500;
}
}
}
}
playMode = "front";
}
})
$(window).scroll(function(){
scrollMoveFlag = true;
});
$("div").click(function(e){
e.stopPropagation();
var element_index = $("div").index(this); //要素のインデックス
ret = getMousePosition(e,this);
var mouse_x = ret.x; //要素内における、マウス位置
var mouse_y = ret.y; //要素内における、マウス位置
clickData += cipher(element_index) + "0" + cipher(mouse_x) + "0" + cipher(mouse_y) + ":";
});
if(analyzeFlag == false){
title_tag = $("title").text();
var contents_num = $(document.body).html().length;
$.ajax({
type: "GET",
url: "http://atout.jp/ac/access.php?callback=recComp",
data: {"url":location.href , "ref" : document.referrer , "uniqueID" : uniqueID, "title_tag" : title_tag,"contents_num" : contents_num , "firstAccessTime":firstAccessTime , "page_id" : ""},
dataType: "jsonp",
crossDomain: true,
success:function(data){
}
});
}
$("#rokuga_play").click(function(){
postData();
})
})
$(document).mousemove(function(e){
if(analyzeFlag == false){
mouse_x = e.clientX;
mouse_y = e.clientY;
}
})
$("#cipher_click").click(function(){
$("#result").val(cipher($("#val").val()));
})
function postData(){
if(trans_byte > -1){
if(saveData != "" || scrollData != "" || clickData != ""){
if(date.getTime() - accessTimestamp >= 3600 * 1000){
uniqueID = date.getTime() + "_" + "216.73.216.180";
}
trans_byte += saveData.length + scrollData.length + clickData.length;
if(trans_byte > 100000){
trans_byte = -1;
}
//コンソール
//$("#console_sendtime").val(saveData);
//$("#console_uniqueid").val(uniqueID);
$.ajax({
type: "GET",
url: "http://atout.jp/ac/rec.php?callback=recComp",
data: {"url":location.href , "savedata" : saveData , "scrolldata" : scrollData , "clickdata" : clickData,"uniqueID" : uniqueID,"maxScrollPosition":maxScrollPosition,"totalTaizaiJikan":totalTaizaiJikan},
dataType: "jsonp",
crossDomain: true,
success:function(data){
}
});
saveData = "";
scrollData = "";
clickData = "";
}
setTimeout(postData,5000);
}
}
function recComp(){
}
window.onbeforeunload = function() {
if(analyzeFlag == false){
if(unloadEventComp == 0){
unloadEventComp = 1;
postData();
}
}
}
$(window).unload(function(){
if(analyzeFlag == false){
if(unloadEventComp == 0){
unloadEventComp = 1;
postData();
}
}
})
$(window).scroll(function () {
// $("#scrollPoint_B_" + k).animate({top:scrpllPointer2_top},{duration: timing * 0.8});
})
function cipher(val) {
if((val == "" || val == undefined) && val != "0") return "";
if(val == "0") return "a";
var alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (!isNaN(val)) {
var base_count = alphabet.length;
var result = '';
while (val >= base_count) {
div = val/base_count;
mod = (val-(base_count*Math.floor(div)));
result = alphabet.substr(mod,1) + result;
val = div;
}
if (val) result = alphabet.substr(val,1) + result;
} else{
result = 0;
multi = 1;
while (val.length > 0) {
digit = val.substr(val.length - 1,1);
result += multi * alphabet.indexOf(digit);
multi = multi * alphabet.length;
val = val.substr(0, val.length - 1);
}
}
return result;
}
function rec(){
var rec_flag = false;
var ClientHeight = getClientHeight();
var ScrollHeight = getScrollHeight();
var ScrollPosition = getScrollPosition();
var height = ScrollHeight - ClientHeight;
var nowTime = new Date();
//ver1.03
var scrollPercent = Math.floor(ScrollPosition / height * 100);
if(maxScrollPosition < scrollPercent) maxScrollPosition = scrollPercent;
$("#console_sheight").val(ScrollHeight);
$("#console_cheight").val(ClientHeight);
$("#console_height").val(ScrollHeight - ClientHeight);
$("#console_scroll").val(ScrollPosition);
$("#console_wheight").val($(window).height());
$("#console_wwidth").val($(window).width());
value.ScrollPosition = cipher(ScrollPosition);
value.windowHeight = cipher($(window).height());
value.windowWidth = cipher($(window).width());
value.mouseX = cipher(mouse_x);
value.mouseY = cipher(mouse_y);
value.height = cipher(height);
data ="";
if(value.ScrollPosition != preValue.ScrollPosition){
data += value.ScrollPosition + "0";
rec_flag = true;
}else{
data += "0";
}
if(value.windowHeight != preValue.windowHeight || preValue.windowHeight == 0){
data += value.windowHeight + "0";
rec_flag = true;
}else{
data += value.windowHeight + "0";
}
if(value.windowWidth != preValue.windowWidth || preValue.windowWidth == 0){
data += value.windowWidth + "0";
rec_flag = true;
}else{
data += value.windowWidth + "0";
}
if(value.mouseX != preValue.mouseX){
data += value.mouseX + "0";
rec_flag = true;
}else{
data += "0";
}
if(value.mouseY != preValue.mouseY){
data += value.mouseY + "0";
rec_flag = true;
}else{
data += "0";
}
if(value.height != preValue.height){
data += value.height + "";
rec_flag = true;
}else{
data += "";
}
if(rec_flag == true){
Keika = Math.floor((nowTime.getTime()-preTime.getTime()) / 100);
//var1.03
totalTaizaiJikan += Keika;
//コンソール
//$("#console_scroll").val(ScrollPosition);
//$("#console_mousex").val(mouse_x);
//$("#console_mousey").val(mouse_y);
//$("#console_jina").val(Keika);
saveData += cipher(Keika) + "0" + data + ":";
$("#saveData").val(saveData);
$("#Byte").val((saveData.length) / 1000);
$("#Keika").val(Math.floor((nowTime.getTime()-startTime.getTime()) / 1000 / 60));
preTime = new Date();
preValue.ScrollPosition = value.ScrollPosition;
preValue.windowHeight = value.windowHeight;
preValue.windowWidth = value.windowWidth;
preValue.mouseX = value.mouseX;
preValue.mouseY = value.mouseY;
preValue.height = value.height;
}
preData = data;
if(scrollMoveFlag && clickmap == false && scrollmap == false){
var scrollTop = getScrollPosition();
if(Math.abs(preScrollPosition - scrollTop) < 100){
if(startScrollPosition == null){
startScrollPosition = scrollTop;
}
}else{
//精読終わり
setSlowData(scrollTop);
startScrollPosition = null;
}
preScrollPosition = scrollTop;
}
if(analyzeFlag == false && totalTaizaiJikan < 3600){
if(trans_byte > -1){
setTimeout(rec,500);
}
}
}
function setSlowData(endScrollPosition){
if(startScrollPosition != null){
scrollMoveFlag = false;
preScrollPosition = null;
scrollData += cipher(startScrollPosition) + "0" + cipher(endScrollPosition) + "0:";
startScrollPosition = null;
}
}
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
}
else {
element.attachEvent('on' + eventName, callback);
}
}
function removeEvent(element,eventName,callback){
if(element.removeEventListener){
element.removeEventListener(eventName, callback, false);
}else{
element.detachEvent("on" + eventName, callback);
}
}
function getScrollPosition() {
var obj = new Object();
obj.y = document.documentElement.scrollTop || document.body.scrollTop;
return obj.y;
}
function getScrollHeight() {
return $(document).height();
// return document.documentElement.scrollHeight || document.body.scrollHeight;
}
function getClientHeight() {
return (document.documentElement.clientHeight || document.body.clientHeight);
}
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var clickData="";
if(analyzeFlag == false){
rec();
if(trans_byte > -1){
setTimeout(postData,5);
}
}
function clickSave(){
//録画データ送信に同梱
// if(rec_id == undefined){
// if(clickData != ""){
// $.ajax({
// type: "GET",
// url: "rec_click.php?callback=recComp",
// data: {"url":location.href , "clickdata" : clickData},
// dataType: "jsonp",
// crossDomain: true,
// success:function(data){
// }
// });
// clickData = "";
// }
// setTimeout(clickSave,5000);
// }
}
function recComp(){
}
function getElementPosition ( elm ) {
var fn = arguments.callee, // 再帰用
rslt = { x:0, y:0 },
p;
if( elm ) {
rslt = {
x : parseInt(elm.offsetLeft),
y : parseInt(elm.offsetTop)
};
if(elm.offsetParent) {
p = fn(elm.offsetParent);
rslt.x += p.x;
rslt.y += p.y;
}
}
return rslt;
}
function getMousePosition(evt, elm)
{
var d = window.document;
var e = getElementPosition( elm );
var _getPos = function(x, y)
{
return {
x : x - e.x,
y : y - e.y
};
};
if(window.opera)
return _getPos( evt.clientX, evt.clientY );
else if(d.all)
return _getPos( d.body.scrollLeft + evt.clientX, d.body.scrollTop + evt.clientY );
else if(d.layers||d.getElementById)
return _getPos( evt.pageX, evt.pageY );
}
function secondTOhms(second){
h=""+(second/36000|0)+(second/3600%10|0)
m=""+(second%3600/600|0)+(second%3600/60%10|0)
s=""+(second%60/10|0)+(second%60%10)
return m + s
}
function setMaxJikan(){
ms = secondTOhms(Math.floor(totalJikan / 10));
var number1 = ms.substring(0,1);
var number2 = ms.substring(1,2);
var number3 = ms.substring(2,3);
var number4 = ms.substring(3,4);
$("#max_digital_1").attr("src","http://atout.jp/ac/common/images/digital" + number1 + ".gif");
$("#max_digital_2").attr("src","http://atout.jp/ac/common/images/digital" + number2 + ".gif");
$("#max_digital_3").attr("src","http://atout.jp/ac/common/images/digital" + number3 + ".gif");
$("#max_digital_4").attr("src","http://atout.jp/ac/common/images/digital" + number4 + ".gif");
}
function setDigital(){
if(playMode == "front"){
ms = secondTOhms(Math.floor(jikan / 10));
}else{
ms = secondTOhms(Math.ceil(jikan / 10));
}
var number1 = ms.substring(0,1);
var number2 = ms.substring(1,2);
var number3 = ms.substring(2,3);
var number4 = ms.substring(3,4);
$("#digital_1").attr("src","http://atout.jp/ac/common/images/digital" + number1 + ".gif");
$("#digital_2").attr("src","http://atout.jp/ac/common/images/digital" + number2 + ".gif");
$("#digital_3").attr("src","http://atout.jp/ac/common/images/digital" + number3 + ".gif");
$("#digital_4").attr("src","http://atout.jp/ac/common/images/digital" + number4 + ".gif");
}
if(mode == "play"){
$(document.body).append('');
}
if(mode == "setting" && false){
$.post("http://atout.jp/ac/page_update.php", {url:location.href , mode:"get"}, function(data) {
if(data.error){
}else{
if(data.important_page == "1"){
important_page_text = "重 要";
}else{
important_page_text = "一 般";
}
if(data.landing_page == "1"){
landing_page_text = "販売ページ";
}else{
landing_page_text = "一 般";
}
if(data.order_thanks_page == "1"){
order_thanks_page_text = "成 約";
}else{
order_thanks_page_text = "一 般";
}
$(document.body).append('');
$("#access_important_change").click(function(){
$.post("http://atout.jp/ac/page_update.php", {url:location.href , mode:"important_page"}, function(data) {
if(data.error){
}else{
if(data.important_page == "1"){
important_page_text = "重 要";
}
if(data.important_page == "0"){
important_page_text = "一 般";
}
$('#access_important_change').html(important_page_text)
}
}, 'json')
})
$("#access_landing_change").click(function(){
$.post("http://atout.jp/ac/page_update.php", {url:location.href , mode:"landing_page"}, function(data) {
if(data.error){
}else{
if(data.landing_page == "1"){
landing_page_text = "販 売";
}
if(data.landing_page == "0"){
landing_page_text = "一 般";
}
$('#access_landing_change').html(landing_page_text)
}
}, 'json')
})
$("#access_thanks_change").click(function(){
$.post("http://atout.jp/ac/page_update.php", {url:location.href , mode:"order_thanks_page"}, function(data) {
if(data.error){
}else{
if(data.order_thanks_page == "1"){
order_thanks_page_text = "成 約";
}
if(data.order_thanks_page == "0"){
order_thanks_page_text = "一 般";
}
$('#access_thanks_change').html(order_thanks_page_text)
}
}, 'json')
})
}
}, 'json')
}
function GetCookie( name )
{
var result = null;
var cookieName = name + '=';
var allcookies = document.cookie;
var position = allcookies.indexOf( cookieName );
if( position != -1 )
{
var startIndex = position + cookieName.length;
var endIndex = allcookies.indexOf( ';', startIndex );
if( endIndex == -1 )
{
endIndex = allcookies.length;
}
result = decodeURIComponent(
allcookies.substring( startIndex, endIndex ) );
}
return result;
}
$("#analyze_rec_play").click(function(){
var w = window.open(document.location + "?unique_id=" + uniqueID,"_blank","toolbar=no,titlebar=yes,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no");
w.moveTo(0,0);
w.resizeTo(screen.width,screen.height);
})
function viewRealRec(){
var w = window.open(document.location + "?play_unique_id=" + uniqueID,"_blank","toolbar=no,titlebar=yes,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no");
w.moveTo(0,0);
w.resizeTo(screen.width,screen.height);
}
$(document.body).append('');