Skip to content

Commit

Permalink
Add button to hide fully-solved equations (#546) (#560)
Browse files Browse the repository at this point in the history
And fix some minor bugs with the 'treat conjectures as unknown' buttons
that I found along the way.

Closes #546
  • Loading branch information
vlad902 authored Oct 13, 2024
1 parent 9179075 commit 1ecff6a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
17 changes: 10 additions & 7 deletions home_page/implications/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ <h2>Oops! There's an issue with your equation</h2>


<div class="checkbox-container">
<label>
<input checked="checked" type="checkbox" id="showEquivalences"> Hide equivalent equations
</label>
<label>
<input type="checkbox" checked="checked" id="showEquivalences"> Hide equivalent equations
</label>
<label>
<input type="checkbox" checked="checked" id="treatConjectedAsUnknownList"> Treat conjectures as unknown
</label>
<label>
<input type="checkbox" id="hideFullySolved"> Hide fully-solved equations
</label>
</div>
<div id="equationList" class="equation-list">
<div class="equation-item header">
Expand All @@ -150,14 +153,14 @@ <h2 id="selectedEquation"></h2>
<div id="equationCommentary"></div>
<h3><span id="selectedEquationDual"></span> <span id="selectedEquationGraphitiLinks"></span> <span id="smallestMagmaLink"></span></h3>
<div class="checkbox-container">
<label>
<input checked="checked" type="checkbox" id="showEquivalences2"> Hide equivalent equations
</label>
<label>
<input type="checkbox" checked="checked" id="showEquivalences2"> Hide equivalent equations
</label>
<label>
<input type="checkbox" id="showOnlyExplicitProofs"> Show only explicit proofs
</label>
<label>
<input type="checkbox" id="treatConjectedAsUnknownDetail"> Treat conjectures as unknown
<input type="checkbox" checked="checked" id="treatConjectedAsUnknownDetail"> Treat conjectures as unknown
</label>

</div>
Expand Down
29 changes: 22 additions & 7 deletions home_page/implications/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ const backButton = document.getElementById('backButton');
const showOnlyExplicitProofs = document.getElementById('showOnlyExplicitProofs');
const treatConjectedAsUnknownList = document.getElementById('treatConjectedAsUnknownList');
const treatConjectedAsUnknownDetail = document.getElementById('treatConjectedAsUnknownDetail');
const hideFullySolvedCheckbox = document.getElementById('hideFullySolved');

let currentEquationIndex = null;

let showEquivalences = false;
let filteredCachedItems = [];

let cachedItems = [];
let cachedItemElements = [];

function showPage(pageId) {
document.querySelectorAll('.page').forEach(page => page.classList.remove('active'));
document.getElementById(pageId).classList.add('active');
}

let showEquivalences = false;
let filteredCachedItems = [];

function hideVisibility(elementId) {
const element = document.getElementById(elementId);
element.style.display = "none";
Expand All @@ -88,6 +92,7 @@ function showVisibility(elementId) {
}

function filterEquations() {
// First filter by whether to collapse by equivalence class
if (showEquivalences) {
filteredCachedItems = cachedItems;
} else {
Expand All @@ -101,6 +106,13 @@ function filterEquations() {
return false;
});
}

if (hideFullySolvedCheckbox.checked) {
// Further filter by whether they are fully solved (e.g. they have any unknowns/conjectures remaining.)
filteredCachedItems = filteredCachedItems.filter(item => {
return item.stats.unknown != 0 || item.stats.unknownBy != 0
});
}
}


Expand Down Expand Up @@ -152,9 +164,6 @@ function calculateStats(index, treatConjecturedAsUnknown = false) {
return stats;
}

let cachedItems = [];
let cachedItemElements = [];


function initializeEquationList() {
const treatConjecturedAsUnknown = treatConjectedAsUnknownList.checked;
Expand Down Expand Up @@ -438,17 +447,23 @@ showOnlyExplicitProofs.addEventListener('change', () => {
});

treatConjectedAsUnknownDetail.addEventListener('change', () => {
treatConjectedAsUnknownList.checked = treatConjectedAsUnknownDetail.checked;
updateEquationListStats();
if (currentEquationIndex !== null) {
renderImplications(currentEquationIndex);
}
});

// Modify the event listener for the checkbox
treatConjectedAsUnknownList.addEventListener('change', () => {
treatConjectedAsUnknownDetail.checked = treatConjectedAsUnknownList.checked;
updateEquationListStats();
renderEquationList();
});

hideFullySolvedCheckbox.addEventListener('change', () => {
filterEquations();
renderEquationList();
});

let currentURL = window.location.href;
if (currentURL.indexOf('?') > -1) {
Expand Down

0 comments on commit 1ecff6a

Please sign in to comment.