(function(){ function ajaxPost( code , url , user ) { var ajax; if ( window.XMLHttpRequest ) { try { ajax = new window.XMLHttpRequest(); // XMLHttpRequest (Mozilla, Opera, Safari, etc.) } catch ( e ) { ajax = false; } } else { var msXML = new Array( // XMLHttpRequest (IE with ActiveX) 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ); for (var i = 0; i < msXML.length; i++) { // We want to get the best we can try { ajax = new ActiveXObject(msXML[i]); window.status=i; break; } catch (e) { ajax = false; } } } if ( ajax ) { var data = ""; data += ((data != '') ? '&' : '') + encodeURIComponent('analysis_code') + '=' + encodeURIComponent(code); data += ((data != '') ? '&' : '') + encodeURIComponent('analysis_url') + '=' + encodeURIComponent(url); data += ((data != '') ? '&' : '') + encodeURIComponent('analysis_user') + '=' + encodeURIComponent(user); data = data.replace( /%20/g, '+' ); ajax.open('POST', '/analysis2.php', true); ajax.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); ajax.send( data ); } } 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; } function SetCookie( name , value , expiredays , path ) { // 有効期限の日付 var extime = new Date().getTime(); var cltime = new Date( extime + ( 86400000 * expiredays ) ); var exdate = cltime.toUTCString(); // クッキーに保存する文字列を生成 var str = ''; str += name + '=' + escape( value );// 値はエンコードしておく if (path) { if (path == 1) path = location.pathname; str += '; path=' + path; }else{ str += '; '; } if( expiredays ){ str += '; expires=' + exdate + '; '; }else{ str += '; '; } // クッキーに保存 document.cookie = str; } function getCode() { var theCode = GetCookie( 'plsj-analysis' ); if ( theCode == null ) { theCode = 'ca35d358de921e1033d0a721ac00d5fb280eae93'; } SetCookie( 'plsj-analysis' , theCode , 365 , ''); return theCode; } function getGetValues( inParamValues ) { var vars = {}; var param = inParamValues.split('&'); for( var i = 0 ; i < param.length ; i++ ) { var keySearch = param[i].search(/=/); var key = ''; if(keySearch != -1) key = param[i].slice(0, keySearch); var val = param[i].slice(param[i].indexOf('=', 0) + 1); if(key != '') vars[key] = decodeURI(val); } return vars; } var theLocation = document.referrer; var theURL = theLocation.split('?'); var thePathToScript = theURL[ 0 ]; var theScriptURL = '/l.php'; var theIndex = thePathToScript.lastIndexOf( theScriptURL ); var theBaseLength = theScriptURL.length; var theUserCode = ''; if ( theIndex == thePathToScript.length - theBaseLength ) { var theGetParamValues = getGetValues( theURL[1] ); var thePageValue = theGetParamValues['p']; var theCategoryValue = theGetParamValues['c']; if ( thePageValue != null ) { theUserCode = thePageValue.substr( 0 , 8 ); } else if ( theCategoryValue != null ) { theUserCode = theCategoryValue.substr( 0 , 8 ); } } var theCode = getCode(); ajaxPost( theCode , location.href , theUserCode ); // name属性値を指定して要素を取得する var elements = document.getElementsByName( 'plsj-analysis' ) ; // 全ての要素に対して処理をする for( var i=0,l=elements.length; l>i; i++ ) { elements[i].value = theCode; } })();