Upload files to "/"

This commit is contained in:
intanguci.pkl 2026-03-13 04:50:39 +00:00
commit 8ef44e4e6c
5 changed files with 172 additions and 0 deletions

53
dashboard.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<style>
body {
font-family: sans-serif;
background-color: #f4f4f4;
text-align: center;
padding-top: 50px;
}
.card {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
display: inline-block;
}
button {
background-color: #e74c3c;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="card">
<h1 id="welcomeMsg">Selamat Datang!</h1>
<p>Anda berhasil masuk ke halaman dashboard.</p>
<p>Ini adalah halaman tujuan setelah login berhasil.</p>
<button onclick="logout()">Logout</button>
</div>
<script>
var loggedInUser = localStorage.getItem("loggedInUser");
if (!loggedInUser) {
window.location.href = 'index.html';
} else {
document.getElementById("welcomeMsg").textContent = "Selamat Datang, " + loggedInUser + "!";
}
function logout() {
localStorage.removeItem("loggedInUser");
window.location.href = 'index.html';
}
</script>
</body>
</html>

30
index.html Normal file
View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Halaman Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form id="loginForm">
<h2>Login</h2>
<label for="username">username</label>
<input type="text" id="username" name="username" placeholder="masukan user" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="masukan password" required>
<button type="button" onclick="login()">login</button>
<p style="text-align:center; margin-top:15px; font-size:14px;">
Belum punya akun? <a href="register.html">Daftar di sini</a>
</p>
</form>
<script src="login.js"></script>
</body>
</html>

21
login.js Normal file
View File

@ -0,0 +1,21 @@
function login() {
var user = document.getElementById("username").value.trim();
var pass = document.getElementById("password").value;
// Ambil daftar user dari localStorage, default ada akun admin
var users = JSON.parse(localStorage.getItem("users")) || [
{ username: "admin", password: "123" }
];
var found = users.find(function(u) {
return u.username === user && u.password === pass;
});
if (found) {
localStorage.setItem("loggedInUser", user);
alert("Login Berhasil!");
window.location.href = 'dashboard.html';
} else {
alert("Username atau Password salah. Coba lagi!");
}
}

33
register.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Halaman Register</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form id="registerForm">
<h2>Register</h2>
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Masukkan username" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Masukkan password" required>
<label for="confirmPassword">Konfirmasi Password</label>
<input type="password" id="confirmPassword" name="confirmPassword" placeholder="Ulangi password" required>
<button type="button" onclick="register()">Daftar</button>
<p style="text-align:center; margin-top:15px; font-size:14px;">
Sudah punya akun? <a href="index.html">Login di sini</a>
</p>
</form>
<script src="register.js"></script>
</body>
</html>

35
register.js Normal file
View File

@ -0,0 +1,35 @@
function register() {
var user = document.getElementById("username").value.trim();
var pass = document.getElementById("password").value;
var confirmPass = document.getElementById("confirmPassword").value;
if (user === "" || pass === "") {
alert("Username dan password tidak boleh kosong!");
return;
}
if (pass !== confirmPass) {
alert("Konfirmasi password tidak cocok!");
return;
}
// Ambil daftar user, default ada akun admin
var users = JSON.parse(localStorage.getItem("users")) || [
{ username: "admin", password: "123" }
];
var exists = users.find(function(u) {
return u.username === user;
});
if (exists) {
alert("Username sudah digunakan! Coba nama lain.");
return;
}
users.push({ username: user, password: pass });
localStorage.setItem("users", JSON.stringify(users));
alert("Registrasi berhasil! Silakan login.");
window.location.href = 'index.html';
}