Skip to content

Commit 98e05fc

Browse files
committed
feat: update calendar demo
1 parent 2fee866 commit 98e05fc

2 files changed

Lines changed: 44 additions & 27 deletions

File tree

app/liturgical-calendar/app.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
const APP_ROOT = '/app/liturgical-calendar/'
88

9-
const WASM_URL = `${APP_ROOT}liturgical_calendar_wasm.wasm?v=15`
10-
const KALD_URL = `${APP_ROOT}romanus_universale.kald?v=15`
11-
const LITS_URL = `${APP_ROOT}romanus_universale_la.lits?v=15`
9+
const WASM_URL = `${APP_ROOT}liturgical_calendar_wasm.wasm?v=16`
10+
const KALD_URL = `${APP_ROOT}romanus_universale.kald?v=16`
11+
const LITS_URL = `${APP_ROOT}romanus_universale_la.lits?v=16`
1212

1313
const KAL_ENGINE_OK = 0
1414
const KAL_ERR_BUILD_ID_MISMATCH = -22
@@ -166,10 +166,16 @@ function renderYear(year, exports, memory) {
166166
document.title = `Calendarium ${year}`
167167
document.getElementById('h1').innerHTML = `Calendarium Romanum Generale <span>. pro ${year}</span>`
168168

169-
const tbody = document.getElementById('cal-body')
169+
// Isolation stricte des layouts
170+
const yearContent = document.getElementById('year-content')
171+
document.getElementById('day-content').hidden = true
172+
170173
const entryPtr = exports.kal_wasm_entry_ptr()
171174
const feastPtr = exports.kal_wasm_feast_ptr()
172175

176+
// Buffer de chaînes pour éviter les allocations d'éléments DOM individuels dans la boucle
177+
let rowsHtml = ''
178+
173179
for (let doy = 0; doy < 366; doy++) {
174180
if (exports.kal_wasm_read_day(year, doy) !== KAL_ENGINE_OK) continue
175181

@@ -190,7 +196,6 @@ function renderYear(year, exports, memory) {
190196
const { month, day } = doyToMonthDay(doy)
191197
const href = `${APP_ROOT}${year}/${zeroPad(month)}/${zeroPad(day)}`
192198

193-
// Correction ici : initialisation stricte sans 's' pour correspondre aux mutations suivantes
194199
let featsHtml = ''
195200

196201
if (exports.kal_wasm_get_label(year, doy) === 1) {
@@ -210,20 +215,43 @@ function renderYear(year, exports, memory) {
210215
}
211216
}
212217

213-
const tr = document.createElement('tr')
214-
tr.innerHTML = `
218+
rowsHtml += `<tr>
215219
<td class="doy"><a id="doy-${doy}" href="#doy-${doy}">${doy}</a></td>
216220
<td class="date"><a href="${href}">${zeroPad(day)}/${zeroPad(month)}</a></td>
217-
<td class="feasts">${featsHtml}</td>`
218-
tbody.appendChild(tr)
221+
<td class="feasts">${featsHtml}</td>
222+
</tr>`
219223
}
220224

221-
document.getElementById('cal-table').hidden = false
225+
// Flush unique du layout complet (Table + Structure + Navigation)
226+
yearContent.innerHTML = `
227+
<table class="table liturgical-calendar">
228+
<thead>
229+
<tr>
230+
<th>Doy</th>
231+
<th>Date</th>
232+
<th>Celebrationes</th>
233+
</tr>
234+
</thead>
235+
<tbody class="table">${rowsHtml}</tbody>
236+
</table>
237+
<hr>
238+
<nav class="flex gap">
239+
<a class="button" href="${APP_ROOT}${year - 10}">Année ${year - 10}</a>
240+
<a class="button" href="${APP_ROOT}${year - 1}">Année ${year - 1}</a>
241+
<a class="button" href="${APP_ROOT}${year}">Année ${year}</a>
242+
<a class="button" href="${APP_ROOT}${year + 1}">Année ${year + 1}</a>
243+
<a class="button" href="${APP_ROOT}${year + 10}">Année ${year + 10}</a>
244+
</nav>`
245+
246+
yearContent.hidden = false
222247
}
223248

224-
// ── Vue journalière ───────────────────────────────────────────────────────────
249+
// ── Vue journalière ─────────────────────────────────────────────────────────
225250

226251
function renderDay(year, month, day, exports, memory) {
252+
// Désactivation explicite du layout annuel
253+
document.getElementById('year-content').hidden = true
254+
227255
const doy = dateToDoy(year, month, day)
228256
document.title = `${zeroPad(day)}/${zeroPad(month)}/${year}`
229257
document.getElementById('h1').innerHTML = `Calendarium Romanum Generale <span>. ${formatDateLong(year, month, day)}</span>`
@@ -256,11 +284,9 @@ function renderDay(year, month, day, exports, memory) {
256284
}
257285

258286
const { precedence, color, nature, hasVigil } = decodeFeastFlags(feastFlags)
259-
// v6 : LiturgicalPeriod dans TimelineEntry.occurrenceFlags[4:2], plus dans FeastEntry.flags[10:8].
260287
const period = exports.kal_wasm_entry_liturgical_period()
261288
const { hasVesperaeI, hasVigilia } = decodeOccurrenceFlags(occFlags)
262289

263-
// Alignement structurel : Résolution sécurisée via l'ID de la célébration principale
264290
const res = resolveById(exports, memory, feastId, year)
265291
const label = res ? res.label : `Fête inconnue (0x${feastId.toString(16).toUpperCase()})`
266292
const annotation = res ? res.annotation : null
@@ -333,6 +359,8 @@ function renderDay(year, month, day, exports, memory) {
333359
function renderNotFound() {
334360
document.title = '404 — Page non trouvée'
335361
document.getElementById('h1').innerHTML = 'Calendarium Romanum Generale <span>. 404</span>'
362+
363+
document.getElementById('year-content').hidden = true
336364
const container = document.getElementById('day-content')
337365
container.innerHTML = `<section class="not-found">
338366
<p>La ressource demandée n'existe pas.</p>

app/liturgical-calendar/index.html

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png" />
1414
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg" color="#5bbad5" />
1515
<link rel="stylesheet" href="../../styles/main.css" media="screen" />
16-
<link rel="stylesheet" href="liturgical-calendar.css?v=15" media="screen" />
16+
<link rel="stylesheet" href="liturgical-calendar.css?v=16" media="screen" />
1717
<link rel="stylesheet" href="/styles/main.css" media="screen" />
1818
<link rel="stylesheet" href="/styles/print.css" media="print" />
1919
<link rel="preload" href="/fonts/notoSans-Regular.woff2" as="font" type="font/woff2" crossorigin />
@@ -27,18 +27,7 @@
2727
<h1 class="main-heading" id="h1">Calendarium Romanum Generale</h1>
2828
</header>
2929
<p id="status">Chargement…</p>
30-
<!-- Vue annuelle -->
31-
<table class="table liturgical-calendar" id="cal-table" hidden>
32-
<thead>
33-
<tr>
34-
<th>Doy</th>
35-
<th>Date</th>
36-
<th>Celebrationes</th>
37-
</tr>
38-
</thead>
39-
<tbody class="table" id="cal-body"></tbody>
40-
</table>
41-
<!-- Vue journalière -->
30+
<div id="year-content" hidden></div>
4231
<div id="day-content" hidden></div>
4332
</article>
4433
</main>
@@ -66,6 +55,6 @@ <h1 class="main-heading" id="h1">Calendarium Romanum Generale</h1>
6655
</div>
6756
</noscript>
6857
</div>
69-
<script type="module" src="/app/liturgical-calendar/app.js?v=15"></script>
58+
<script type="module" src="/app/liturgical-calendar/app.js?v=16"></script>
7059
</body>
7160
</html>

0 commit comments

Comments
 (0)