-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·144 lines (115 loc) · 3.54 KB
/
app.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// DOM SELECTION
let numbers = document.querySelectorAll("div.number");
// console.log(numbers);
let input = document.querySelector("input");
console.log(input);
let removebtn = document.querySelector(".back");
// console.log(remove);
let btn = document.querySelector("input.event-none");
// console.log(button);
let randomCode="";
let linecode = document.querySelector("h3");
let subtitle = document.querySelector("legend");
let label = document.querySelector("h2");
let tag = document.querySelector("h6");
// console.log("h6");
let details = document.querySelector("span");
let add = document.querySelector("input#Tel");
let eye = document.querySelector("i.fas");
// console.log(eye);
// const input1 = document.querySelector('input');
// const log = document.getElementById('log');
let keyPad = document.querySelector("section#keypad");
//FUNCTIONS
function putInput() {
if (keyPad.hasAttribute("type")) {
input.value += this.getAttribute("num");
if (input.value.length === 11) {
btn.classList.remove("event-none");
btn.classList.add("active");
}
}
}
function putCode() {
if ( !keyPad.hasAttribute("type")){
if (input.value.length === 6) {
input.value = "";
btn.classList.remove("event-none");
btn.classList.add("active");
}
}
}
function myfunction (){
input.textContent = document.getElementById("Tel").onkeypress
}
function showEye() {
eye.style.display = "inline";
if (input.value.length === 0){
eye.style.display = "none";
}
}
// function logKey(e) {
// log.textContent += ` ${e.code}`;
// }
// }
function removeinput() {
let newStr = input.value.substr(0,input.value.length-1);
if (input.value = newStr){
// input.setAttribute("number","password");
}
// console.log(newStr);
}
function VertificationCode(e) {
e.preventDefault();
for (let i=0;i<6;i++){
randomCode += String(Math.floor(Math.random()*10));
}
// console.log(randomCode);
linecode.textContent=randomCode;
if (randomCode.length === 6){
input.value = "";
btn.classList.remove("active");
btn.classList.add("event-none");
btn.classList.add("yellow");
}
changeTage();
timer();
keyPad.removeAttribute("type");
showEye();
}
function changeTage() {
subtitle.textContent = "Vertification Code";
label.textContent = "XBOX";
tag.textContent = "Put Your Code Here";
add.setAttribute("type" , "password") ;
btn.textContent = "go for it";
}
function timer() {
let sec = 0;
let min = 0;
let interval = setInterval(function () {
sec++;
if (sec === 60){
min++;
sec =0;
}
let timer =" your time is 2 minutes: "+ min +":"+sec;
details.textContent = timer;
},1000);
}
function showEye() {
eye.style.display = "none";
if (add.value.length === 0){
eye.style.display = "inline";
}
}
//EVENT TRIGGERED
for (let number of numbers){
number.addEventListener("click" ,putInput);
number.addEventListener("click" ,putCode);
}
removebtn.addEventListener("click" , removeinput);
btn.addEventListener("click" , VertificationCode);
btn.addEventListener("click" , changeTage);
btn.addEventListener("click" , showEye);
// input.addEventListener('keydown',logKey);