-
Notifications
You must be signed in to change notification settings - Fork 1
/
attendance.html
172 lines (156 loc) Β· 4.74 KB
/
attendance.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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog=="
crossorigin="anonymous" />
<!-- CSS -->
<title>Attendance</title>
</head>
<body>
<p>Enter the PassCode from the Board</p>
<h1>Falcon Code</h1>
<div class="otp-field">
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input class="space" type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
</div>
<br>
<br>
<div>
<button style="" onclick="submit()">Submit</button>
</div>
<script>
const inputs = document.querySelectorAll(".otp-field input");
inputs.forEach((input, index) => {
input.dataset.index = index;
input.addEventListener("keyup", handleOtp);
input.addEventListener("paste", handleOnPasteOtp);
});
function handleOtp(e) {
/**
* <input type="text" π maxlength="1" />
* π NOTE: On mobile devices `maxlength` property isn't supported,
* So we to write our own logic to make it work. π
*/
const input = e.target;
let value = input.value;
let isValidInput = value.match(/[0-9a-z]/gi);
input.value = "";
input.value = isValidInput ? value[0] : "";
let fieldIndex = input.dataset.index;
if (fieldIndex < inputs.length - 1 && isValidInput) {
input.nextElementSibling.focus();
}
if (e.key === "Backspace" && fieldIndex > 0) {
input.previousElementSibling.focus();
}
if (fieldIndex === inputs.length - 1 && isValidInput) {
submit();
}
}
function handleOnPasteOtp(e) {
const data = e.clipboardData.getData("text");
const value = data.split("");
if (value.length === inputs.length) {
inputs.forEach((input, index) => (input.value = value[index]));
submit();
}
}
function submit() {
console.log("Submitting...");
// π Entered OTP
let otp = "";
inputs.forEach((input) => {
otp += input.value;
input.disabled = true;
input.classList.add("disabled");
});
console.log(otp);
}
</script>
<style>
body {
margin: 0;
font-family: "Poppins", sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background: #1f202e;
height: 100vh;
color: #fff;
}
.otp-field {
display: flex;
}
.otp-field input {
width: 24px;
font-size: 32px;
padding: 10px;
text-align: center;
border-radius: 5px;
margin: 2px;
border: 2px solid #55525c;
background: #21232d;
font-weight: bold;
color: #fff;
outline: none;
transition: all 0.1s;
}
.otp-field input:focus {
border: 2px solid #a527ff;
box-shadow: 0 0 2px 2px #a527ff6a;
}
.disabled {
opacity: 0.5;
}
.space {
margin-right: 1rem !important;
}
</style>
</body>
<style>
/* From Uiverse.io by adamgiebl */
button {
--green: #dfe0e6;
font-size: 15px;
padding: 0.7em 2.7em;
letter-spacing: 0.06em;
position: relative;
font-family: inherit;
border-radius: 0.6em;
overflow: hidden;
transition: all 0.3s;
line-height: 1.4em;
border: 2px solid var(--green);
background: linear-gradient(to right, rgba(87, 140, 195, 0.49) 1%, transparent 40%,transparent 60% , rgba(112, 122, 228, 0.43) 100%);
color: var(--green);
box-shadow: inset 0 0 10px rgba(27, 253, 156, 0.4), 0 0 9px 3px rgba(27, 253, 156, 0.1);
}
button:hover {
color: #82ffc9;
box-shadow: inset 0 0 10px rgba(27, 253, 156, 0.6), 0 0 9px 3px rgba(27, 253, 156, 0.2);
}
button:before {
content: "";
position: absolute;
left: -4em;
width: 4em;
height: 100%;
top: 0;
transition: transform .4s ease-in-out;
background: linear-gradient(to right, transparent 1%, rgba(27, 253, 156, 0.1) 40%,rgba(27, 253, 156, 0.1) 60% , transparent 100%);
}
button:hover:before {
transform: translateX(15em);
}
</style>
</html>