Before Big refactor

This commit is contained in:
2026-05-05 15:43:42 -04:00
parent 93f0fa7c09
commit bc151473dc
9 changed files with 83 additions and 84 deletions

Binary file not shown.

View File

@@ -24,6 +24,8 @@ def move_all_to_one_side(equation):
step["after"] = new_expr step["after"] = new_expr
step["step"] = f"Subtract {sstr(clean(right_expr))} from both sides" step["step"] = f"Subtract {sstr(clean(right_expr))} from both sides"
step["left"] = f"-{sstr(clean(right_expr))}"
step["right"] = f"-{sstr(clean(right_expr))}"
step["rule"] = "Subtraction Property of Equality" step["rule"] = "Subtraction Property of Equality"
return step return step
@@ -43,6 +45,8 @@ def add_both_sides(equation, value):
step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}" step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}"
step["step"] = f"Add {sstr(value)} to both sides" step["step"] = f"Add {sstr(value)} to both sides"
step["left"] = f"+{sstr(value)}"
step["right"] = f"+{sstr(value)}"
step["rule"] = "Addition Property of Equality" step["rule"] = "Addition Property of Equality"
return step return step
@@ -62,6 +66,8 @@ def subtract_both_sides(equation, value):
step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}" step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}"
step["step"] = f"Subtract {sstr(value)} from both sides" step["step"] = f"Subtract {sstr(value)} from both sides"
step["left"] = f"-{sstr(value)}"
step["right"] = f"-{sstr(value)}"
step["rule"] = "Subtraction Property of Equality" step["rule"] = "Subtraction Property of Equality"
return step return step
@@ -81,6 +87,8 @@ def divide_both_sides(equation, value):
step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}" step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}"
step["step"] = f"Divide both sides by {sstr(value)}" step["step"] = f"Divide both sides by {sstr(value)}"
step["left"] = f"÷{sstr(value)}"
step["right] = f"÷{sstr(value)}"
step["rule"] = "Division Property of Equality" step["rule"] = "Division Property of Equality"
return step return step
@@ -119,6 +127,8 @@ def multiply_both_sides(equation, value):
step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}" step["after"] = f"{sstr(new_left_expr)} = {sstr(new_right_expr)}"
step["step"] = f"Multiply both sides by {sstr(value)}" step["step"] = f"Multiply both sides by {sstr(value)}"
step["left"] = f"×{sstr(value)}"
step["right"] = f"×{sstr(value)}"
step["rule"] = "Multiplication Property of Equality" step["rule"] = "Multiplication Property of Equality"
return step return step

View File

@@ -68,7 +68,7 @@ def generate_problem_message():
return problem return problem
def get_time_for_problem(problem): def get_time_for_problem(problem):
return 30 return 10
def main(): def main():
problem_solved = False problem_solved = False

View File

@@ -10,20 +10,20 @@
<canvas id="waveCanvas"></canvas> <canvas id="waveCanvas"></canvas>
<canvas id="particleCanvas"></canvas> <canvas id="particleCanvas"></canvas>
<!-- Timer -->
<div id="timer"> <div id="timer">
<svg width="60" height="60"> <svg width="72" height="72">
<circle <circle
id="timer-bg" id="timer-bg"
cx="30" cx="36"
cy="30" cy="36"
r="25" r="30"
/> />
<circle <circle
id="timer-progress" id="timer-progress"
cx="30" cx="36"
cy="30" cy="36"
r="25" r="30"
/> />
</svg> </svg>
<div id="timer-text"></div> <div id="timer-text"></div>
@@ -31,8 +31,8 @@
<div id="problem"></div> <div id="problem"></div>
<div id="equation-main"></div> <div id="equation-main"></div>
<div id="equation-next"></div>
<div id="explanation"></div> <div id="explanation"></div>
<div id="equation-next"></div>
<script src="scripts/timer.js"></script> <script src="scripts/timer.js"></script>
<script src="scripts/background.js"></script> <script src="scripts/background.js"></script>

View File

