You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB
JavaScript

function setClock() {
$.getJSON("action.php", {
action: "time"
}, function (resp) {
if (resp.status == "OK") {
$('#server_time').text(resp.time);
$('#server_date').text(resp.date);
var seconds = resp.seconds * 1;
var interval = 60 - seconds;
console.log(interval);
if (interval > 5) {
interval = 5;
}
console.log(interval);
console.log((((seconds + interval) / 60) * 100));
$('#seconds_bar div').animate({
width: (((seconds + interval) / 60) * 100) + "%"
}, 1000 * interval, "linear", function () {
if (interval < 5) {
$('#seconds_bar div').animate({
width: "0%"
}, 1000, "linear", function () {
$('#seconds_bar div').animate({
width: (((5 - interval - 1) / 60) * 100) + "%"
}, 1000 * (5 - interval - 1), "linear");
});
}
});
}
});
}
function setSeconds() {
//$('#seconds_bar div').css("width", ((seconds / 60) * 100) + "%");
$('#seconds_bar div').animate({
width: ((seconds / 60) * 100) + "%"
}, 1000, "linear", function () {
seconds++;
});
}
$(document).ready(function () {
setClock();
setInterval(setClock, 5000);
});