From cfc0373f44ab4fcc9cab61ecd6d14e8233c1d283 Mon Sep 17 00:00:00 2001 From: Damian <> Date: Wed, 18 Dec 2019 17:19:47 +0000 Subject: [PATCH] doifclock.js: clock with date git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20777 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- contrib/DOIF/doifclock.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 contrib/DOIF/doifclock.js diff --git a/contrib/DOIF/doifclock.js b/contrib/DOIF/doifclock.js new file mode 100644 index 000000000..98619eb41 --- /dev/null +++ b/contrib/DOIF/doifclock.js @@ -0,0 +1,25 @@ +function startTime() { + var today = new Date(); + var h = today.getHours(); + var m = today.getMinutes(); + var d = today.getDate(); + var mo = today.getMonth()+1; + var y = today.getFullYear(); + var dofw =today.getDay(); + var days = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']; + h = checkTime(h); + m = checkTime(m); + d = checkTime(d); + mo = checkTime(mo); + $('.doifclock').each(function(){ + $(this).html(h + ":" + m + "  " + days[dofw] + " " + d + "." + mo + "." + y); + }); + var t = setTimeout(startTime,1000); + +} +function checkTime(i) { + if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10 + return i; +} + +startTime(); \ No newline at end of file