Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/rz3n/hugo-theme-freshstart.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Franzen <rfranzen@gmail.com>2020-08-14 01:58:58 +0300
committerRicardo Franzen <rfranzen@gmail.com>2020-08-14 01:58:58 +0300
commit285af4778eeb9e46fc8c1086b74c5376de3e403c (patch)
tree0afb0f951fb8974bc1c561ff705b68b86a7db8f5
parent3e77d51d2b44783e109c6ba29ce4f2edcf90daef (diff)
small javascript just for the clock and date
-rw-r--r--layouts/partials/footer.html24
-rw-r--r--layouts/partials/head.html4
-rw-r--r--layouts/partials/header.html8
-rw-r--r--static/js/app.js61
4 files changed, 25 insertions, 72 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 35dfe13..4574d1c 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,5 +1,27 @@
+<script>
+ var timer = setInterval(function() {
+ localTimer();
+ }, 1000);
+
+ function addZero(i) {
+ if (i < 10) {
+ i = "0" + i;
+ }
+ return i;
+ }
+
+ function localTimer() {
+ var today = new Date();
+ var time = addZero(today.getHours()) + ":" + addZero(today.getMinutes()) + ":" + addZero(today.getSeconds());
+ document.getElementById("current_time").innerHTML = time;
+
+ var date = today.getDate()+' . '+(today.getMonth()+1)+' . '+today.getFullYear();
+ document.getElementById("current_date").innerHTML = date;
+}
+</script>
+
<!--
<footer>
</footer>
---> \ No newline at end of file
+-->
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index fa08993..c1f5a15 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -8,10 +8,6 @@
{{ if .Site.Params.description }}<meta name="description" content="{{ .Site.Params.description }}" />{{ end }}
{{ if .Site.Params.favicon }} <link rel="icon" href="{{ .Site.Params.favicon }}" /> {{ end }}
- <script src="/js/app.js"></script>
- <script
- src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
-
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
</head>
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 7d2365c..6bd32a1 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -12,15 +12,11 @@
<ul class="datetime">
<li class="date">
<i class="far fa-calendar"></i>&nbsp;
- <span class="date-day"></span> .
- <span class="date-month"></span> .
- <span class="date-year"></span>
+ <span id="current_date"></span>
</li>
<li class="time">
<i class="far fa-clock"></i>&nbsp;
- <span class="time-hours"></span> :
- <span class="time-minutes"></span> :
- <span class="time-seconds"></span>
+ <span id="current_time"></span>
</li>
</ul>
</div>
diff --git a/static/js/app.js b/static/js/app.js
deleted file mode 100644
index 7bd0920..0000000
--- a/static/js/app.js
+++ /dev/null
@@ -1,61 +0,0 @@
-function init() {
- initClock();
- loadLists();
-}
-
-function initClock() {
- var today = new Date();
- var h = today.getHours();
- var m = today.getMinutes();
- var s = today.getSeconds();
- var dd = today.getDate();
- var mm = today.getMonth() + 1; //January is 0!
- var yyyy = today.getFullYear();
-
- if (dd < 10)
- dd = '0' + dd
- if (mm < 10)
- mm = '0' + mm
- if (h < 10)
- h = '0' + h
- if (m < 10)
- m = '0' + m
- if (s < 10)
- s = '0' + s
-
- $(".time-hours").html(h);
- $(".time-minutes").html(m);
- $(".time-seconds").html(s);
- $(".date-day").html(dd);
- $(".date-month").html(mm);
- $(".date-year").html(yyyy);
-
- if (h < 12) {
- $(".greetings-title").html("Good Morning");
- } else if (h >= 12 && h < 19) {
- $(".greetings-title").html("Good Afternoon");
- } else {
- $(".greetings-title").html("Good Evening");
- }
-
- var t = setTimeout(initClock, 500);
-}
-
-function loadLists() {
- var into = $('#result');
-
- function fileRetrieved(contents) {
- var lines = contents.split('\n');
- for (var i = 0; i < lines.length; i += 1) {
- createListElement(lines[i]);
- }
- }
-
- function createListElement(text) {
- var el = $('<li></li>').html(text);
- el.appendTo(into);
- }
-
- var text = $('#text').html();
- fileRetrieved(text);
-} \ No newline at end of file