-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
60 lines (46 loc) · 2.21 KB
/
script.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
53
54
55
56
57
58
// ============== Pin-Matcher-Master JavaScript =================== //
const pinBtn = document.querySelector("#pinGenerator");
pinBtn.addEventListener("click", function(){
const pin = Math.random() * (9999 - 1000) + 1000;
const newPin = Math.floor(pin);
document.querySelector("#pinShow").value = newPin;
})
document.querySelector("#pinShow").value = "";
// ============== pin generate part =================== //
var pinSubmit = document.querySelector('#pinSubmit');
function value(data){
switch (data){
case 'c':
pinSubmit.value = "";
break;
case '<':
pinSubmit.value = pinSubmit.value.substr(0, pinSubmit.value.length - 1);
break;
default:
pinSubmit.value += data;
break;
}
}
document.querySelector("#pinSubmit").value = "";
// ============== keyboard part =================== //
const submitBtn = document.querySelector('#submitButton');
submitBtn.addEventListener('click', function(){
let pinShow = document.querySelector("#pinShow").value;
let pinSubmit = document.querySelector("#pinSubmit").value;
if (pinSubmit === pinShow) {
let notifySuccess = document.querySelector("#notifySuccess");
notifySuccess.style.display = "block";
let notifyFail = document.querySelector("#notifyFail");
notifyFail.style.display = " none";
document.querySelector("#pinSubmit").value = "";
document.querySelector("#pinShow").value = "";
}
else{
let notifyFail = document.querySelector("#notifyFail");
notifyFail.style.display = " block";
let notifySuccess = document.querySelector("#notifySuccess");
notifySuccess.style.display = "none";
document.querySelector("#pinSubmit").value = "";
document.querySelector("#pinShow").value = "";
}
});