master
Minetest-j45 2021-10-30 10:28:29 +01:00
parent ec20eebeca
commit abd7d063d1
3 changed files with 72 additions and 0 deletions

20
base.css Normal file
View File

@ -0,0 +1,20 @@
body {
height: 100%;
background: linear-gradient(to bottom right, #cc0099 1%, #9999ff 100%);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: 'Lucida Console', "Courier New", monospace;
}
#clock {
background-color: #8cffff;
width: 75%;
padding-top: 5%;
padding-bottom: 5%;
margin-top: 10%;
margin-bottom: 10%;
margin-left: 12.5%;
margin-right: 12.5%;
font-size: 10vw;
text-align: center;
border: 5px outset purple;
}

11
index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Digital Clock</title>
<link rel="stylesheet" href="./base.css">
</head>
<body>
<div id="clock"></div>
<script src="./main.js"></script>
</html>

41
main.js Normal file
View File

@ -0,0 +1,41 @@
function getHour() {
var d = new Date();
//return d.getHours();
var hour = ""+d.getHours();
if (hour.length == 1) {
hour = "0" + hour;
}
return hour;
}
function getMinute() {
var d = new Date();
//return d.getMinutes();
var minute = ""+d.getMinutes();
if (minute.length == 1) {
minute = "0" + minute;
}
return minute;
}
function getSecond() {
var d = new Date();
//return d.getSeconds();
var second = ""+d.getSeconds();
if (second.length == 1) {
second = "0" + second;
}
return second;
}
function drawClock() {
var clock = document.getElementById('clock');
clock.innerHTML = getHour() + ":" + getMinute() + ":" + getSecond();
updateClock();
}
function updateClock() {
setTimeout(drawClock, 1000);
}
drawClock();