mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-11-08 14:49:43 +00:00
Add timeRefresh
for periodic localtime update and allow for multilingual time format (#177)
This commit is contained in:
parent
8b1684b6c2
commit
5205eeac73
2 changed files with 11 additions and 4 deletions
|
@ -1,4 +1,11 @@
|
|||
$(document).ready(function() {
|
||||
var time = moment().tz("{{ .Site.Params.home.timeZone }}").format("{{ .Site.Params.home.timeFormat }}");
|
||||
$("#time").html(time);
|
||||
const tnode = $("#time")
|
||||
const update_localtime = function(){
|
||||
var time = moment()
|
||||
.tz(tnode.attr("data-time-zone"))
|
||||
.format(tnode.attr("data-time-format"));
|
||||
tnode.html(time);
|
||||
}
|
||||
update_localtime();
|
||||
setInterval(update_localtime, 1000);
|
||||
})
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
{{ .Content }}
|
||||
</div>
|
||||
{{ if .Site.Params.home.localTime }}
|
||||
<p>{{ i18n "index_currentTime" . }} <span id="time"></span>.</p>
|
||||
<p>{{ i18n "index_currentTime" . }} <span id="time" data-time-zone="{{ .Site.Params.home.timeZone }}" data-time-format="{{ .Site.Params.home.timeFormat }}"></span>.</p>
|
||||
{{ end }}
|
||||
{{ with .Site.Params.email }}
|
||||
<h3 class="subtitle is-3 has-text-centered top-pad">
|
||||
|
@ -135,7 +135,7 @@
|
|||
{{ $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" | resources.ExecuteAsTemplate "js/initMoment.tmp.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>
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue