SIBULIB =
{
//**************************************************************************
//priavte variable
//**************************************************************************
iframeId: 'sibulla_iframe',
formId: 'sibulla_iframe_form',
iframeContentTemplate: '
',
imgContentTemplate: '
',
sendUrls: {'http': 'http://wl005.sibulla.com/sibulog/access', 'https': 'https://wl005.sibulla.com/sibulog/access'},
//**************************************************************************
//check opera
//**************************************************************************
isOpera: function()
{
var ua = navigator.userAgent.toLowerCase();
return (ua.indexOf("opera") > -1 ? true : false);
},
//**************************************************************************
// check ie
//**************************************************************************
isIE: function()
{
var ua = navigator.userAgent.toLowerCase();
return (!SIBULIB.isOpera() && ua.indexOf("msie") > -1 ? true : false);
},
//**************************************************************************
// check safari
//**************************************************************************
isSafari: function()
{
var ua = navigator.userAgent.toLowerCase();
return ( (/webkit|khtml/).test(ua) ? true : false );
},
//**************************************************************************
// check Firefox
//**************************************************************************
isFirefox: function()
{
var ua = navigator.userAgent.toLowerCase();
return( !SIBULIB.isSafari() && ua.indexOf("gecko") > -1 ? true : false);
},
//**************************************************************************
// check Array Object
//**************************************************************************
isArray: function(value)
{
return Object.prototype.toString.apply(value) === '[object Array]';
},
//**************************************************************************
// padding
//**************************************************************************
padding: function(n)
{
return n < 10 ? "0" + n : n;
},
//**************************************************************************
// use has own
//**************************************************************************
useHasOwn: function()
{
!!{}.hasOwnProperty;
},
//**************************************************************************
// json encode string type part
//**************************************************************************
META_TBL: {"\b": '\\b', "\t": '\\t', "\n": '\\n', "\f": '\\f', "\r": '\\r', '"' : '\\"', "\\": '\\\\' },
jsonEncodeForString: function(s)
{
if( /["\\\x00-\x1f]/.test(s) ){
return '"' +
s.replace(/([\x00-\x1f\\"])/g, function(a, b)
{
var c = SIBULIB.META_TBL[ b ];
if( c ){
return c;
}
c = b.charCodeAt();
return "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
}) +
'"';
}
return '"' + s + '"';
},
//**************************************************************************
// json encode array object type part
//**************************************************************************
jsonEncodeForArray: function(o)
{
var a = ["["], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push( v === null ? "null" : SIBULIB.jsonEncode(v) );
b = true;
}
}
a.push("]");
return a.join("");
},
//**************************************************************************
// json encode date type part
//**************************************************************************
jsonEncodeForDate: function(o)
{
return '"' + o.getFullYear() + "-" + SIBULIB.padding(o.getMonth() + 1) + "-" + SIBULIB.padding(o.getDate()) + "T" +
SIBULIB.padding(o.getHours()) + ":" + SIBULIB.padding(o.getMinutes()) + ":" + SIBULIB.padding(o.getSeconds()) + '"';
},
//**************************************************************************
// json encode
//**************************************************************************
jsonEncode: function(o)
{
if( typeof(o) == "undefined" || o === null ){
return "null";
}
else if( SIBULIB.isArray(o) ){
return SIBULIB.jsonEncodeForArray( o );
}
else if( Object.prototype.toString.apply(o) === '[object Date]' ){
return SIBULIB.jsonEncodeForDate( o );
}
else if( typeof(o) == "string" ){
return SIBULIB.jsonEncodeForString( o );
}
else if( typeof(o) == "number" ){
return isFinite( o ) ? String( o ) : "null";
}
else if(typeof(o) == "boolean" ){
return String( o );
}
else{
var a = ["{"], b, i, v;
for (i in o) {
if(!SIBULIB.useHasOwn() || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown": break;
default:
if(b){
a.push(',');
}
a.push( SIBULIB.jsonEncode(i), ":", v === null ? "null" : SIBULIB.jsonEncode(v) );
b = true;
}
}
}
a.push("}");
return a.join("");
}
},
//**************************************************************************
// Formating String
//**************************************************************************
stringFormat: function(format)
{
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/\{(\d+)\}/g, function(m, i){
return args[i];
});
},
//**************************************************************************
// String both trim
//**************************************************************************
trim: function(data)
{
return data.replace(/^\s+|\s+$/g,"");
},
//**************************************************************************
// String left only trim
//**************************************************************************
ltrim: function(data)
{
return data.replace(/^\s+/,"");
},
//**************************************************************************
// String right only trim
//**************************************************************************
rtrim: function(data)
{
return data.replace(/\s+$/,"");
},
//**************************************************************************
// get cookie value
//**************************************************************************
getCookie: function(cname)
{
var cookies = document.cookie.toString().split(';');
cname = SIBULIB.trim(cname.toString());
for(var n in cookies)
{
var element = SIBULIB.ltrim(cookies[n]);
var pos = element.indexOf('=');
if( pos == -1 ){
continue;
}
if( element.substring(0, pos) == cname ){
return unescape( element.substring(pos + 1) );
}
}
return '';
},
//**************************************************************************
// set and replace cookie value
//**************************************************************************
setCookie: function(cname, value, path, domain, expires, isSecure)
{
var cookie = SIBLIB.trim(cname.toString()) + '=' + escape(value);
if( path ){
cookie += 'path=' + path + '; ';
}
if( domain ){
cookie += 'domain=' + domain + '; ';
}
if( expires && (expires instanceof Date) ){
cookie += 'expires=' + expires.toGMTString() + '; ';
}
if( expires && (expires instanceof String) ){
cookie += 'expires=' + expires + '; ';
}
if( isSecure ){
cookie += 'secure';
}
document.cookie = cookie;
},
//**************************************************************************
// send log data by post method
//**************************************************************************
sendPostData: function(data)
{
// write iframe tag
var iframe = document.createElement( 'iframe' );
iframe.id = SIBULIB.iframeId;
iframe.setAttribute( 'name', SIBULIB.iframeId );
iframe.setAttribute( 'src', 'javascript:false' );
iframe.setAttribute( 'width', '1' );
iframe.setAttribute( 'height', '1' );
iframe.setAttribute( 'border', '0' );
iframe.setAttribute( 'frameborder', 'no' );
document.body.appendChild(iframe);
// get iframe document
var childDoc = ( SIBULIB.isIE() ?
iframe.contentWindow.document : (iframe.contentDocument || window.frames[SIBULIB.iframeId].document) );
// write form tag
var protocol = location.protocol;
var sendUrl = (protocol == "http:" ? SIBULIB.sendUrls['http'] : SIBULIB.sendUrls['https']);
var content = SIBULIB.stringFormat( SIBULIB.iframeContentTemplate, SIBULIB.formId, SIBULIB.formId, sendUrl, 'post' );
childDoc.open();
childDoc.write( content );
childDoc.close();
// get form element and submit
var childForms = childDoc.getElementsByName( SIBULIB.formId );
SIBULIB.writeHiddenData( childDoc, childForms[0], data );
childForms[0].submit();
//remove iframe( 500msec later)
var tId = window.setTimeout( function(){
document.body.removeChild( iframe );
try{
window.clearTimeout( tId );
}
catch(e){
;
}
}, 500 );
},
//**************************************************************************
// send log data by get method
//**************************************************************************
sendGetData: function(data, objImg)
{
var protocol = location.protocol;
var sendUrl = (protocol == "http:" ? SIBULIB.sendUrls['http'] : SIBULIB.sendUrls['https']);
//
// hash to array
//
var params = new Array();
for( var n in data ){
if( typeof(params[n]) == 'function' ){
continue;
}
if( n == 'REFERER' || n == 'w' || n == 't' ){
continue;
}
params.push( n + '=' + data[n] );
}
//
//append title, width and referer
//
if( 't' in data ){
params.push( 't=' + data['t'] );
}
if( 'w' in data ){
params.push( 'w=' + data['w'] );
}
if( 'REFERER' in data ){
params.push( 'REFERER=' + data['REFERER'] );
}
//
//append parameters
//
sendUrl += (params.length > 0 ? '?' : '');
sendUrl += params.join('&');
//
//create and send log data
//
if( objImg ){
objImg.src = sendUrl;
}
else{
var imgTag = SIBULIB.stringFormat( SIBULIB.imgContentTemplate, sendUrl );
document.write( imgTag );
}
},
//**************************************************************************
// Write Hidden Tag
//**************************************************************************
writeHiddenData: function(doc, form, data)
{
var protocol = location.protocol;
var sendUrl = (protocol == "http:" ? SIBULIB.sendUrls['http'] : SIBULIB.sendUrls['https']);
//
// hash to array
//
var params = new Array();
for( var n in data ){
if( typeof(params[n]) == 'function' ){
continue;
}
if( n == 'REFERER' || n == 'w' || n == 't' ){
continue;
}
params.push( {
name: n,
value: data[n]
} );
}
//
//append title, width and referer
//
if( 't' in data ){
params.push( {
name: 't',
value: data['t']
} );
}
if( 'w' in data ){
params.push( {
name: 'w',
value: data['w']
} );
}
if( 'REFERER' in data ){
params.push( {
name: 'REFERER',
value: data['REFERER']
} );
}
//
//write hidden tag
//
for( var i = 0; i < params.length; i++ ){
if( typeof(params[i]) == 'function' ){
continue;
}
SIBULIB.createHiddenElement( doc, form, params[i].name, params[i].value );
}
},
//**************************************************************************
// create hidden tag
//**************************************************************************
createHiddenElement: function(doc, parent, name, value)
{
var element = doc.createElement('input');
element.type = 'hidden';
element.name = name;
element.value = value;
parent.appendChild(element);
return element;
},
//**************************************************************************
// get current url(current page url & referer url)
//**************************************************************************
getCurrentUrls: function()
{
var refer = '';
var url = '';
try{
if (document.referrer == parent.frames.location) {
refer = top.document.referrer.toString();
url = location.href.toString();
}
else {
refer = document.referrer.toString();
url = document.location.href.toString();
}
if (refer.length == "" && window.opener != null) {
refer = window.opener.location.toString();
url = location.href.toString();
}
}catch(e){
refer = document.referrer.toString();
url = location.href.toString();
}
return {
'referer': refer,
'request': url
};
},
//**************************************************************************
// url encoding
//**************************************************************************
urlEncode: function(str)
{
var s0, i, s, u;
s0 = ""; // encoded str
for (i = 0; i < str.length; i++){ // scan the source
s = str.charAt(i);
u = str.charCodeAt(i); // get unicode of the char
if (s == " "){s0 += "+";} // SP should be converted to "+"
else {
if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){ // check for escape
s0 = s0 + s; // don't escape
}
else { // escape
if ((u >= 0x0) && (u <= 0x7f)){ // single byte format
s = "0"+u.toString(16);
s0 += "%"+ s.substr(s.length-2);
}
else if (u > 0x1fffff){ // quaternary byte format (extended)
s0 += "%" + (0xf0 + ((u & 0x1c0000) >> 18)).toString(16);
s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
}
else if (u > 0x7ff){ // triple byte format
s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
}
else { // double byte format
s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
}
}
}
}
return s0;
},
//**************************************************************************
// subtract parameter
//**************************************************************************
getSubtractParam: function(refer)
{
try{
if (refer == null || refer.length == 0 || (refer.indexOf("http://",0) == -1 && refer.indexOf("https://",0) == -1)) {
return "";
}
}
catch(Exception){
return "";
}
var new_refer = refer;
var index = refer.indexOf("?",0);
if (index != -1 || refer.length < index) {
new_refer = refer.substring(0,index);
}
return new_refer;
},
//**************************************************************************
// add event handler
//**************************************************************************
addEvent: function(target, eventName, handler)
{
if( SIBULIB.isIE() == true ){
target.attachEvent( 'on' + eventName, function() {
handler.call( target, window.event );
} );
}
else{
target.addEventListener( eventName, handler, false );
}
},
//**************************************************************************
// initilize ec data
//**************************************************************************
initEcData: function(cno, totalBuyCount, totalBuyMoney, orderNo, totalPrice)
{
return {
'cust_no': cno || '', //customer no
'total_buy_count': (totalBuyCount ? parseInt(totalBuyCount) : 0 ), //total buy count( including this timing)
'total_buy_money': (totalBuyMoney ? parseInt(totalBuyMoney) : 0 ), //total buy money( including this timing)
'order_no': orderNo || '', //order no
'total_price': (totalPrice ? parseInt(totalPrice) : 0 ), //total price
'items': [] //array of detail item data
};
},
//**************************************************************************
// append ec item data
//**************************************************************************
appendEcItem: function(ecData, itemNo, itemName, itemCount, itemUnitPrice, itemPrice)
{
var item = {
'no': itemNo || '', //item no
'name': itemName || '', //item name
'count': ( itemCount == undefined ? 0 : parseInt(itemCount) ), //number
'unit_price': ( itemUnitPrice == undefined ? 0 : parseInt(itemUnitPrice) ), //unit price
'price': ( itemPrice == undefined ? 0 : parseInt(itemPrice) ) //total price( number * unit price)
}
ecData.items.push( item );
},
//**************************************************************************
// create ec data
//**************************************************************************
createEcData: function(cno, totalBuyCount, totalBuyMoney, orderNo, totalPrice, itemNos, itemNames, itemCounts, itemUnitPrices, itemPrices, sep)
{
var nos = (itemNos ? itemNos.split(sep) : new Array());
var names = (itemNames ? itemNames.split(sep) : new Array());
var counts = (itemCounts ? itemCounts.split(sep) : new Array());
var unitPrices = (itemUnitPrices ? itemUnitPrices.split(sep) : new Array());
var prices = (itemPrices ? itemPrices.split(sep) : new Array());
var ecData = SIBULIB.initEcData(cno, totalBuyCount, totalBuyMoney, orderNo, totalPrice);
for( var i = 0; i < nos.length; i++ ){
var no = nos[i];
var name = names[i] || '';
var count = (counts[i] ? parseInt(counts[i]) : 0);
var unitPrice = (unitPrices[i] ? parseInt(unitPrices[i]) : 0);
var price = (prices[i] ? parseInt(prices[i]) : 0);
SIBULIB.appendEcItem( ecData, no, name, count, unitPrice, price );
}
return ecData;
}
};
//*****************************************************************************
//regular type
//*****************************************************************************
function c6f67(id)
{
var urls = SIBULIB.getCurrentUrls();
var data = {
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'REFERER': urls.referer
};
SIBULIB.sendGetData( data );
}
//*****************************************************************************
//referer without params type
//*****************************************************************************
function c6f68(id)
{
var urls = SIBULIB.getCurrentUrls();
var data = {
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'REFERER': SIBULIB.getSubtractParam( urls.referer )
};
SIBULIB.sendGetData( data );
}
//*****************************************************************************
//send current url without params
//*****************************************************************************
function c6f69(id)
{
var urls = SIBULIB.getCurrentUrls();
var data = {
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'URL': SIBULIB.urlEncode( SIBULIB.getSubtractParam( urls.request ) ),
'REFERER': urls.referer
};
SIBULIB.sendGetData( data );
}
//*****************************************************************************
//send current url with user param
//*****************************************************************************
function c6f70(id, param)
{
var urls = SIBULIB.getCurrentUrls();
var prms = (param != undefined ? '?' + param : '');
var data = {
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'URL': SIBULIB.urlEncode( SIBULIB.getSubtractParam(urls.request) + prms ),
'REFERER': urls.referer
};
SIBULIB.sendGetData( data );
}
//*****************************************************************************
//send flash click log
//*****************************************************************************
function c6f71(id, gifid, param)
{
var urls = SIBULIB.getCurrentUrls();
var prms = (param != undefined ? '?' + param : '');
var dt = new Date();
var data = {
'r': dt.getTime(),
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'URL': SIBULIB.urlEncode( SIBULIB.getSubtractParam(urls.request) + prms ),
'REFERER': urls.referer
};
var objImg = document.images[gifid];
SIBULIB.sendGetData( data, objImg );
}
//*****************************************************************************
// ATTENSION!! Dynamic tag server only!!
//frame site send log
//*****************************************************************************
function c6f72(id)
{
var urls = SIBULIB.getCurrentUrls();
var refer = urls.referer;
var siteurls = new Array('http://drink.s140.xrea.com/','http://www.isize.com/','http://www24.atwiki.jp/realwebanalytics/','https://drink.s140.xrea.com/','https://www.isize.com/');
// get referer from cookie
for(var n in siteurls){
if( typeof(siteurls[n]) == 'function' ){
continue;
}
var siteurl = siteurls[n];
if( siteurl == refer.substring(0, siteurl.length) ){
refer = getCookie( 'siburefer' );
break;
}
}
// set request url to cookie
setCookie( 'siburefer', location.href );
var data = {
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'REFERER': refer
};
SIBULIB.sendGetData( data );
}
//*****************************************************************************
// send with ec data
//*****************************************************************************
function c6f73(id, ecData)
{
var ec = SIBULIB.jsonEncode( ecData );
var urls = SIBULIB.getCurrentUrls();
var data = {
'ec': SIBULIB.urlEncode( ec ),
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'URL': urls.request,
'REFERER': urls.referer
};
//add onload event
SIBULIB.addEvent(window, 'load', function(){
SIBULIB.sendPostData( data );
} );
}
//*****************************************************************************
//send flash click log (new version)
//*****************************************************************************
function c6f74(id, param)
{
var urls = SIBULIB.getCurrentUrls();
var prms = (param != undefined ? '?' + param : '');
var dt = new Date();
var data = {
'r': dt.getTime(),
'id': id,
't': SIBULIB.urlEncode( document.title ),
'w': screen.width,
'h': screen.height,
'URL': SIBULIB.urlEncode( SIBULIB.getSubtractParam(urls.request) + prms ),
'REFERER': urls.referer
};
// create or get sibulla image gif element
var objImg = null;
try{
objImg = document.getElementById('sibulla_gif20091113');
}
catch( e ){
;
}
if( !objImg ){
objImg = document.createElement('img');
objImg.id = 'sibulla_gif20091113';
objImg.width = 1;
objImg.height = 1;
document.body.appendChild( objImg );
}
SIBULIB.sendGetData( data, objImg );
return true;
}
var id = 'texc4ynl';
var param = '';
c6f67(id);