@@ -11,14 +11,13 @@ function showProblem() {
problemEl.innerHTML = `\\(${formatted}\\)`; problemEl.innerHTML = `\\(${formatted}\\)`;
// Initialize the main equation (this is what evolves) // Initialize the main equation (this is what evolves)
mainEl.innerHTML = `\\(${formatted}\\)`; mainEl.innerHTML = "";
// Clear animation layer + explanation // Clear animation layer + explanation
nextEl.innerHTML = ""; nextEl.innerHTML = "";
nextEl.style.opacity = 0; nextEl.style.opacity = 0;
expEl.innerHTML = ""; expEl.innerHTML = "";
expEl.style.opacity = 0;
MathJax.typesetPromise([problemEl, mainEl]); MathJax.typesetPromise([problemEl, mainEl]);
} }
@@ -35,41 +34,49 @@ function showStep() {
const step = problemData.steps[stepIndex]; const step = problemData.steps[stepIndex];
// 1. Show explanation // 1. Start with the equation
expEl.innerHTML = step.step; mainEl.innerHTML = `\\(${formatMath(step.before)}\\)`;
expEl.style.opacity = 1; MathJax.typesetPromise([mainEl]);
mainEl.style.opacity = 1;
// 2. Prepare next equation
nextEl.innerHTML = `\\(${formatMath(step.after)}\\)`;
nextEl.classList.remove("fade-in", "move-up");
nextEl.style.opacity = 0; nextEl.style.opacity = 0;
MathJax.typesetPromise([nextEl]);
setTimeout(() => { setTimeout(() => {
// 3. Fade in next equation (below) // 2. Show explanation
nextEl.style.opacity = 1; expEl.innerHTML = step.step;
nextEl.classList.add("move-up"); expEl.style.opacity = 1;
// 4. Fade out old + explanation // 3. Prepare next equation
mainEl.classList.add("fade-out"); nextEl.innerHTML = `\\(${formatMath(step.after)}\\)`;
expEl.style.opacity = 0; nextEl.classList.remove("move-up");
nextEl.style.opacity = 0;
MathJax.typesetPromise([nextEl]);
setTimeout(() => { setTimeout(() => {
// 5. Promote next → main // 3. Fade in next equation (below)
mainEl.innerHTML = nextEl.innerHTML; nextEl.style.opacity = 1;
MathJax.typesetPromise([mainEl]);
// reset styles setTimeout(() => {
mainEl.classList.remove("fade-out"); // 4. Fade out old and explanation
nextEl.style.opacity = 0; mainEl.style.opacity = 0;
expEl.style.opacity = 0;
stepIndex++; setTimeout(() => {
setTimeout(showStep, 1500); // 5. Move up next equation
}, 500); nextEl.classList.add("move-up");
}, 1000); // time to read explanation // 5. Promote next → main
mainEl.innerHTML = nextEl.innerHTML;
MathJax.typesetPromise([mainEl]);
stepIndex++;
setTimeout(showStep, 1500);
}, 1500); // Move up New Equation
}, 3000); // Fade Out Explanation and old
}, 1500); // Fade in Next Equation
}, 1500); // Show Explanation
} }
function startSteps() { function startSteps() {

View File

@@ -1,5 +1,5 @@
// Copyright John Salguero All rights Reserved // Copyright John Salguero All rights Reserved
const radius = 25; const radius = 30;
const circumference = 2 * Math.PI * radius; const circumference = 2 * Math.PI * radius;
const circle = document.getElementById("timer-progress"); const circle = document.getElementById("timer-progress");
@@ -15,6 +15,9 @@ let timerInterval = null;
function startTimer(duration) { function startTimer(duration) {
let timeLeft = duration; let timeLeft = duration;
const textEl = document.getElementById("timer-text"); const textEl = document.getElementById("timer-text");
textEl.textContent = timeLeft;
circle.style.stroke = startColor;
circle.style.strokeDashoffset = 0;
// clear previous timer // clear previous timer
if (timerInterval) { if (timerInterval) {
@@ -28,17 +31,18 @@ function startTimer(duration) {
textEl.textContent = timeLeft; textEl.textContent = timeLeft;
// 🔥 recompute progress EVERY tick // 🔥 recompute progress EVERY tick
const progress = (duration - timeLeft) / duration; const progress = (duration - (timeLeft - 1)) / duration;
const p = Math.max(0, Math.min(1, progress));
// update circle // update circle
const offset = circumference * progress; const offset = circumference * p;
circle.style.strokeDashoffset = -offset; circle.style.strokeDashoffset = -offset;
// color interpolation // color interpolation
if (progress < 0.5) { if (progress < 0.5) {
circle.style.stroke = lerpColor(startColor, middleColor, progress * 2); circle.style.stroke = lerpColor(startColor, middleColor, p * 2);
} else { } else {
circle.style.stroke = lerpColor(middleColor, endColor, (progress - 0.5) * 2); circle.style.stroke = lerpColor(middleColor, endColor, (p - 0.5) * 2);
} }
// low-time pulse // low-time pulse

View File

@@ -22,8 +22,9 @@ socket.onmessage = (event) => {
stepIndex = 0; stepIndex = 0;
showProblem(); showProblem();
initial_duration = msg.time;
startTimer(msg.time); startTimer(msg.time);
// Debug show problem timing
//startTimer(1);
} }
}; };

View File

@@ -16,8 +16,8 @@ html, body {
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 20px; right: 20px;
width: 60px; width: 72px;
height: 60px; height: 72px;
z-index: 10; z-index: 10;
} }
@@ -59,38 +59,25 @@ html, body {
text-align: center; text-align: center;
} }
#equation-main, #equation-next { #equation-main, #explanation, #equation-next{
position: absolute; position: absolute;
top: 30%; top: 31.5%;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
font-size: 48px; font-size: 48px;
transition: all 0.5s ease; transition: all 1.5s ease;
}
#equation-next {
opacity: 0;
transform: translate(-50%, 40px); /* start slightly below */
} }
#explanation { #explanation {
position: absolute; transform: translate(-50%, 80px);
top: 45%;
left: 50%;
transform: translateX(-50%);
font-size: 24px; font-size: 24px;
opacity: 0.8; opacity: 0.8;
} }
#steps { #equation-next {
position: absolute; font-size: 48px;
top: 27%; /* below the problem */ transform: translate(-50%, 160px); /* start slightly below */
left: 50%; opacity: 0;
transform: translateX(-50%);
width: 800px;
text-align: center;
font-size: 28px;
} }
#waveCanvas { #waveCanvas {
@@ -115,17 +102,7 @@ html, body {
animation: pulse 1s infinite; animation: pulse 1s infinite;
} }
.fade-out { #equation-next.move-up {
opacity: 0;
transform: translateX(-50%) scale(0.95);
}
.fade-in {
opacity: 1;
transform: translateX(-50%) scale(1);
}
.move-up {
transform: translate(-50%, 0); transform: translate(-50%, 0);
} }