我找不到托管 Flipclock 的 CDN,所以这里是代码。
计数器每 5 到 20 秒递增 +1。
<html>
<head>
<link rel="stylesheet" href="../compiled/flipclock.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../compiled/flipclock.js"></script>
</head>
<body>
<div class="clock" style="margin:2em;"></div>
<div class="message"></div>
<script type="text/javascript">
var clock;
var nextDoubleJump;
var internalCounter;
$(document).ready(function() {
internalCounter = 0;
nextDoubleJump = getRandomIntInclusive(5, 20);
console.log('Next jump value: ' + nextDoubleJump);
clock = $('.clock').FlipClock({
clockFace: 'Counter',
autoStart: false,
});
setInterval(function(){
internalCounter += 1;
console.log(internalCounter);
if(internalCounter == nextDoubleJump) {
clock.increment();
nextDoubleJump = getRandomIntInclusive(5, 20) + internalCounter;
console.log('Next jump value: ' + nextDoubleJump);
}
}, 1000);
});
function getRandomIntInclusive(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
</script>
</body>
</html>