-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.js
54 lines (46 loc) · 1.8 KB
/
home.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
42
43
44
45
46
47
48
49
50
51
52
// for more details about simplebar https://github.com/Grsmto/simplebar
var difficultyLevel="Easy";
//var myElement = document.getElementById('main-div');
//new SimpleBar(myElement, { autoHide: true });
document.addEventListener("DOMContentLoaded",()=>{
document.getElementById("game-start-btn").addEventListener("click",()=>{
localStorage.setItem('difficulty', difficultyLevel);
});
document.getElementById("cbtn1").addEventListener("click",()=>{
removeColorFromButton();
let easyButton=document.getElementById("cbtn1");
easyButton.classList.add("purple-background");
setDifficultyLevel("Easy");
});
document.getElementById("cbtn2").addEventListener("click",()=>{
removeColorFromButton();
let intermediateButton=document.getElementById("cbtn2");
intermediateButton.classList.add("purple-background");
setDifficultyLevel("Intermediate");
});
document.getElementById("cbtn3").addEventListener("click",()=>{
removeColorFromButton();
let hardButton=document.getElementById("cbtn3");
hardButton.classList.add("purple-background");
setDifficultyLevel("Hard");
});
document.getElementById("popup-btn").addEventListener("click",()=>{
let userName=document.getElementById("name-input").value;
localStorage.setItem("username",userName);
window.location.href="./index.html";
});
});
let removeColorFromButton=()=>{
let easyButton=document.getElementById("cbtn1");
let intermediateButton=document.getElementById("cbtn2");
let hardButton=document.getElementById("cbtn3");
easyButton.classList.remove("purple-background");
intermediateButton.classList.remove("purple-background");
hardButton.classList.remove("purple-background");
};
let setDifficultyLevel=(difficulty)=>{
difficultyLevel=difficulty;
}
let addColorInButton=(buttonElement)=>{
buttonElement.classList.add("purple-background");
};