sha
All checks were successful
Deploy to FTP / deploy (push) Successful in 5s

This commit is contained in:
Sebastian Molenda
2026-05-05 20:43:06 +02:00
parent ae9f965e03
commit 77d5af8fa0
5 changed files with 45 additions and 51 deletions

View File

@@ -26,5 +26,5 @@ jobs:
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASS }}
local-dir: ./
server-dir: /public_html/
server-dir: /

67
app.js
View File

@@ -450,15 +450,15 @@ historyToggle.addEventListener('click', ()=>{
// historyBtn.addEventListener('click', toggleHistory)
// if (historyToggle) historyToggle.addEventListener('click', toggleHistory)
historyBack.addEventListener('click', ()=>{
historyScreen.classList.add('hidden')
menuScreen.classList.remove('hidden')
})
// historyBack.addEventListener('click', ()=>{
// historyScreen.classList.add('hidden')
// menuScreen.classList.remove('hidden')
// })
clearHistoryBtn.addEventListener('click', ()=>{
try{ localStorage.removeItem('matma:history') }catch(e){}
renderHistory()
})
// clearHistoryBtn.addEventListener('click', ()=>{
// try{ localStorage.removeItem('matma:history') }catch(e){}
// renderHistory()
// })
// keyboard support: allow Enter/Backspace/0-9
window.addEventListener('keydown', (e)=>{
@@ -479,29 +479,34 @@ 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(){
// Load commit SHA into footer (robust: prefers window.COMMIT_SHA, then meta tag, then fetch plain file)
document.addEventListener('DOMContentLoaded', async () => {
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()
// 1) prefer a global injected by CI: window.COMMIT_SHA
let sha = (window.COMMIT_SHA || '').toString().trim()
// 2) fallback to meta tag if CI injects that instead
if (!sha) {
const meta = document.querySelector('meta[name="commit-sha"]')
if (meta && meta.content) sha = meta.content.trim()
}
// 3) finally try to fetch the external file (works if it's plain text or a tiny JS file)
if (!sha) {
try {
const res = await fetch('/version.js', { cache: 'no-cache' })
if (res.ok) {
const txt = (await res.text()).trim()
// try to extract a quoted/assigned sha like: window.COMMIT_SHA = "abc..." or COMMIT_SHA: "..."
const m = txt.match(/COMMIT_SHA\s*(?:=|:)\s*["']?([0-9a-fA-F]{7,40})["']?/)
if (m && m[1]) sha = m[1]
else {
const firstLine = txt.split(/\r?\n/).find(l => l.trim().length>0)
if (firstLine) sha = firstLine.trim()
}
}
} catch (e) {
// ignore failures silently
}
}
if (sha) el.textContent = sha.slice(0,8)
})
.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'
})
})()

View File

@@ -140,24 +140,11 @@
</div>
</section>
</main>
<main class="screen hidden" id="history-screen">
<header class="play-header">
<div class="left">
<button id="history-back" class="small">← Menu</button>
</div>
<div class="center"><strong>Historia sesji</strong></div>
<div class="right">
<button id="clear-history" class="small">Wyczyść</button>
</div>
</header>
<section class="panel history-list" id="history-list">
<!-- wpisy historii -->
</section>
</main>
</div>
<footer class="app-footer">Commit: <span id="commit-sha">(loading)</span></footer>
<script src="version.js" defer></script>
<script src="app.js"></script>
</body>
</html>

View File

@@ -7,9 +7,10 @@
*{box-sizing:border-box}
html,body{height:100%}
.app-wrap{width:100%;max-width:420px}
.app-wrap{width:100%;max-width:420px}
body{
margin:0; font-family:Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
background:var(--bg); color:#111; display:flex; align-items:center; justify-content:center; padding:16px;
background:var(--bg); color:#111; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; min-height:100vh; padding:16px;
}
.screen{width:100%;background:var(--card);border-radius:16px;box-shadow:0 6px 22px rgba(16,24,40,0.08);position:relative;overflow:auto;-webkit-overflow-scrolling:touch}
.screen.hidden{display:none}
@@ -62,7 +63,7 @@ body{
.summary h2{margin:6px 0}
.summary p{font-size:18px}
.app-footer{font-size:12px;color:var(--muted);text-align:center;padding:10px 0}
.app-footer{font-size:12px;color:var(--muted);text-align:center;padding:10px 0;width:100%;max-width:420px}
@media (orientation:portrait){
.screen{max-height:94vh}

1
version.js Normal file
View File

@@ -0,0 +1 @@
const COMMIT_SHA = '-';