a 60s'button using localStorage
- remainTime()
- changeButtonState()
- timeEvent()
- entry()
Calculate the remaining time.
If the storage start-time
is not populated, it will return 60s and create the storage start-time
.
Else, it will return the remaining time.
Change the button's state.
If the remaining time equal or less than 0s, it will change the button's value, disable state.Of course, it will remove
the storage start-time
and the cron job.
Else, it will change the button's value about the remaining time and be sure that the button's state is disabled.
Change the state of the button once every second.
Every time you open the page(maybe you refresh the page),it will check the storage start-time
.
If the storage start-time
is not populated, it will bind the function timeEvent
on the button.
Else, run the function timeEvent
automatically.