-
Notifications
You must be signed in to change notification settings - Fork 0
/
restart.js
41 lines (36 loc) · 1.2 KB
/
restart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { createAnswer } from "./answer.js";
import { commonCSSClassPrefix } from "./constants.js";
import createLayout from "./create_layout.js";
import { repairHeart } from "./heart_anim.js";
import { keys, resetCorrectCounter, resetWrongCounter } from "./keyboard.js";
import { hearts } from "./lives.js";
import { checkAnswerNumber } from "./pick_random_question.js";
import questions from "./questions.js";
import { returnClothes } from "./return_clothes.js";
import { yepAnim } from "./yep_anim.js";
export let isRestart = false;
export const restart = () => {
isRestart = true;
};
const restartButton = createLayout({
elementname: "restartButton",
classname: `${commonCSSClassPrefix}_restart`,
tag: "button",
textcontent: "restart",
});
restartButton.addEventListener("click", () => {
isRestart = true;
resetCorrectCounter();
resetWrongCounter();
window.history.pushState({}, "", window.location.pathname);
keys.forEach((key) => {
key.removeAttribute("disabled");
key.style.backgroundColor = "lightgreen";
});
checkAnswerNumber(questions);
createAnswer(localStorage.getItem("que_lyu"));
repairHeart(hearts);
returnClothes();
yepAnim(false, "");
});
export default restartButton;