This commit is contained in:
27
app.js
27
app.js
@@ -478,3 +478,30 @@ window.addEventListener('keydown', (e)=>{
|
||||
|
||||
// small helper to set initial focus - mobile browsers will not open keyboard for divs
|
||||
document.addEventListener('touchstart', ()=>{}, {passive:true})
|
||||
|
||||
// load COMMIT_SHA from /version.js if present (no-cache fetch)
|
||||
;(function loadCommitSha(){
|
||||
const el = document.getElementById('commit-sha')
|
||||
if (!el) return
|
||||
// prefer a no-cache fetch
|
||||
fetch('/version.js', {cache: 'no-store'})
|
||||
.then(r => {
|
||||
if (!r.ok) throw new Error('no version.js')
|
||||
return r.text()
|
||||
})
|
||||
.then(text => {
|
||||
// naive parse: look for COMMIT_SHA = '...'; or window.COMMIT_SHA
|
||||
let m = text.match(/COMMIT_SHA\s*=\s*['\"]([0-9a-fA-F]+)['\"]/)
|
||||
if (m) return m[1]
|
||||
m = text.match(/window\.COMMIT_SHA\s*=\s*['\"]([0-9a-fA-F]+)['\"]/)
|
||||
if (m) return m[1]
|
||||
return null
|
||||
})
|
||||
.catch(()=>{
|
||||
// fallback to global
|
||||
return (window && window.COMMIT_SHA) ? window.COMMIT_SHA : null
|
||||
})
|
||||
.then(sha => {
|
||||
el.textContent = sha ? sha.slice(0,8) : 'unknown'
|
||||
})
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user