Commit ff5e5a6c authored by Bc. Peter Štieber's avatar Bc. Peter Štieber
Browse files

replace of jquery timer for pure vanilla js timer

parent 9595549b
Pipeline #13202 passed with stage
in 2 minutes and 1 second
......@@ -96,16 +96,30 @@ $time_leaving = 20;
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var showTime = function() {
$('#time').text(new Date().toLocaleTimeString());
};
setInterval(showTime,200);
});
document.onreadystatechange = () => {
if (document.readyState === 'complete') {
startTime() // document ready
}
};
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('time').innerHTML = h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment