Skip to content

Commit 95e18e8

Browse files
committed
improve export
1 parent 8209474 commit 95e18e8

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

programs.html

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,11 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
364364
}
365365

366366
// --- Toggle PARI export display ---
367-
async function togglePariExport(sequenceId, button, programContainer, programCode) {
367+
async function togglePariExport(sequenceId, button, otherButton, programContainer, programCode) {
368368
const pariId = `loda-pari-${sequenceId}`;
369+
const leanId = `loda-lean-${sequenceId}`;
369370
let pariContainer = document.getElementById(pariId);
371+
let leanContainer = document.getElementById(leanId);
370372

371373
if (pariContainer) {
372374
// If PARI is already shown, hide it
@@ -375,6 +377,12 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
375377
return;
376378
}
377379

380+
// Close LEAN export if it's open
381+
if (leanContainer) {
382+
leanContainer.remove();
383+
otherButton.textContent = BUTTON_STATES.LEAN_COLLAPSED;
384+
}
385+
378386
// Show loading state
379387
button.textContent = BUTTON_STATES.PARI_LOADING;
380388
button.disabled = true;
@@ -403,9 +411,11 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
403411
}
404412

405413
// --- Toggle LEAN export display ---
406-
async function toggleLeanExport(sequenceId, button, programContainer, programCode) {
414+
async function toggleLeanExport(sequenceId, button, otherButton, programContainer, programCode) {
407415
const leanId = `loda-lean-${sequenceId}`;
416+
const pariId = `loda-pari-${sequenceId}`;
408417
let leanContainer = document.getElementById(leanId);
418+
let pariContainer = document.getElementById(pariId);
409419

410420
if (leanContainer) {
411421
// If LEAN is already shown, hide it
@@ -414,6 +424,12 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
414424
return;
415425
}
416426

427+
// Close PARI export if it's open
428+
if (pariContainer) {
429+
pariContainer.remove();
430+
otherButton.textContent = BUTTON_STATES.PARI_COLLAPSED;
431+
}
432+
417433
// Show loading state
418434
button.textContent = BUTTON_STATES.LEAN_LOADING;
419435
button.disabled = true;
@@ -529,14 +545,16 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
529545
const pariButton = document.createElement('button');
530546
pariButton.className = CSS_CLASSES.LODA_BUTTON;
531547
pariButton.textContent = BUTTON_STATES.PARI_COLLAPSED;
532-
pariButton.onclick = () => togglePariExport(sequenceId, pariButton, programContainer, code);
533548
buttonsContainer.appendChild(pariButton);
534549

535550
const leanButton = document.createElement('button');
536551
leanButton.className = CSS_CLASSES.LODA_BUTTON;
537552
leanButton.textContent = BUTTON_STATES.LEAN_COLLAPSED;
538-
leanButton.onclick = () => toggleLeanExport(sequenceId, leanButton, programContainer, code);
539553
buttonsContainer.appendChild(leanButton);
554+
555+
// Set up onclick handlers with cross-references
556+
pariButton.onclick = () => togglePariExport(sequenceId, pariButton, leanButton, programContainer, code);
557+
leanButton.onclick = () => toggleLeanExport(sequenceId, leanButton, pariButton, programContainer, code);
540558
}
541559

542560
programContainer.appendChild(codeContainer);

0 commit comments

Comments
 (0)