This commit is contained in:
2026-10-29 09:32:18 +07:00
commit e3c040b5d7
14 changed files with 347 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
View File
Binary file not shown.
+128
View File
@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jawaban Latihan Project 08</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; max-width: 600px; margin: auto; }
.exercise-box { background: #f9f9f9; padding: 15px; margin-bottom: 20px; border: 1px solid #ddd; border-radius: 5px; }
.hidden { display: none; }
#toggle-box { width: 100px; height: 100px; background: tomato; margin-top: 10px; color: white; display: flex; align-items: center; justify-content: center;}
ul { background: #fff; padding: 15px 30px; border: 1px solid #ccc; }
li { margin-bottom: 5px; }
.remove-btn { margin-left: 10px; background: red; color: white; border: none; cursor: pointer; padding: 3px 6px;}
</style>
</head>
<body>
<h1>Jawaban Latihan Project 08</h1>
<!-- EXERCISE 1 -->
<div class="exercise-box">
<h3>Exercise 1: Looping Angka 1-10</h3>
<ul id="number-list"></ul>
</div>
<!-- EXERCISE 2 -->
<div class="exercise-box">
<h3>Exercise 2: Filter Nama Huruf "A"</h3>
<ul id="name-list"></ul>
</div>
<!-- EXERCISE 3 -->
<div class="exercise-box">
<h3>Exercise 3: Toggle Button (Show/Hide)</h3>
<button id="toggle-btn">Tampilkan / Sembunyikan Kotak</button>
<div id="toggle-box">Ini Kotak!</div>
</div>
<!-- EXERCISE 4 -->
<div class="exercise-box">
<h3>Exercise 4: Live Character Counter</h3>
<textarea id="text-input" rows="4" style="width: 100%;" placeholder="Ketik sesuatu di sini..."></textarea>
<p>Jumlah karakter: <span id="char-count">0</span></p>
</div>
<!-- EXERCISE 5 -->
<div class="exercise-box">
<h3>Exercise 5: Mini To-Do List</h3>
<input type="text" id="todo-input" placeholder="Tugas baru...">
<button id="add-todo-btn">Tambah Tugas</button>
<ul id="todo-list"></ul>
</div>
<script>
// JAWABAN EXERCISE 1
// Gunakan for loop untuk mengisi <ul> dengan angka 1 sampai 10
const numberList = document.getElementById("number-list");
let htmlNumbers = "";
for (let i = 1; i <= 10; i++) {
htmlNumbers += `<li>Angka ${i}</li>`;
}
numberList.innerHTML = htmlNumbers;
const names = ["Andi", "Budi", "Ayu", "Citra", "Agus", "Dewi"];
const nameList = document.getElementById("name-list");
let htmlNames = "";
for (let i = 0; i < names.length; i++) {
if (names[i].startsWith("A")) {
htmlNames += `<li>${names[i]}</li>`;
}
}
nameList.innerHTML = htmlNames;
const toggleBtn = document.getElementById("toggle-btn");
const toggleBox = document.getElementById("toggle-box");
toggleBtn.addEventListener("click", function() {
toggleBox.classList.toggle("hidden");
});
const textInput = document.getElementById("text-input");
const charCount = document.getElementById("char-count");
textInput.addEventListener("input", function() {
charCount.textContent = textInput.value.length;
});
const todoInput = document.getElementById("todo-input");
const addTodoBtn = document.getElementById("add-todo-btn");
const todoList = document.getElementById("todo-list");
addTodoBtn.addEventListener("click", function() {
if (todoInput.value.trim() === "") return; // Cegah input kosong
const li = document.createElement("li");
li.textContent = todoInput.value + " ";
const removeBtn = document.createElement("button");
removeBtn.textContent = "Hapus";
removeBtn.className = "remove-btn";
li.appendChild(removeBtn);
todoList.appendChild(li);
todoInput.value = "";
});
todoList.addEventListener("click", function(event) {
if (event.target.matches(".remove-btn")) {
event.target.closest("li").remove();
}
});
</script>
</body>
</html>
+44
View File
@@ -0,0 +1,44 @@
<html>
<head>
<style>
body{
margin:0;
background: lightgray;
}
.slidebar{
background: blue;
color: white;
}
.dashboard{
display:flex;
main-height:100vh;
}
.slidebar a{
display:block;
color: white
text-decaration:none;
padding: 10px;
}
</style>
</head>
<body>
<div class="dashboard">
<aside class="slidebar">
<h2>mydashboard</h2>
<a href="#">dasboard</a>
<a href="#">statistik</a>
<a href="#">data siswa</a>
<a href="#">pemgaturan</a>
</aside>
<main class="main">
<h1>dashboard siswa</h1>
<p>tahun ajaran 2026/2027</p>
<section class="card">
<div></div>
</section>
</main><div>
\</div><body>
</body>
</html>
View File
+113
View File
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project 07 - Shopping Cart</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-4">
<div class="max-w-6xl mx-auto">
<h1 class="text-3xl font-bold text-center mb-6">
Product Catalog
</h1>
<input
type="search"
id="searchBox"
oninput="filterProducts()"
placeholder="Search product..."
class="w-full p-3 mb-6 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
>
<div id="product-list" class="grid grid-cols-1 lg:grid-cols-3 gap-4"></div>
</div>
<div class="max-w-6xl mx-auto flex flex-col lg:flex-row gap-6">
<!-- Product Catalog Grid -->
<div class="w-full lg:w-2/3 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
<!-- Product 1 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/controller.jpeg" alt="Controller" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Controller</h3>
<p class="text-gray-600">Rp 750.000</p>
<button data-name="Controller" data-price="750000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- Product 2 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/headset.png" alt="Headset" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Headset</h3>
<p class="text-gray-600">Rp 1.200.000</p>
<button data-name="Headset" data-price="1200000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- Product 3 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/keyboard.jpg" alt="Keyboard" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Keyboard</h3>
<p class="text-gray-600">Rp 1.800.000</p>
<button data-name="Keyboard" data-price="1800000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- Product 4 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/laptop.jpg" alt="Laptop" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Laptop</h3>
<p class="text-gray-600">Rp 14.985.000</p>
<button data-name="Laptop" data-price="14985000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- Product 5 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/monitor.jpeg" alt="Monitor" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Monitor</h3>
<p class="text-gray-600">Rp 3.000.000</p>
<button data-name="Monitor" data-price="3000000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- Product 6 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/mouse_logitech.jpg" alt="Mouse Logitech" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">Mouse Logitech</h3>
<p class="text-gray-600">Rp 600.000</p>
<button data-name="Mouse Logitech" data-price="600000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<!-- product 7 -->
<div class="bg-white p-4 rounded shadow">
<img src="images/speaker.jpeg" alt="speaker" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">speaker</h3>
<p class="text-gray-600">Rp 800.000</p>
<button data-name="speaker" data-price="800000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
<div class="bg-white p-4 rounded shadow">
<img src="images/webcam.jpeg" alt="webcam" class="w-full h-40 object-cover mb-4">
<h3 class="font-bold text-lg">webcam</h3>
<p class="text-gray-600">Rp 1.200.000</p>
<button data-name="webcam" data-price="1200000" class="add-to-cart-btn mt-2 bg-blue-500 text-white px-4 py-2 rounded w-full hover:bg-blue-600">Add to Cart</button>
</div>
</div>
<div class="w-full lg:w-1/3 bg-white p-6 rounded shadow h-fit">
<h2 class="text-2xl font-bold mb-4">Keranjang Belanja</h2>
<p id="empty-cart-msg" class="text-gray-500 italic mb-4">Keranjang masih kosong</p>
<ul id="cart-items" class="mb-4 space-y-2"></ul>
<div class="border-t pt-4 font-bold text-xl">
Total: Rp <span id="cart-total">0</span>
</div>
</div>
</div>
<script src="javascriptngelu.js"></script>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
let cart = [];
const cartItemsContainer = document.getElementById('cart-items');
const cartTotalElement = document.getElementById('cart-total');
const emptyCartMsg = document.getElementById('empty-cart-msg');
const addButtons = document.querySelectorAll('.add-to-cart-btn');
addButtons.forEach(button => {
button.addEventListener('click', function() {
const name = this.getAttribute('data-name');
const price = parseFloat(this.getAttribute('data-price'));
cart.push({ name, price });
renderCart();
});
});
cartItemsContainer.addEventListener('click', function () {
if (event.target.matches('.remove-btn') || event.target.closest('.remove-btn')) {
const itemIndex = event.target.getAttribute('data-index');
cart.splice(itemIndex, 1);
renderCart();
}
});
function renderCart() {
cartItemsContainer.innerHTML = '';
let total = 0;
if (cart.length === 0) {
emptyCartMsg.style.display = 'block';
} else {
emptyCartMsg.style.display = 'none';
cart.forEach((item, index) => {
total += item.price;
const li = document.createElement('li');
li.className = 'flex justify-between items-center bg-gray-50 p-2 rounded border';
const span = document.createElement('span');
// Mengubah format harga menjadi style Rupiah (id-ID)
span.textContent = `${item.name} - Rp ${item.price.toLocaleString('id-ID')}`;
const removeBtn = document.createElement('button');
removeBtn.textContent = 'Remove';
removeBtn.className = 'remove-btn bg-red-500 text-white px-2 py-1 rounded text-sm hover:bg-red-600';
removeBtn.setAttribute('data-index', index);
li.appendChild(span);
li.appendChild(removeBtn);
cartItemsContainer.appendChild(li);
});
}
cartTotalElement.textContent = total.toLocaleString('id-ID');
}