Skip to content

Commit 28cd48b

Browse files
authored
Merge pull request #1859 from prachishelke1312/feature-prediction-comparison
Add prediction comparison feature
2 parents ed677fb + 8efa7f3 commit 28cd48b

7 files changed

Lines changed: 171 additions & 10 deletions

File tree

login.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,33 @@ input::-webkit-reveal {
643643
.forgot-password {
644644
margin-bottom: 15px;
645645
}
646+
}
647+
/* Lamp Toggle */
648+
.lamp-container {
649+
text-align: center;
650+
margin-bottom: 20px;
651+
}
652+
653+
#lampToggle {
654+
padding: 10px 18px;
655+
border: none;
656+
border-radius: 10px;
657+
cursor: pointer;
658+
background: #ffd54f;
659+
font-size: 16px;
660+
font-weight: bold;
661+
}
662+
663+
/* Dark Overlay */
664+
#darkOverlay {
665+
position: absolute;
666+
inset: 0;
667+
background: rgba(0, 0, 0, 0.6);
668+
border-radius: 20px;
669+
z-index: 5;
670+
transition: opacity 0.4s ease;
671+
}
672+
673+
.hidden {
674+
display: none;
646675
}

login.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
</svg>
5151
</button>
5252
</div>
53+
<div class="lamp-container">
54+
<button id="lampToggle" type="button">💡 ON</button>
55+
</div>
5356

57+
<div id="darkOverlay" class="hidden"></div>
5458
<!-- Brand section -->
5559
<div class="brand-section">
5660
<a href="./index.html" class="brand-icon">

login.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,37 @@ function togglePassword() {
108108
eyeIcon.className = "fas fa-eye";
109109
}
110110
}
111+
// Lamp Toggle Feature
112+
document.addEventListener("DOMContentLoaded", () => {
113+
const lampToggle = document.getElementById("lampToggle");
114+
const darkOverlay = document.getElementById("darkOverlay");
115+
116+
if (!lampToggle || !darkOverlay) return;
117+
118+
const inputs = document.querySelectorAll(
119+
'input, button[type="submit"]'
120+
);
121+
122+
let lampOn = true;
123+
124+
lampToggle.addEventListener("click", () => {
125+
lampOn = !lampOn;
126+
127+
if (lampOn) {
128+
lampToggle.textContent = "💡 ON";
129+
darkOverlay.classList.add("hidden");
130+
131+
inputs.forEach(input => {
132+
input.disabled = false;
133+
});
134+
135+
} else {
136+
lampToggle.textContent = "💡 OFF";
137+
darkOverlay.classList.remove("hidden");
138+
139+
inputs.forEach(input => {
140+
input.disabled = true;
141+
});
142+
}
143+
});
144+
});

register.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,32 @@ input::-webkit-reveal {
547547
.form-container a:hover {
548548
color: #0f3d1e;
549549
}
550+
/* Lamp Toggle */
551+
.lamp-container {
552+
text-align: center;
553+
margin-bottom: 20px;
554+
}
555+
556+
#lampToggle {
557+
padding: 10px 18px;
558+
border: none;
559+
border-radius: 10px;
560+
cursor: pointer;
561+
background: #ffd54f;
562+
font-size: 16px;
563+
font-weight: bold;
564+
}
565+
566+
/* Dark Overlay */
567+
#darkOverlay {
568+
position: absolute;
569+
inset: 0;
570+
background: rgba(0, 0, 0, 0.6);
571+
border-radius: 20px;
572+
z-index: 5;
573+
transition: opacity 0.4s ease;
574+
}
575+
576+
.hidden {
577+
display: none;
578+
}

register.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,37 @@ document.addEventListener("keydown", function (e) {
262262

263263
document.addEventListener("DOMContentLoaded", updateProgress);
264264
document.getElementById("password").addEventListener("input", checkPasswordStrength);
265+
// Lamp Toggle Feature
266+
document.addEventListener("DOMContentLoaded", () => {
267+
const lampToggle = document.getElementById("lampToggle");
268+
const darkOverlay = document.getElementById("darkOverlay");
269+
270+
if (!lampToggle || !darkOverlay) return;
271+
272+
const formInputs = document.querySelectorAll(
273+
"#role, #fullname, #email, #password, #confirmPassword, #register-btn"
274+
);
275+
276+
let lampOn = true;
277+
278+
lampToggle.addEventListener("click", () => {
279+
lampOn = !lampOn;
280+
281+
if (lampOn) {
282+
lampToggle.textContent = "💡 ON";
283+
darkOverlay.classList.add("hidden");
284+
285+
formInputs.forEach(input => {
286+
input.disabled = false;
287+
});
288+
289+
} else {
290+
lampToggle.textContent = "💡 OFF";
291+
darkOverlay.classList.remove("hidden");
292+
293+
formInputs.forEach(input => {
294+
input.disabled = true;
295+
});
296+
}
297+
});
298+
});

src/frontend/components/RecentPredictions.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { getPredictions, clearPredictions } from "../js/predictionStorage.js";
1+
import {
2+
getPredictions,
3+
clearPredictions,
4+
comparePredictions
5+
} from "../js/predictionStorage.js";
26

37
export default function RecentPredictions() {
48
const history = getPredictions();
@@ -11,16 +15,35 @@ export default function RecentPredictions() {
1115
container.appendChild(title);
1216

1317
history.forEach((item, i) => {
14-
const div = document.createElement("div");
15-
div.className = "prediction-item";
16-
div.innerHTML = `
17-
<p><strong>${item.timestamp}</strong></p>
18-
<p>Input: ${item.input}</p>
19-
<p>Output: ${item.output}</p>
20-
`;
21-
container.appendChild(div);
22-
});
18+
const div = document.createElement("div");
19+
div.className = "prediction-item";
2320

21+
div.innerHTML = `
22+
<p><strong>${item.timestamp}</strong></p>
23+
<p>Input: ${item.input}</p>
24+
<p>Output: ${item.output}</p>
25+
`;
26+
27+
const compareBtn = document.createElement("button");
28+
compareBtn.textContent = "Compare";
29+
30+
compareBtn.onclick = () => {
31+
if (i + 1 < history.length) {
32+
const result = comparePredictions(i + 1, i);
33+
34+
alert(
35+
`Previous Output: ${result.previous.output}
36+
Latest Output: ${result.latest.output}`
37+
);
38+
} else {
39+
alert("No previous prediction available");
40+
}
41+
};
42+
43+
div.appendChild(compareBtn);
44+
45+
container.appendChild(div);
46+
});
2447
if (history.length > 0) {
2548
const clearBtn = document.createElement("button");
2649
clearBtn.textContent = "Clear History";

src/frontend/js/predictionStorage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ export function getPredictions() {
1212
export function clearPredictions() {
1313
localStorage.removeItem("predictions");
1414
}
15+
export function comparePredictions(index1, index2) {
16+
const history = getPredictions();
17+
18+
return {
19+
previous: history[index1],
20+
latest: history[index2]
21+
};
22+
}

0 commit comments

Comments
 (0)