<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="title">Start</div>
<a id="waiting" href="http://ya.ru/" target="_blank" data-load="1">Click</a>
<script>
function eHide(sec, checkLocalStorage) {
if (checkLocalStorage && localStorage.getItem('eHideSec')) {
var savedSec = localStorage.getItem('eHideSec');
if (savedSec > 0) sec = savedSec;
}
var time = sec;
var hour = parseInt(time / 3600);
if (hour < 1) hour = 0;
time = parseInt(time - hour * 3600);
if (hour < 10) hour = '0' + hour;
var minutes = parseInt(time / 60);
if (minutes < 1) minutes = 0;
time = parseInt(time - minutes * 60);
if (minutes < 10) minutes = '0' + minutes;
var seconds = time;
if (seconds < 10) seconds = '0' + seconds;
document.getElementById("title").innerHTML = 'Wait ' + hour + ':' + minutes + ':' + seconds;
localStorage.setItem('eHideSec', sec);
sec--;
if (sec >= 0) {
window.setTimeout(function () {
eHide(sec);
}, 1000);
enabled = false;
} else {
document.getElementById("title").innerHTML = 'The End!';
$("#waiting").attr("data-load", '1');
}
}
if (localStorage.getItem('eHideSec') && localStorage.getItem('eHideSec') > 0) {
$("#waiting").attr("data-load", '0');
eHide(15, true);
}
$("#waiting").on("click", function () {
if ($(this).attr("data-load") == 1) {
$(this).attr("data-load", '0');
eHide(15, true);
} else {
alert('forbidden')
return false;
}
});
</script>
</body>
</html>