2015-03-31 20:15:22 +02:00
|
|
|
/**
|
2020-02-29 17:23:20 +01:00
|
|
|
* Created by feliciaan on 30/03/15.
|
|
|
|
*/
|
2015-03-31 20:15:22 +02:00
|
|
|
$.ready(function(){
|
2020-02-29 17:23:20 +01:00
|
|
|
$('.time').each(function() {
|
|
|
|
var timeEl = $( this );
|
|
|
|
var time = timeEl.text().split(' ')[0].split(':');
|
2015-03-31 20:15:22 +02:00
|
|
|
|
2020-02-29 17:23:20 +01:00
|
|
|
if (timeEl.text().indexOf('closed') < 0) {
|
|
|
|
window.setInterval(function () {
|
|
|
|
time = my_tick(time);
|
|
|
|
if (time !== "closed") {
|
|
|
|
timeS = ("0" + time[0]).slice(-2) + ":" + ("0" + time[1]).slice(-2) + ":" + ("0" + time[2]).slice(-2) + " left";
|
|
|
|
} else {
|
|
|
|
timeS = "closed"
|
|
|
|
}
|
|
|
|
timeEl.html(timeS);
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
});
|
2015-03-31 20:15:22 +02:00
|
|
|
|
2020-02-29 17:23:20 +01:00
|
|
|
function my_tick(time) {
|
|
|
|
if (time[2] > 0) {
|
|
|
|
time[2] = time[2] - 1;
|
|
|
|
} else if(time[1] > 0) {
|
|
|
|
time[2] = 59;
|
|
|
|
time[1] = time[1] - 1;
|
|
|
|
} else if(time[0] > 0) {
|
|
|
|
time[1] = 59;
|
|
|
|
time[0] = time[0] - 1;
|
|
|
|
} else {
|
|
|
|
return "closed";
|
|
|
|
}
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
}());
|