|
|
@ -1,12 +1,20 @@
|
|
|
|
import './style.css';
|
|
|
|
import './style.css';
|
|
|
|
|
|
|
|
|
|
|
|
const CODE = import.meta.env.VITE_KEYPAD_CODE || '1234';
|
|
|
|
const CODE = import.meta.env.VITE_KEYPAD_CODE || generateCode(4);
|
|
|
|
let builder = '';
|
|
|
|
let builder = '';
|
|
|
|
|
|
|
|
|
|
|
|
const display = document.getElementById('display') as HTMLDivElement;
|
|
|
|
const display = document.getElementById('display') as HTMLDivElement;
|
|
|
|
const light = document.getElementById('light') as HTMLDivElement;
|
|
|
|
const light = document.getElementById('light') as HTMLDivElement;
|
|
|
|
const keypad = document.getElementById('keypad') as HTMLDivElement;
|
|
|
|
const keypad = document.getElementById('keypad') as HTMLDivElement;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function generateCode(len: number): string {
|
|
|
|
|
|
|
|
let code = '';
|
|
|
|
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
|
|
|
|
code += Math.floor(Math.random() * 10).toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return code;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function resetCode() {
|
|
|
|
function resetCode() {
|
|
|
|
builder = '';
|
|
|
|
builder = '';
|
|
|
|
display.innerText = '_'.repeat(CODE.length);
|
|
|
|
display.innerText = '_'.repeat(CODE.length);
|
|
|
|