-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (104 loc) · 4.75 KB
/
index.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pin Generator</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="pin-generator half-width">
<input class="form-control" type="text" id="pin-box">
<button class="generate-btn" id="pin-generator-btn">Generate Pin</button>
</div>
</div>
<div class="col-md-6">
<div class="input-section half-width">
<input class="form-control" type="text" id="user-input-box">
<div class="numbers">
<div class="calc-body">
<div id="btn-container">
<div class="calc-button-row">
<div class="button">7</div>
<div class="button">8</div>
<div class="button">9</div>
</div>
<div class="calc-button-row">
<div class="button">4</div>
<div class="button">5</div>
<div class="button">6</div>
</div>
<div class="calc-button-row">
<div class="button">1</div>
<div class="button">2</div>
<div class="button">3</div>
</div>
<div class="calc-button-row">
<div class="button"><</div>
<div class="button">0</div>
<div class="button">C</div>
</div>
</div>
<div>
<button type="submit" class="submit-btn" id="match-btn">Submit</button>
<p class="action-left">3 try left</p>
</div>
</div>
</div>
</div>
</div>
<div class="notify-section">
<p class="notify" id="not-matched">❌ Pin Didn't Match, Please try again</p>
<p class="notify" id="matched">✅ Pin Matched... Secret door is opening for you</p>
</div>
</div>
<script>
let pinGeneratorButton = document.getElementById('pin-generator-btn');
let pinBox = document.getElementById('pin-box');
var userInputBox = document.getElementById('user-input-box');
userInputBox.value = "";
var matched = document.getElementById('matched');
var notMatched = document.getElementById('not-matched')
pinGeneratorButton.addEventListener('click', function () {
pinGenerator()
})
function pinGenerator() {
let pin = (Math.round(Math.random() * 10000));
pin = pin.toString();
if (pin.length < 4) {
console.log('less than 4');
pinGenerator();
} else {
pinBox.value = pin;
}
}
function userInput(){
var btnContainer = document.getElementById('btn-container');
btnContainer.addEventListener('click',function(e){
var btnValue = e.target.innerText;
userInputBox.value = userInputBox.value + btnValue ;
// userInputBox.value = userInput.value + btnValue;
})
}
function pinMather(){
let matchBtn = document.getElementById('match-btn');
matchBtn.addEventListener('click',function(){
if(pinBox.value == userInputBox.value){
matched.style.display = 'block';
notMatched.style.display = 'none'
}else{
matched.style.display = 'none';
notMatched.style.display = 'block'
}
})
}
pinMather()
userInput()
</script>
</body>
</html>