aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-03-01 19:14:59 -0800
committerclarkzjw <[email protected]>2023-03-01 20:21:47 -0800
commit375c0d2544b20124a8cf497819006e01cd217225 (patch)
tree8984bf464561722f33dd15f60a7872ff1aa71912 /assets/site.js
parentf87fef5388ca419f79c4750810e302cedfc310f5 (diff)
downloadphoto-375c0d2544b20124a8cf497819006e01cd217225.tar.gz
host photos.json on cloudflare r2
Diffstat (limited to 'assets/site.js')
-rw-r--r--assets/site.js32
1 files changed, 0 insertions, 32 deletions
diff --git a/assets/site.js b/assets/site.js
deleted file mode 100644
index 4e72511..0000000
--- a/assets/site.js
+++ /dev/null
@@ -1,32 +0,0 @@
1function settime() {
2 const timestamp = document.querySelector('[data-timestamp-text]')
3 if (!timestamp || !('Intl' in window)) return
4
5 const options = {
6 timeZone: "Asia/Taipei",
7 timeStyle: "short",
8 hour12: false
9 }
10
11 // https://gist.github.com/muan/e7414b6241f088090acd916ed965540e
12 let time = new Intl.DateTimeFormat(navigator.language || "zh-TW", options).format(new Date())
13
14 // https://bugs.chromium.org/p/chromium/issues/detail?id=1262801
15 if (time.match(/^24:/)) time = time.replace('24:', '00:')
16
17 // Setting interpolated string instead of just the time because
18 // if there's no JS there should be no mentions of current time
19 const text = timestamp.getAttribute('data-timestamp-text').replace('{time}', time)
20 timestamp.innerHTML = text.replace(':', '<span class="timestamp-colon" data-colon>:</span>')
21
22 const now = new Date()
23 const sec = now.getSeconds()
24 const secondIsEven = sec % 2 === 0
25 const colon = document.querySelector('[data-colon]')
26 if (colon) colon.style.animationDelay = `${(secondIsEven ? 0 : 1000) - now.getMilliseconds()}ms`
27
28 const delay = 60000 - ((sec * 1000) + now.getMilliseconds())
29 setTimeout(settime, delay)
30}
31
32settime()
Powered by cgit v1.2.3 (git 2.41.0)