JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<div id="timer"></div>
<input type="button" id="b1" value="button 1">
<input type="button" disabled id="b2" value="button 2">
<input type="button" disabled id="b3" value="button 3">
JavaScript
var timer = {
init: function() {
if(!$.cookie("timer")) {
this.time = 0;
$.cookie("timer", 0)
}
// Устанавливаем текущее время с cookies
this.time = $.cookie("timer");
// иницализируем время на скрине
this.initTime();
// включаем кнопки
var that = this;
setInterval(function() {
that.enableButtons();
that.initTime();
$.cookie("timer", that.time++);
}, 1000);
},
enableButtons: function() {
// Тут можете установить интервал отображения кнопок
var btnEnable = this.time / (60 * 5);
// ужасный код снизу, не берите в пример
if(btnEnable >= 1) {
$("#b2").removeAttr("disabled");
} else if(btnEnable >= 2) {
$("#b3").removeAttr("disabled");
}
},
initTime: function() {
$("#timer").html(this.time);
}
}
timer.init();