测试地震
<script>
var times = 0;
var ms = new Date();
var prex =0;
var pretoright=false;
var level =0;
function trackEarthQuake(){
var curx = event.screenX;
var toright ;
if(curx>prex){
level += curx-prex;
toright=true;
} else {
toright=false;
}
prex = curx;
if(pretoright!=toright){
times ++;
}
pretoright=toright;
var curms=new Date();
if(times>=10){
times=0;
intervalms = curms-ms;
if(intervalms<=1600){
alert("有地震!快跑!地震级别为"+Math.round(Math.log(level)));
}
ms=curms;
level=0;
}
}
</script>
<body onmousemove="trackEarthQuake()">
</body>