heartbeat

 
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 object
function 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 request
function 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 object
function 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 long
function 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 idle
function resetIdleTimer() {
 //if (enable_lock=='Y') {
  if (timer)
   window.clearInterval(timer);
  timer=window.setTimeout("promptAlive()", max_idle_time);
 //}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值