//================管理画面表示==================== var showAdminLink = false; document.write(""); function fixAdminLink() { /* if(showAdminLink == false) { document.getElementById("adminlink").style.backgroundColor = "#99ffff"; document.getElementById("adminlink").innerHTML = "管理画面"; showAdminLink = true; } else { document.getElementById("adminlink").innerHTML = ""; document.getElementById("adminlink").style.backgroundColor = ""; showAdminLink = false; } */ } //===============スクロール位置表示=================== var showHeight = false; //if(document.cookie.indexOf("admin")>=0 ) { document.write("
"); //} function showScrollHeight() { document.getElementById("result").style.backgroundColor = "blue"; document.getElementById("result").style.width = "60px"; document.getElementById("result").style.height = "15px"; } function hideScrollHeight() { document.getElementById("result").style.backgroundColor = ""; document.getElementById("result").style.width = "40px"; document.getElementById("result").style.height = "40px"; document.getElementById("result").innerHTML = ""; } function fixScrollHeight() { if(showHeight == false) { showScrollHeight(); showHeight = true; } else { hideScrollHeight(); showHeight = false; } } var maxY = 0; var recording = false;//実際にスクロール位置が記録されているかどうか //==========スクロールイベントでスクロール位置を更新==================== try { document.body.onscroll = recordMaxY(); recording = true; }catch(e) { } //============タイマーイベントでスクロール位置を更新===================== startRecordMaxY();//debug function startRecordMaxY() { //alert("startRecordMaxY"); try { setInterval("recordMaxY()",250); recording = true; }catch(e) { } } function recordMaxY() { tmpY = kl_sly(); if(tmpY>maxY) maxY = tmpY; document.getElementById("adminlink").style.top = tmpY; document.getElementById("result").style.top = tmpY; if(showHeight) { try { document.getElementById("result").innerHTML = tmpY; } catch(e) { } } else document.getElementById("result").innerHTML = ""; } //=============アンロードイベントでスクロール位置を送信=================== //***オリジナルのunloadを保存 var oldunload; try { oldunload = document.body.onunload; } catch(e) { } //***登録したいイベントを登録 try { document.body.onunload = sendMaxY; }catch(e) { } function sendMaxY() { //***オリジナルのunloadを実行 try { oldunload(); } catch(e) { } //***目的の処理を実行 if( recording == true ) { loadWebPage(); } } //alert(location.href +" : "+ encodeURL(location.href)); //=============HTTP GET===================================================== function loadWebPage() { //alert("loadWebPageが呼び出されました。");//debug xmlhttp = createXMLHttpRequest(); if (xmlhttp) { requestData = "./agent.php?maxY="+maxY+"&url="+encodeURL(location.href); xmlhttp.onreadystatechange = rr_check; xmlhttp.open("get", requestData, true); xmlhttp.send(""); } } function rr_check() { // alert(xmlhttp.responseText); if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // document.getElementById("result").innerHTML = xmlhttp.responseText; } } // XMLHttpオブジェクト作成 function createXMLHttpRequest() { var XMLhttpObject = null; try{ XMLhttpObject = new XMLHttpRequest(); }catch(e){ try{ XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ return null; } } } return XMLhttpObject; } //URL Encode (UTF-8) function encodeURL(str) { var character = ''; var unicode = ''; var string = ''; var i = 0; for (i = 0; i < str.length; i++) { character = str.charAt(i); unicode = str.charCodeAt(i); if (character == ' ') { string += '+'; } else { if (unicode == 0x2a || unicode == 0x2d || unicode == 0x2e || unicode == 0x5f || ((unicode >= 0x30) && (unicode <= 0x39)) || ((unicode >= 0x41) && (unicode <= 0x5a)) || ((unicode >= 0x61) && (unicode <= 0x7a))) { string = string + character; } else { if ((unicode >= 0x0) && (unicode <= 0x7f)) { character = '0' + unicode.toString(16); string += '%' + character.substr(character.length - 2); } else if (unicode > 0x1fffff) { string += '%' + (oxf0 + ((unicode & 0x1c0000) >> 18)).toString(16); string += '%' + (0x80 + ((unicode & 0x3f000) >> 12)).toString(16); string += '%' + (0x80 + ((unicode & 0xfc0) >> 6)).toString(16); string += '%' + (0x80 + (unicode & 0x3f)).toString(16); } else if (unicode > 0x7ff) { string += '%' + (0xe0 + ((unicode & 0xf000) >> 12)).toString(16); string += '%' + (0x80 + ((unicode & 0xfc0) >> 6)).toString(16); string += '%' + (0x80 + (unicode & 0x3f)).toString(16); } else { string += '%' + (0xc0 + ((unicode & 0x7c0) >> 6)).toString(16); string += '%' + (0x80 + (unicode & 0x3f)).toString(16); } } } } return string; } function decodeURL(str){ var s0, i, j, s, ss, u, n, f; s0 = ""; // decoded str for (i = 0; i < str.length; i++){ // scan the source str s = str.charAt(i); if (s == "+"){s0 += " ";} // "+" should be changed to SP else { if (s != "%"){s0 += s;} // add an unescaped char else{ // escape sequence decoding u = 0; // unicode of the character f = 1; // escape flag, zero means end of this sequence while (true) { ss = ""; // local str to parse as int for (j = 0; j < 2; j++ ) { // get two maximum hex characters for parse sss = str.charAt(++i); if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f")) || ((sss >= "A") && (sss <= "F"))) { ss += sss; // if hex, add the hex character } else {--i; break;} // not a hex char., exit the loop } n = parseInt(ss, 16); // parse the hex str as byte if (n <= 0x7f){u = n; f = 1;} // single byte format if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;} // double byte format if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;} // triple byte format if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;} // quaternary byte format (extended) if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;} // not a first, shift and add 6 lower bits if (f <= 1){break;} // end of the utf byte sequence if (str.charAt(i + 1) == "%"){ i++ ;} // test for the next shift byte else {break;} // abnormal, format error } s0 += String.fromCharCode(u); // add the escaped character } } } return s0; }