Custom sessions now draw their own bead ring matching the builder sequence

present.php extracts the ordered bead types (small/large/crucifix) from
custom session slides and passes them as CUSTOM_BEADS to the JS layer.

rosary.js reads CUSTOM_BEADS on init: if present, it draws exactly those
N beads (with their correct types) instead of the standard 60-bead ring.
The three hardcoded 60s and the fixed type Sets are now dynamic so any
sequence length works. Standard sessions are unchanged (CUSTOM_BEADS=null).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 21:34:24 -07:00
parent 3cc002a6da
commit 76a5061fba
2 changed files with 44 additions and 9 deletions
+14
View File
@@ -78,6 +78,19 @@ if ($session['mystery_set'] === 'all_sorrowful') {
// Build slide array
$slides = build_slides($session);
// For custom sessions, extract the ordered bead sequence so rosary.js
// can draw exactly those beads instead of the standard 60-bead ring.
$custom_beads = null;
if ($session['occasion'] === 'custom') {
$custom_beads = [];
foreach ($slides as $slide) {
if (!empty($slide['bead'])) {
$custom_beads[] = $slide['bead'];
}
}
if (empty($custom_beads)) $custom_beads = null;
}
// Prepare JSON for JavaScript (HTML-safe)
$slides_json = json_encode($slides, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
@@ -223,6 +236,7 @@ $has_audio = !empty($audio_manifest);
var BACK_URL = <?= json_encode($back_url) ?>;
var AUDIO_MANIFEST = <?= json_encode($audio_manifest, JSON_HEX_TAG | JSON_HEX_AMP) ?>;
var AUDIO_BASE_URL = <?= json_encode(UPLOADS_URL . 'audio/') ?>;
var CUSTOM_BEADS = <?= json_encode($custom_beads) ?>;
</script>
<script src="<?= BASE_URL ?>/assets/js/rosary.js?v=9"></script>