heartbeat

    技术2022-05-11  102

    var timer;var usingERIS=true;var _xmlHttp=null; function GetParamValue(name){  var reg = new RegExp("(^|//?|&)"+ name +"=([^&]*)(//s|&|$)", "i");    if (reg.test(window.location.href))   {      return RegExp.$2;  }    return "";}     // Create XMLHttpRequest objectfunction getXMLHTTP() { var xmlHttpObject=null;  try {  xmlHttpObject=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {  try {   xmlHttpObject=new ActiveXObject("Microsoft.XMLHTTP");  } catch (oc) {   xmlHttpObject=null;  } } if ((!xmlHttpObject)&&(typeof(XMLHttpRequest!="undefined")))  xmlHttpObject=new XMLHttpRequest(); return(xmlHttpObject);} // Send a http requestfunction sendHttpRequest() { if (_xmlHttp) {  _xmlHttp.open("GET", url, true);  _xmlHttp.onreadystatechange=OnReady;  _xmlHttp.send(null); }} function OnReady(){   if ((_xmlHttp.readyState==4)&&(_xmlHttp.responseText)) {    if (_xmlHttp.responseText.indexOf("FAIL")==0) {     alert("The record is already locked by another user");     window.location.href='/Web/Navigation/Welcome.aspx';         }    else     window.setTimeout("sendHeartbeat()", heartbeat_period);   }  } // Send heartbeat by XMLHttpRequest objectfunction sendHeartbeat() { //if (enable_lock=='Y') {  if ((_xmlHttp)&&(_xmlHttp.readyState!=0))   _xmlHttp.abort();  _xmlHttp=getXMLHTTP();  if (usingERIS==true)   sendHttpRequest(); //}} // Prompt if the user is idle for too longfunction promptAlive() { var message = 'Your data entry session has been idled too long, would you like to continue?'; window.focus(); usingERIS=false;  usingERIS = confirm(message); if (usingERIS==true) {  sendHttpRequest();  window.setTimeout("sendHeartbeat()", heartbeat_period);  resetIdleTimer(); } else {       window.location.href='./Navigation/Welcome.aspx'; }} // Reset the timer for user idlefunction resetIdleTimer() { //if (enable_lock=='Y') {  if (timer)   window.clearInterval(timer);  timer=window.setTimeout("promptAlive()", max_idle_time); //}}

    最新回复(0)