You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.7 KiB

7 months ago
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Drone System - Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="login-page">
<div class="login-container">
<h1>Al Drone Console v1.0</h1>
<form id="login-form">
<div class="input-group">
7 months ago
<label for="id">id</label>
<input type="text" id="id" name="id" required>
7 months ago
</div>
<div class="input-group">
<label for="password">password</label>
<input type="password" id="password" name="password" required>
7 months ago
</div>
<button type="submit" class="login-button">Login</button>
</form>
</div>
<script>
// DOM(HTML)이 모두 로드되었을 때 실행
document.addEventListener('DOMContentLoaded', () => {
// ID가 'login-form'인 폼 요소를 가져옵니다.
const loginForm = document.getElementById('login-form');
if (loginForm) {
// 폼에서 'submit' 이벤트(로그인 버튼 클릭)가 발생했을 때 실행될 함수를 정의
loginForm.addEventListener('submit', (event) => {
// 1. 폼의 기본 제출 동작(페이지 새로고침 또는 이동)을 막습니다.
event.preventDefault();
// 2. ID와 비밀번호 입력 필드에서 사용자가 입력한 값을 가져옵니다.
const idInput = document.getElementById('id');
const passwordInput = document.getElementById('password');
const id = idInput.value;
const password = passwordInput.value;
// 3. ID와 비밀번호가 'admin'인지 확인합니다.
if (id === 'admin' && password === 'admin') {
// 4. 일치하면: 'dashboard.html' 페이지로 이동합니다.
console.log('Login successful. Redirecting to dashboard.html...');
window.location.href = 'dashboard.html';
} else {
// 5. 일치하지 않으면: 사용자에게 알림 창을 표시합니다.
alert('ID 또는 비밀번호가 올바르지 않습니다.');
// (선택 사항) 틀린 비밀번호 필드를 비우고 다시 포커스합니다.
passwordInput.value = '';
passwordInput.focus();
}
});
}
});
</script>
7 months ago
</body>
</html>