-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreatepin.html
193 lines (161 loc) · 4.41 KB
/
createpin.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Create PIN</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
background-color: #f8f8f8;
}
h1 {
font-weight: normal;
font-size: 24px;
}
.container {
text-align: center;
margin-top: -200px;
}
.pin-dots {
display: flex;
justify-content: center;
margin-bottom: 70px;
}
.pin-dot {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #ccc;
margin: 0 5px;
}
.pin-dot.filled {
background-color: #333;
}
.numpad {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
max-width: 300px;
margin: 0 auto;
}
.numpad button {
font-size: 24px;
color: black;
padding: 20px;
border: none;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: background-color 0.3s;
width: 80px;
height: 80px;
}
.numpad button:active {
background-color: #e0e0e0;
}
.numpad button:last-child {
font-size: 24px;
border-radius: 0;
transform: scaleY(1.3);
transform-origin: center;
background-color: transparent;
box-shadow: none;
width: auto;
height: auto;
padding: 0;
}
.numpad .placeholder {
visibility: hidden;
}
</style>
</head>
<body>
<div class="container">
<h1>Create Passcode</h1>
<div id="pin-dots" class="pin-dots"></div>
<div class="numpad">
<button onclick="addDigit('1')">1</button>
<button onclick="addDigit('2')">2</button>
<button onclick="addDigit('3')">3</button>
<button onclick="addDigit('4')">4</button>
<button onclick="addDigit('5')">5</button>
<button onclick="addDigit('6')">6</button>
<button onclick="addDigit('7')">7</button>
<button onclick="addDigit('8')">8</button>
<button onclick="addDigit('9')">9</button>
<button class="placeholder"></button>
<button onclick="addDigit('0')">0</button>
<button onclick="clearLastDigit()"><</button>
</div>
</div>
<script>
let attempts = 0;
const maxAttempts = 5;
let pinValue = '';
function addDigit(digit) {
if (pinValue.length < 4) {
pinValue += digit;
updatePinDots();
// Check if the PIN is complete (4 digits)
if (pinValue.length === 4) {
// Automatically submit the PIN
submitPin();
}
}
}
function clearLastDigit() {
if (pinValue.length > 0) {
pinValue = pinValue.slice(0, -1);
updatePinDots();
}
}
function updatePinDots() {
const pinDots = document.getElementById('pin-dots');
pinDots.innerHTML = '';
for (let i = 0; i < 4; i++) {
const dot = document.createElement('div');
dot.className = 'pin-dot' + (i < pinValue.length ? ' filled' : '');
pinDots.appendChild(dot);
}
}
function clearPin() {
const dots = document.querySelectorAll('.pin-dot');
dots.forEach(dot => dot.classList.remove('filled'));
enteredPin = ''; // Reset the entered PIN
}
function submitPin() {
fetch('/create-pin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ pin: pinValue }),
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.href = data.redirectUrl;
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred. Please try again.');
});
}
function disableInputs() {
const buttons = document.querySelectorAll('.numpad button');
buttons.forEach(button => button.disabled = true);
}
// Initialize the pin dots
updatePinDots();
</script>
</body>
</html>