Keep the green light on

This commit is contained in:
2023-11-14 17:57:34 +01:00
parent 6100bd8cd8
commit 0469830e59

View File

@@ -27,11 +27,9 @@ function resetCode() {
function composeDigit(digit: number) {
builder += digit.toString();
display.innerText = builder + '_'.repeat(CODE.length - builder.length);
light.classList.remove(IS_SUCCESS, IS_ERROR);
if (CODE.startsWith(builder)) {
light.classList.add(IS_SUCCESS);
if (builder !== CODE) {
setTimeout(() => light.classList.remove(IS_SUCCESS), DELAY);
}
} else {
light.classList.add(IS_ERROR);
setTimeout(resetCode, DELAY);