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 }} username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASS }} password: ${{ secrets.FTP_PASS }}
local-dir: ./ local-dir: ./
server-dir: /public_html/ server-dir: /

69
app.js
View File

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

View File

@@ -140,24 +140,11 @@
</div> </div>
</section> </section>
</main> </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> </div>
<footer class="app-footer">Commit: <span id="commit-sha">(loading)</span></footer> <footer class="app-footer">Commit: <span id="commit-sha">(loading)</span></footer>
<script src="version.js" defer></script>
<script src="app.js"></script> <script src="app.js"></script>
</body> </body>
</html> </html>

View File

@@ -7,9 +7,10 @@
*{box-sizing:border-box} *{box-sizing:border-box}
html,body{height:100%} html,body{height:100%}
.app-wrap{width:100%;max-width:420px} .app-wrap{width:100%;max-width:420px}
.app-wrap{width:100%;max-width:420px}
body{ body{
margin:0; font-family:Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; 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{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} .screen.hidden{display:none}
@@ -62,7 +63,7 @@ body{
.summary h2{margin:6px 0} .summary h2{margin:6px 0}
.summary p{font-size:18px} .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){ @media (orientation:portrait){
.screen{max-height:94vh} .screen{max-height:94vh}

1
version.js Normal file
View File

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