66
77const 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
1313const KAL_ENGINE_OK = 0
1414const 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
226251function 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) {
333359function 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>
0 commit comments