Skip to content

Commit ef72021

Browse files
authored
Fix copy buttons not removed when collapsing PARI/LEAN containers (#23)
1 parent 54b36c1 commit ef72021

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

programs.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,20 +396,30 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
396396
// --- Toggle PARI export display ---
397397
async function togglePariExport(sequenceId, button, otherButton, programContainer, programCode) {
398398
const pariId = `loda-pari-${sequenceId}`;
399+
const pariButtonsId = `loda-pari-buttons-${sequenceId}`;
399400
const leanId = `loda-lean-${sequenceId}`;
401+
const leanButtonsId = `loda-lean-buttons-${sequenceId}`;
400402
let pariContainer = document.getElementById(pariId);
403+
let pariButtonsContainer = document.getElementById(pariButtonsId);
401404
let leanContainer = document.getElementById(leanId);
405+
let leanButtonsContainer = document.getElementById(leanButtonsId);
402406

403407
if (pariContainer) {
404408
// If PARI is already shown, hide it
405409
pariContainer.remove();
410+
if (pariButtonsContainer) {
411+
pariButtonsContainer.remove();
412+
}
406413
button.textContent = BUTTON_STATES.PARI_COLLAPSED;
407414
return;
408415
}
409416

410417
// Close LEAN export if it's open
411418
if (leanContainer) {
412419
leanContainer.remove();
420+
if (leanButtonsContainer) {
421+
leanButtonsContainer.remove();
422+
}
413423
otherButton.textContent = BUTTON_STATES.LEAN_COLLAPSED;
414424
}
415425

@@ -429,6 +439,7 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
429439

430440
// Create buttons container for PARI
431441
const pariButtonsContainer = document.createElement('div');
442+
pariButtonsContainer.id = pariButtonsId;
432443
pariButtonsContainer.className = CSS_CLASSES.PROGRAM_BUTTONS;
433444

434445
const pariCopyButton = document.createElement('button');
@@ -454,20 +465,30 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
454465
// --- Toggle LEAN export display ---
455466
async function toggleLeanExport(sequenceId, button, otherButton, programContainer, programCode) {
456467
const leanId = `loda-lean-${sequenceId}`;
468+
const leanButtonsId = `loda-lean-buttons-${sequenceId}`;
457469
const pariId = `loda-pari-${sequenceId}`;
470+
const pariButtonsId = `loda-pari-buttons-${sequenceId}`;
458471
let leanContainer = document.getElementById(leanId);
472+
let leanButtonsContainer = document.getElementById(leanButtonsId);
459473
let pariContainer = document.getElementById(pariId);
474+
let pariButtonsContainer = document.getElementById(pariButtonsId);
460475

461476
if (leanContainer) {
462477
// If LEAN is already shown, hide it
463478
leanContainer.remove();
479+
if (leanButtonsContainer) {
480+
leanButtonsContainer.remove();
481+
}
464482
button.textContent = BUTTON_STATES.LEAN_COLLAPSED;
465483
return;
466484
}
467485

468486
// Close PARI export if it's open
469487
if (pariContainer) {
470488
pariContainer.remove();
489+
if (pariButtonsContainer) {
490+
pariButtonsContainer.remove();
491+
}
471492
otherButton.textContent = BUTTON_STATES.PARI_COLLAPSED;
472493
}
473494

@@ -487,6 +508,7 @@ <h1 class="post-title">Integer Sequences and LODA Programs</h1>
487508

488509
// Create buttons container for LEAN
489510
const leanButtonsContainer = document.createElement('div');
511+
leanButtonsContainer.id = leanButtonsId;
490512
leanButtonsContainer.className = CSS_CLASSES.PROGRAM_BUTTONS;
491513

492514
const leanCopyButton = document.createElement('button');

0 commit comments

Comments
 (0)