Randomize default code
continuous-integration/drone/push Build is passing Details

main
Clément FRÉVILLE 1 year ago
parent b083271b92
commit 383ae9184d

@ -1,12 +1,20 @@
import './style.css';
const CODE = import.meta.env.VITE_KEYPAD_CODE || '1234';
const CODE = import.meta.env.VITE_KEYPAD_CODE || generateCode(4);
let builder = '';
const display = document.getElementById('display') as HTMLDivElement;
const light = document.getElementById('light') 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() {
builder = '';
display.innerText = '_'.repeat(CODE.length);

Loading…
Cancel
Save