-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'backend' of github.com:tomaseuu/project-pomodoro into b…
…ackend
- Loading branch information
Showing
3 changed files
with
226 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>FocusFruitCalendar</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="index.css" /> | ||
</head> | ||
<body class="calendar-page"> | ||
<nav class="navbar"> | ||
<a href="index.html" class="logo-link"> | ||
<div class="logo-container"> | ||
<img src="focus-fruit-logo.png" alt="Focus-Fruit Logo" class="logo-image" /> | ||
<span class="logo-text">FocusFruit</span> | ||
</div> | ||
</a> | ||
<ul class="nav-list"> | ||
<li><a href="pomodoro.html">Home</a></li> | ||
<li><a href="calendar.html">Calendar</a></li> | ||
<li><a href="profile.html"><img src="user-logo.png" alt="Profile" class="profile-icon"></a></li> | ||
</ul> | ||
</nav> | ||
|
||
<main class="main-content"> | ||
<div class="calendar-container"> | ||
<div class="calendar-header"> | ||
<button id="prevMonth" class="nav-button"><</button> | ||
<h2 id="monthYear" class="month-header"></h2> | ||
<button id="nextMonth" class="nav-button">></button> | ||
</div> | ||
<div id="calendar" class="calendar-grid"></div> | ||
</div> | ||
</main> | ||
|
||
<script> | ||
|
||
let currentMonth = new Date().getMonth(); | ||
let currentYear = new Date().getFullYear(); | ||
|
||
function renderCalendar(month, year) { | ||
|
||
const calendar = document.getElementById('calendar'); | ||
const monthYearHeader = document.getElementById('monthYear'); | ||
|
||
calendar.innerHTML = ''; | ||
|
||
const monthName = new Date(year, month).toLocaleString('default', {month: 'long'}); | ||
monthYearHeader.textContent = `${monthName} ${year}`; | ||
|
||
const firstDays = new Date(year, month, 1).getDay(); | ||
const totalDays = new Date(year, month + 1, 0).getDate(); | ||
|
||
//days before first day (empty) | ||
for (let i = 0 ; i < firstDays ; i++) { | ||
const emptyCell = document.createElement('div'); | ||
emptyCell.classList.add('empty'); | ||
calendar.appendChild(emptyCell); | ||
} | ||
|
||
//add days of month | ||
for (let day = 1 ; day <= totalDays ; day++) { | ||
const dayDiv = document.createElement('div'); | ||
dayDiv.textContent = day; | ||
|
||
//todays date | ||
const today = new Date(); | ||
if ( | ||
day === today.getDate() && | ||
month === today.getMonth() && | ||
year === today.getFullYear() | ||
) { | ||
dayDiv.classList.add('current-date'); | ||
} | ||
|
||
calendar.appendChild(dayDiv); | ||
} | ||
} | ||
|
||
//left nav button | ||
document.getElementById('prevMonth').addEventListener('click', () => { | ||
currentMonth--; | ||
if (currentMonth < 0) { | ||
currentMonth = 11; | ||
currentYear--; | ||
} | ||
renderCalendar(currentMonth, currentYear); | ||
}) | ||
|
||
//right nav button | ||
document.getElementById('nextMonth').addEventListener('click', () => { | ||
currentMonth++; | ||
if (currentMonth > 11) { | ||
currentMonth = 0; | ||
currentYear++; | ||
} | ||
renderCalendar(currentMonth, currentYear); | ||
}); | ||
|
||
renderCalendar(currentMonth, currentYear); | ||
|
||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters