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

github.com/vickylaixy/hugo-theme-introduction.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyGiHu <74786828+MyGiHu@users.noreply.github.com>2020-12-04 18:49:32 +0300
committerGitHub <noreply@github.com>2020-12-04 18:49:32 +0300
commit6925c0248cf70674576d42d173ff33b00a3d522a (patch)
treee3aaa7f60c15f717e7cce2eda7258c682cae22a2 /layouts
parent293ab665ca52f3c7d8d3273ca79fa7949493b1ea (diff)
Replacing Moment.js with native JavaScript (#266)
* fix-262 * Replacing Moment.js with native JavaScript
Diffstat (limited to 'layouts')
-rw-r--r--layouts/index.html17
1 files changed, 10 insertions, 7 deletions
diff --git a/layouts/index.html b/layouts/index.html
index fd1787c..d9243c3 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -106,7 +106,7 @@
{{ .Content }}
</div>
{{ if .Site.Params.home.localTime }}
- <p>{{ i18n "index_currentTime" . }} <span id="time" data-time-zone="{{ .Site.Params.home.timeZone }}" data-time-format="{{ .Site.Params.home.timeFormat }}"></span>.</p>
+ <p>{{ i18n "index_currentTime" . }} <span id="time"></span>.</p>
{{ end }}
{{ with .Site.Params.email }}
<h3 class="subtitle is-3 has-text-centered top-pad">
@@ -132,12 +132,15 @@
{{ partial "js/owlCarousel.html" . }}
{{ if .Site.Params.home.localTime }}
- {{ $momentjs := resources.Get "vendor/momentjs/moment.min.js" }}
- {{ $momentTimezone := resources.Get "vendor/momentjs/moment-timezone.min.js" }}
- {{ $momentTimezoneWithData := resources.Get "vendor/momentjs/moment-timezone-with-data-2012-2022.min.js" }}
- {{ $initMomentjs := resources.Get "js/initMoment.js" }}
- {{ $bundleMoment := slice $momentjs $momentTimezone $momentTimezoneWithData $initMomentjs | resources.Concat "js/bundleMoment.js" | fingerprint }}
- <script src="{{ $bundleMoment.Permalink }}" integrity="{{ $bundleMoment.Data.Integrity }}"></script>
+ <script>
+ function update_localtime() {
+ const time = new Date().toLocaleTimeString('{{ .Site.Params.home.timeFormat }}', { timeZone: '{{ .Site.Params.home.timeZone }}', timeStyle: 'short' });
+ document.getElementById('time').innerHTML = time;
+ }
+ update_localtime();
+ // Updating every second to prevent seconds looking like stood still when timeStyle is ignored.
+ setInterval(update_localtime, 1000);
+ </script>
{{ end }}
</body>