Initial commit
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Weekly Calendar</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
/* 7 columns for 7 days */
|
||||||
|
gap: 10px;
|
||||||
|
margin: 20px auto;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-column {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-header {
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hour-block {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 2px 0;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hour-block.clicked {
|
||||||
|
background-color: #87CEEB;
|
||||||
|
/* Change color when clicked */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Datefinder</h1>
|
||||||
|
<div class="calendar" id="calendar"></div>
|
||||||
|
<script src="index.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// Days of the week
|
||||||
|
const daysOfWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
||||||
|
|
||||||
|
// Select the calendar container
|
||||||
|
const calendar = document.getElementById("calendar");
|
||||||
|
|
||||||
|
// Create the weekly calendar
|
||||||
|
daysOfWeek.forEach((day) => {
|
||||||
|
// Create a column for each day
|
||||||
|
const dayColumn = document.createElement("div");
|
||||||
|
dayColumn.classList.add("day-column");
|
||||||
|
|
||||||
|
// Add a header for the day
|
||||||
|
const dayHeader = document.createElement("div");
|
||||||
|
dayHeader.classList.add("day-header");
|
||||||
|
dayHeader.textContent = day;
|
||||||
|
dayColumn.appendChild(dayHeader);
|
||||||
|
|
||||||
|
// Add hourly blocks for each day
|
||||||
|
for (let hour = 0; hour < 24; hour++) {
|
||||||
|
const hourBlock = document.createElement("div");
|
||||||
|
hourBlock.classList.add("hour-block");
|
||||||
|
hourBlock.textContent = `${hour}:00`;
|
||||||
|
|
||||||
|
// Add a click event listener to toggle color
|
||||||
|
hourBlock.addEventListener("click", () => {
|
||||||
|
hourBlock.classList.toggle("clicked");
|
||||||
|
});
|
||||||
|
|
||||||
|
dayColumn.appendChild(hourBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the day column to the calendar
|
||||||
|
calendar.appendChild(dayColumn);
|
||||||
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user