Download index.html from davphi17/freespace: direct link, hf CLI and curl.
- Browser
- Download file 48.2 kB
-
https://huggingface.co/spaces/davphi17/freespace/resolve/main/index.html
- Command line
-
hf download hf://spaces/davphi17/freespace/index.html
-
curl -L -o index.html https://huggingface.co/spaces/davphi17/freespace/resolve/main/index.html
48.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Hamilton Christian School - Space Booking</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .hidden { | |
| display: none; | |
| } | |
| .calendar-day { | |
| transition: all 0.2s ease; | |
| } | |
| .calendar-day:hover:not(.disabled):not(.booked) { | |
| background-color: #f0f9ff; | |
| cursor: pointer; | |
| } | |
| .booking-card { | |
| transition: all 0.3s ease; | |
| } | |
| .booking-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); | |
| } | |
| #login { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| bottom: 0; | |
| background-color: rgba(255, 255, 255, 0.9); | |
| z-index: 1000; | |
| overflow-y: auto; | |
| } | |
| .room-image { | |
| height: 200px; | |
| object-fit: cover; | |
| } | |
| @media (max-width: 768px) { | |
| .room-image { | |
| height: 150px; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <!-- Navigation Bar --> | |
| <nav class="bg-blue-800 text-white shadow-lg"> | |
| <div class="container mx-auto px-4 py-3 flex justify-between items-center"> | |
| <div class="flex items-center space-x-4"> | |
| <a href="#" id="home-link" class="text-xl font-bold hover:text-blue-200 transition">HCS Booking</a> | |
| <a href="#" id="back-link" class="hidden hover:text-blue-200 transition"> | |
| <i class="fas fa-arrow-left mr-1"></i> Back | |
| </a> | |
| </div> | |
| <div id="logout-container" class="hidden"> | |
| <button id="logout-btn" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded transition"> | |
| <i class="fas fa-sign-out-alt mr-1"></i> Logout | |
| </button> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Main Content Area --> | |
| <main class="container mx-auto px-4 py-8"> | |
| <!-- Homepage - Booking Area Selection --> | |
| <section id="homepage" class="page"> | |
| <h1 class="text-3xl md:text-4xl font-bold text-gray-800 mb-8">Book a Space at Hamilton Christian School</h1> | |
| <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"> | |
| <!-- Fields Card --> | |
| <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition"> | |
| <div class="bg-green-600 h-40 flex items-center justify-center"> | |
| <i class="fas fa-futbol text-white text-6xl"></i> | |
| </div> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-2">Fields</h3> | |
| <p class="text-gray-600 mb-4">Book our outdoor sports fields for games and practices.</p> | |
| <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="fields"> | |
| View Fields <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Classrooms Card --> | |
| <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition"> | |
| <div class="bg-blue-600 h-40 flex items-center justify-center"> | |
| <i class="fas fa-chalkboard text-white text-6xl"></i> | |
| </div> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-2">Classrooms</h3> | |
| <p class="text-gray-600 mb-4">Book classrooms for meetings, events, or study sessions.</p> | |
| <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="classrooms"> | |
| View Classrooms <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- MPR/Library Card --> | |
| <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition"> | |
| <div class="bg-purple-600 h-40 flex items-center justify-center"> | |
| <i class="fas fa-book-open text-white text-6xl"></i> | |
| </div> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-2">MPR/Library</h3> | |
| <p class="text-gray-600 mb-4">Book our Multi-Purpose Room or Library for larger events.</p> | |
| <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="mpr-library"> | |
| View Spaces <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Courts Card --> | |
| <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition"> | |
| <div class="bg-red-600 h-40 flex items-center justify-center"> | |
| <i class="fas fa-basketball-ball text-white text-6xl"></i> | |
| </div> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-2">Courts</h3> | |
| <p class="text-gray-600 mb-4">Book our basketball or tennis courts for games and practice.</p> | |
| <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="courts"> | |
| View Courts <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Space Selection Pages --> | |
| <section id="space-selection" class="page hidden"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <h2 id="space-title" class="text-2xl md:text-3xl font-bold text-gray-800"></h2> | |
| <div class="flex space-x-2"> | |
| <button id="prev-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition"> | |
| <i class="fas fa-chevron-left"></i> | |
| </button> | |
| <button id="next-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition"> | |
| <i class="fas fa-chevron-right"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div id="space-content" class="grid grid-cols-1 md:grid-cols-3 gap-6"> | |
| <!-- Space items will be dynamically inserted here --> | |
| </div> | |
| </section> | |
| <!-- Room Details Page --> | |
| <section id="room-details" class="page hidden"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h2 id="room-title" class="text-2xl md:text-3xl font-bold text-gray-800"></h2> | |
| <div class="flex space-x-2"> | |
| <button id="room-prev-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition"> | |
| <i class="fas fa-chevron-left"></i> | |
| </button> | |
| <span id="room-current-month" class="px-3 py-1 font-medium"></span> | |
| <button id="room-next-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition"> | |
| <i class="fas fa-chevron-right"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 lg:grid-cols-2 gap-8"> | |
| <div> | |
| <div class="bg-white rounded-lg shadow-md overflow-hidden mb-6"> | |
| <img id="room-main-image" src="https://via.placeholder.com/800x400?text=Room+Image" alt="Room Image" class="w-full room-image"> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold mb-2" id="room-name"></h3> | |
| <p class="text-gray-600 mb-4" id="room-description"></p> | |
| <div class="grid grid-cols-2 gap-4 mb-4"> | |
| <div> | |
| <span class="block text-sm text-gray-500">Capacity</span> | |
| <span class="font-medium" id="room-capacity"></span> | |
| </div> | |
| <div> | |
| <span class="block text-sm text-gray-500">Type</span> | |
| <span class="font-medium" id="room-type"></span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-4 mb-8"> | |
| <img src="https://via.placeholder.com/400x300?text=Inside+View" alt="Inside View" class="rounded shadow room-image"> | |
| <img src="https://via.placeholder.com/400x300?text=Outside+View" alt="Outside View" class="rounded shadow room-image"> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="bg-white rounded-lg shadow-md p-6 mb-6"> | |
| <h3 class="text-xl font-semibold mb-4">Availability Calendar</h3> | |
| <div id="room-calendar" class="grid grid-cols-7 gap-1 mb-4"> | |
| <!-- Calendar days will be inserted here --> | |
| </div> | |
| <div class="mb-6"> | |
| <h4 class="font-medium mb-2">Available Time Slots</h4> | |
| <div id="time-slots" class="grid grid-cols-2 md:grid-cols-3 gap-2"> | |
| <!-- Time slots will be inserted here --> | |
| </div> | |
| </div> | |
| <div id="booking-form" class="hidden"> | |
| <h4 class="font-medium mb-2">Book This Room</h4> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm text-gray-600 mb-1">Selected Date</label> | |
| <input type="text" id="booking-date" class="w-full p-2 border rounded" readonly> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-600 mb-1">Time Slot</label> | |
| <input type="text" id="booking-time" class="w-full p-2 border rounded" readonly> | |
| </div> | |
| <div> | |
| <label for="booking-purpose" class="block text-sm text-gray-600 mb-1">Purpose</label> | |
| <input type="text" id="booking-purpose" class="w-full p-2 border rounded" placeholder="Meeting, Event, etc."> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <button id="confirm-booking" class="flex-1 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition"> | |
| Confirm Booking | |
| </button> | |
| <button id="cancel-booking" class="flex-1 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300 transition"> | |
| Cancel | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="my-bookings" class="bg-white rounded-lg shadow-md p-6 hidden"> | |
| <h3 class="text-xl font-semibold mb-4">My Bookings</h3> | |
| <div id="bookings-list"> | |
| <!-- User's bookings will be inserted here --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| </main> | |
| <!-- Login Page (hidden by default) --> | |
| <section id="login" class="page hidden"> | |
| <div class="bg-blue-800 text-white py-12"> | |
| <div class="container mx-auto px-4"> | |
| <h1 class="text-3xl md:text-4xl font-bold">Login to Your Account</h1> | |
| <p class="text-xl mt-2">Access your bookings and account details</p> | |
| </div> | |
| </div> | |
| <div class="container mx-auto px-4 py-12"> | |
| <div class="max-w-md mx-auto bg-white p-8 rounded-lg shadow-md"> | |
| <form id="login-form" class="space-y-6"> | |
| <div> | |
| <label for="login-email" class="block text-sm font-medium text-gray-700 mb-1">Email</label> | |
| <input type="email" id="login-email" class="w-full p-3 border rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="login-password" class="block text-sm font-medium text-gray-700 mb-1">Password</label> | |
| <input type="password" id="login-password" class="w-full p-3 border rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div class="flex items-center justify-between"> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="remember-me" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"> | |
| <label for="remember-me" class="ml-2 block text-sm text-gray-700">Remember me</label> | |
| </div> | |
| <a href="#" class="text-sm text-blue-600 hover:text-blue-800">Forgot password?</a> | |
| </div> | |
| <div> | |
| <button type="submit" class="w-full py-3 px-4 bg-blue-600 text-white rounded hover:bg-blue-700 transition duration-300"> | |
| Login | |
| </button> | |
| </div> | |
| <div class="text-center"> | |
| <p class="text-sm text-gray-600">Don't have an account? <a href="#" class="text-blue-600 hover:text-blue-800">Create one</a></p> | |
| </div> | |
| </form> | |
| <div class="mt-6"> | |
| <div class="relative"> | |
| <div class="absolute inset-0 flex items-center"> | |
| <div class="w-full border-t border-gray-300"></div> | |
| </div> | |
| <div class="relative flex justify-center text-sm"> | |
| <span class="px-2 bg-white text-gray-500">Or continue with</span> | |
| </div> | |
| </div> | |
| <div class="mt-6 grid grid-cols-1 gap-3"> | |
| <button id="google-login" class="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 hover:bg-gray-50"> | |
| <i class="fab fa-google text-red-500 mr-2"></i> Sign in with Google | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Toast Notification --> | |
| <div id="toast" class="fixed bottom-4 right-4 bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg hidden"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-check-circle mr-2"></i> | |
| <span id="toast-message"></span> | |
| </div> | |
| </div> | |
| <script> | |
| // State management | |
| const state = { | |
| currentUser: null, | |
| currentPage: 'homepage', | |
| currentSpaceType: null, | |
| currentRoom: null, | |
| currentMonth: new Date().getMonth(), | |
| currentYear: new Date().getFullYear(), | |
| bookings: JSON.parse(localStorage.getItem('bookings')) || [], | |
| selectedDate: null, | |
| selectedTime: null, | |
| loginRedirect: null | |
| }; | |
| // DOM Elements | |
| const pages = document.querySelectorAll('.page'); | |
| const homeLink = document.getElementById('home-link'); | |
| const backLink = document.getElementById('back-link'); | |
| const logoutContainer = document.getElementById('logout-container'); | |
| const logoutBtn = document.getElementById('logout-btn'); | |
| const bookBtns = document.querySelectorAll('.book-btn'); | |
| const spaceSelectionPage = document.getElementById('space-selection'); | |
| const spaceTitle = document.getElementById('space-title'); | |
| const spaceContent = document.getElementById('space-content'); | |
| const prevMonthBtn = document.getElementById('prev-month'); | |
| const nextMonthBtn = document.getElementById('next-month'); | |
| const roomDetailsPage = document.getElementById('room-details'); | |
| const roomTitle = document.getElementById('room-title'); | |
| const roomName = document.getElementById('room-name'); | |
| const roomDescription = document.getElementById('room-description'); | |
| const roomCapacity = document.getElementById('room-capacity'); | |
| const roomType = document.getElementById('room-type'); | |
| const roomMainImage = document.getElementById('room-main-image'); | |
| const roomCalendar = document.getElementById('room-calendar'); | |
| const roomCurrentMonth = document.getElementById('room-current-month'); | |
| const roomPrevMonthBtn = document.getElementById('room-prev-month'); | |
| const roomNextMonthBtn = document.getElementById('room-next-month'); | |
| const timeSlots = document.getElementById('time-slots'); | |
| const bookingForm = document.getElementById('booking-form'); | |
| const bookingDate = document.getElementById('booking-date'); | |
| const bookingTime = document.getElementById('booking-time'); | |
| const bookingPurpose = document.getElementById('booking-purpose'); | |
| const confirmBookingBtn = document.getElementById('confirm-booking'); | |
| const cancelBookingBtn = document.getElementById('cancel-booking'); | |
| const myBookingsSection = document.getElementById('my-bookings'); | |
| const bookingsList = document.getElementById('bookings-list'); | |
| const loginPage = document.getElementById('login'); | |
| const loginForm = document.getElementById('login-form'); | |
| const loginEmail = document.getElementById('login-email'); | |
| const loginPassword = document.getElementById('login-password'); | |
| const googleLoginBtn = document.getElementById('google-login'); | |
| const toast = document.getElementById('toast'); | |
| const toastMessage = document.getElementById('toast-message'); | |
| // Initialize the app | |
| function init() { | |
| // Check if user is logged in from localStorage | |
| const savedUser = localStorage.getItem('currentUser'); | |
| if (savedUser) { | |
| state.currentUser = JSON.parse(savedUser); | |
| logoutContainer.classList.remove('hidden'); | |
| } | |
| // Set up event listeners | |
| homeLink.addEventListener('click', showHomepage); | |
| backLink.addEventListener('click', goBack); | |
| logoutBtn.addEventListener('click', handleLogout); | |
| bookBtns.forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const spaceType = btn.getAttribute('data-type'); | |
| showSpaceSelection(spaceType); | |
| }); | |
| }); | |
| prevMonthBtn.addEventListener('click', () => { | |
| if (state.currentMonth === 0) { | |
| state.currentMonth = 11; | |
| state.currentYear--; | |
| } else { | |
| state.currentMonth--; | |
| } | |
| renderSpaceSelection(); | |
| }); | |
| nextMonthBtn.addEventListener('click', () => { | |
| if (state.currentMonth === 11) { | |
| state.currentMonth = 0; | |
| state.currentYear++; | |
| } else { | |
| state.currentMonth++; | |
| } | |
| renderSpaceSelection(); | |
| }); | |
| roomPrevMonthBtn.addEventListener('click', () => { | |
| if (state.currentMonth === 0) { | |
| state.currentMonth = 11; | |
| state.currentYear--; | |
| } else { | |
| state.currentMonth--; | |
| } | |
| renderRoomDetails(); | |
| }); | |
| roomNextMonthBtn.addEventListener('click', () => { | |
| if (state.currentMonth === 11) { | |
| state.currentMonth = 0; | |
| state.currentYear++; | |
| } else { | |
| state.currentMonth++; | |
| } | |
| renderRoomDetails(); | |
| }); | |
| confirmBookingBtn.addEventListener('click', handleConfirmBooking); | |
| cancelBookingBtn.addEventListener('click', () => { | |
| bookingForm.classList.add('hidden'); | |
| state.selectedDate = null; | |
| state.selectedTime = null; | |
| }); | |
| loginForm.addEventListener('submit', handleLogin); | |
| googleLoginBtn.addEventListener('click', handleGoogleLogin); | |
| // Show homepage by default | |
| showPage('homepage'); | |
| } | |
| // Page navigation functions | |
| function showPage(pageId) { | |
| pages.forEach(page => { | |
| if (page.id === pageId) { | |
| page.classList.remove('hidden'); | |
| state.currentPage = pageId; | |
| } else { | |
| page.classList.add('hidden'); | |
| } | |
| }); | |
| // Update navigation buttons | |
| if (pageId === 'homepage') { | |
| backLink.classList.add('hidden'); | |
| } else if (pageId === 'space-selection') { | |
| backLink.classList.remove('hidden'); | |
| } else if (pageId === 'room-details') { | |
| backLink.classList.remove('hidden'); | |
| } | |
| // Update logout button visibility | |
| if (state.currentUser) { | |
| logoutContainer.classList.remove('hidden'); | |
| } else { | |
| logoutContainer.classList.add('hidden'); | |
| } | |
| } | |
| function showHomepage(e) { | |
| if (e) e.preventDefault(); | |
| showPage('homepage'); | |
| } | |
| function showSpaceSelection(spaceType) { | |
| state.currentSpaceType = spaceType; | |
| // Set title based on space type | |
| let title = ''; | |
| switch (spaceType) { | |
| case 'fields': | |
| title = 'Sports Fields'; | |
| break; | |
| case 'classrooms': | |
| title = 'Classrooms'; | |
| break; | |
| case 'mpr-library': | |
| title = 'MPR & Library'; | |
| break; | |
| case 'courts': | |
| title = 'Sports Courts'; | |
| break; | |
| } | |
| spaceTitle.textContent = title; | |
| renderSpaceSelection(); | |
| showPage('space-selection'); | |
| } | |
| function showRoomDetails(room) { | |
| state.currentRoom = room; | |
| roomTitle.textContent = room.name; | |
| roomName.textContent = room.name; | |
| roomDescription.textContent = room.description; | |
| roomCapacity.textContent = room.capacity; | |
| roomType.textContent = room.type; | |
| roomMainImage.src = room.image; | |
| renderRoomDetails(); | |
| showPage('room-details'); | |
| } | |
| function goBack(e) { | |
| if (e) e.preventDefault(); | |
| if (state.currentPage === 'space-selection') { | |
| showHomepage(); | |
| } else if (state.currentPage === 'room-details') { | |
| showSpaceSelection(state.currentSpaceType); | |
| } | |
| } | |
| // Render functions | |
| function renderSpaceSelection() { | |
| spaceContent.innerHTML = ''; | |
| // Get spaces based on current space type | |
| const spaces = getSpacesForType(state.currentSpaceType); | |
| spaces.forEach(space => { | |
| const spaceElement = document.createElement('div'); | |
| spaceElement.className = 'bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition cursor-pointer'; | |
| spaceElement.innerHTML = ` | |
| <div class="h-40 bg-blue-100 flex items-center justify-center"> | |
| <i class="${space.icon} text-blue-600 text-6xl"></i> | |
| </div> | |
| <div class="p-6"> | |
| <h3 class="text-xl font-semibold text-gray-800 mb-2">${space.name}</h3> | |
| <p class="text-gray-600 mb-4">${space.description}</p> | |
| <button class="view-space-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-id="${space.id}"> | |
| View Details <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| `; | |
| spaceContent.appendChild(spaceElement); | |
| }); | |
| // Add event listeners to view buttons | |
| document.querySelectorAll('.view-space-btn').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const spaceId = btn.getAttribute('data-id'); | |
| const space = getSpaceById(spaceId); | |
| showRoomDetails(space); | |
| }); | |
| }); | |
| } | |
| function renderRoomDetails() { | |
| // Update month display | |
| const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | |
| roomCurrentMonth.textContent = `${monthNames[state.currentMonth]} ${state.currentYear}`; | |
| // Render calendar | |
| renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id); | |
| // Show user's bookings if logged in | |
| if (state.currentUser) { | |
| myBookingsSection.classList.remove('hidden'); | |
| renderUserBookings(); | |
| } else { | |
| myBookingsSection.classList.add('hidden'); | |
| } | |
| // Clear time slots and booking form | |
| timeSlots.innerHTML = ''; | |
| bookingForm.classList.add('hidden'); | |
| } | |
| function renderCalendar(container, year, month, roomId) { | |
| container.innerHTML = ''; | |
| // Add day headers | |
| const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; | |
| dayNames.forEach(day => { | |
| const dayHeader = document.createElement('div'); | |
| dayHeader.className = 'text-center font-medium text-sm py-1'; | |
| dayHeader.textContent = day; | |
| container.appendChild(dayHeader); | |
| }); | |
| // Get first day of month and total days | |
| const firstDay = new Date(year, month, 1).getDay(); | |
| const daysInMonth = new Date(year, month + 1, 0).getDate(); | |
| // Add empty cells for days before first day | |
| for (let i = 0; i < firstDay; i++) { | |
| const emptyCell = document.createElement('div'); | |
| emptyCell.className = 'h-10'; | |
| container.appendChild(emptyCell); | |
| } | |
| // Add day cells | |
| const today = new Date(); | |
| today.setHours(0, 0, 0, 0); | |
| for (let day = 1; day <= daysInMonth; day++) { | |
| const date = new Date(year, month, day); | |
| const dayCell = document.createElement('div'); | |
| dayCell.className = 'calendar-day text-center p-1 h-10 border rounded'; | |
| // Check if date is in the past or less than 5 days ahead | |
| const minBookingDate = new Date(); | |
| minBookingDate.setDate(minBookingDate.getDate() + 5); | |
| minBookingDate.setHours(0, 0, 0, 0); | |
| if (date < minBookingDate) { | |
| dayCell.classList.add('disabled', 'bg-gray-100', 'text-gray-400'); | |
| } else { | |
| // Check if date is booked | |
| const isBooked = state.bookings.some(booking => { | |
| const bookingDate = new Date(booking.date); | |
| return ( | |
| booking.roomId === roomId && | |
| bookingDate.getFullYear() === year && | |
| bookingDate.getMonth() === month && | |
| bookingDate.getDate() === day | |
| ); | |
| }); | |
| if (isBooked) { | |
| dayCell.classList.add('booked', 'bg-red-100', 'text-red-800'); | |
| } | |
| } | |
| dayCell.textContent = day; | |
| // Add click event for selectable days | |
| if (!dayCell.classList.contains('disabled') && !dayCell.classList.contains('booked')) { | |
| dayCell.addEventListener('click', () => handleDateSelect(year, month, day, roomId)); | |
| } | |
| container.appendChild(dayCell); | |
| } | |
| } | |
| function handleDateSelect(year, month, day, roomId) { | |
| state.selectedDate = new Date(year, month, day); | |
| // Format date for display | |
| const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; | |
| bookingDate.value = state.selectedDate.toLocaleDateString('en-US', options); | |
| // Generate time slots (9am to 5pm in 1-hour increments) | |
| timeSlots.innerHTML = ''; | |
| const startHour = 9; | |
| const endHour = 17; | |
| for (let hour = startHour; hour < endHour; hour++) { | |
| const timeSlot = document.createElement('button'); | |
| timeSlot.className = 'py-2 bg-green-100 text-green-800 rounded hover:bg-green-200 transition'; | |
| timeSlot.textContent = `${hour}:00 - ${hour + 1}:00`; | |
| timeSlot.addEventListener('click', () => { | |
| // Remove active class from all time slots | |
| document.querySelectorAll('#time-slots button').forEach(btn => { | |
| btn.classList.remove('bg-green-500', 'text-white'); | |
| btn.classList.add('bg-green-100', 'text-green-800'); | |
| }); | |
| // Add active class to selected time slot | |
| timeSlot.classList.remove('bg-green-100', 'text-green-800'); | |
| timeSlot.classList.add('bg-green-500', 'text-white'); | |
| state.selectedTime = `${hour}:00 - ${hour + 1}:00`; | |
| bookingTime.value = state.selectedTime; | |
| // Show booking form | |
| bookingForm.classList.remove('hidden'); | |
| }); | |
| timeSlots.appendChild(timeSlot); | |
| } | |
| } | |
| function renderUserBookings() { | |
| if (!state.currentUser) return; | |
| const userBookings = state.bookings.filter( | |
| booking => booking.userId === state.currentUser.id && booking.roomId === state.currentRoom.id | |
| ); | |
| if (userBookings.length === 0) { | |
| bookingsList.innerHTML = '<p class="text-gray-500">You have no bookings for this room.</p>'; | |
| return; | |
| } | |
| bookingsList.innerHTML = ''; | |
| userBookings.forEach(booking => { | |
| const bookingElement = document.createElement('div'); | |
| bookingElement.className = 'border-b border-gray-200 py-4'; | |
| bookingElement.innerHTML = ` | |
| <div class="flex justify-between items-start"> | |
| <div> | |
| <h4 class="font-medium">${new Date(booking.date).toLocaleDateString()}</h4> | |
| <p class="text-sm text-gray-600">${booking.time}</p> | |
| <p class="text-sm mt-1">${booking.purpose}</p> | |
| </div> | |
| <div> | |
| <button class="edit-booking-btn px-3 py-1 bg-blue-100 text-blue-600 rounded hover:bg-blue-200 transition text-sm mr-2" data-id="${booking.id}"> | |
| <i class="fas fa-edit mr-1"></i> Edit | |
| </button> | |
| <button class="cancel-booking-btn px-3 py-1 bg-red-100 text-red-600 rounded hover:bg-red-200 transition text-sm" data-id="${booking.id}"> | |
| <i class="fas fa-trash-alt mr-1"></i> Cancel | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| bookingsList.appendChild(bookingElement); | |
| }); | |
| // Add event listeners to edit and cancel buttons | |
| document.querySelectorAll('.edit-booking-btn').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const bookingId = btn.getAttribute('data-id'); | |
| promptLoginIfNeeded(() => { | |
| const booking = state.bookings.find(b => b.id === bookingId); | |
| if (booking) { | |
| editBooking(booking); | |
| } | |
| }); | |
| }); | |
| }); | |
| document.querySelectorAll('.cancel-booking-btn').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const bookingId = btn.getAttribute('data-id'); | |
| promptLoginIfNeeded(() => { | |
| cancelBooking(bookingId); | |
| }); | |
| }); | |
| }); | |
| } | |
| // Booking functions | |
| function handleConfirmBooking() { | |
| if (!state.currentUser) { | |
| showToast('Please login to make a booking'); | |
| return; | |
| } | |
| if (!state.selectedDate || !state.selectedTime) { | |
| showToast('Please select a date and time'); | |
| return; | |
| } | |
| const purpose = bookingPurpose.value.trim(); | |
| if (!purpose) { | |
| showToast('Please enter a purpose for your booking'); | |
| return; | |
| } | |
| // Create new booking | |
| const newBooking = { | |
| id: generateId(), | |
| userId: state.currentUser.id, | |
| roomId: state.currentRoom.id, | |
| date: state.selectedDate.toISOString(), | |
| time: state.selectedTime, | |
| purpose: purpose, | |
| createdAt: new Date().toISOString() | |
| }; | |
| // Add to bookings array | |
| state.bookings.push(newBooking); | |
| saveBookings(); | |
| // Reset form and show success message | |
| bookingForm.classList.add('hidden'); | |
| bookingPurpose.value = ''; | |
| state.selectedDate = null; | |
| state.selectedTime = null; | |
| showToast('Booking confirmed successfully!'); | |
| // Refresh calendar and bookings list | |
| renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id); | |
| renderUserBookings(); | |
| } | |
| function editBooking(booking) { | |
| // For simplicity, we'll just allow canceling and creating a new booking | |
| // In a real app, you would have a proper edit form | |
| state.selectedDate = new Date(booking.date); | |
| state.selectedTime = booking.time; | |
| bookingPurpose.value = booking.purpose; | |
| // Format date for display | |
| const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; | |
| bookingDate.value = state.selectedDate.toLocaleDateString('en-US', options); | |
| bookingTime.value = state.selectedTime; | |
| // Show booking form | |
| bookingForm.classList.remove('hidden'); | |
| // Scroll to form | |
| bookingForm.scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| function cancelBooking(bookingId) { | |
| if (confirm('Are you sure you want to cancel this booking?')) { | |
| state.bookings = state.bookings.filter(booking => booking.id !== bookingId); | |
| saveBookings(); | |
| showToast('Booking canceled successfully'); | |
| // Refresh calendar and bookings list | |
| renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id); | |
| renderUserBookings(); | |
| } | |
| } | |
| // Auth functions | |
| function handleLogin(e) { | |
| e.preventDefault(); | |
| const email = loginEmail.value.trim(); | |
| const password = loginPassword.value.trim(); | |
| // Simple validation | |
| if (!email || !password) { | |
| showToast('Please enter both email and password'); | |
| return; | |
| } | |
| // Check if it's a Gmail account | |
| if (!email.endsWith('@gmail.com')) { | |
| showToast('Please use a Gmail account to login'); | |
| return; | |
| } | |
| // For demo purposes, any password works | |
| state.currentUser = { | |
| id: generateId(), | |
| email: email, | |
| name: email.split('@')[0] | |
| }; | |
| // Save to localStorage if "Remember me" is checked | |
| if (document.getElementById('remember-me').checked) { | |
| localStorage.setItem('currentUser', JSON.stringify(state.currentUser)); | |
| } | |
| // Hide login page | |
| loginPage.classList.add('hidden'); | |
| // Show success message | |
| showToast('Login successful!'); | |
| // Update UI | |
| logoutContainer.classList.remove('hidden'); | |
| // If there was a redirect, go to that page | |
| if (state.loginRedirect) { | |
| state.loginRedirect(); | |
| state.loginRedirect = null; | |
| } else { | |
| // Otherwise refresh current page | |
| if (state.currentPage === 'room-details') { | |
| renderRoomDetails(); | |
| } | |
| } | |
| } | |
| function handleGoogleLogin() { | |
| // Simulate Google login | |
| state.currentUser = { | |
| id: generateId(), | |
| email: 'demo@gmail.com', | |
| name: 'Demo User' | |
| }; | |
| // Save to localStorage | |
| localStorage.setItem('currentUser', JSON.stringify(state.currentUser)); | |
| // Hide login page | |
| loginPage.classList.add('hidden'); | |
| // Show success message | |
| showToast('Google login successful!'); | |
| // Update UI | |
| logoutContainer.classList.remove('hidden'); | |
| // If there was a redirect, go to that page | |
| if (state.loginRedirect) { | |
| state.loginRedirect(); | |
| state.loginRedirect = null; | |
| } else { | |
| // Otherwise refresh current page | |
| if (state.currentPage === 'room-details') { | |
| renderRoomDetails(); | |
| } | |
| } | |
| } | |
| function handleLogout() { | |
| if (confirm('Are you sure you want to log out?')) { | |
| state.currentUser = null; | |
| localStorage.removeItem('currentUser'); | |
| logoutContainer.classList.add('hidden'); | |
| showToast('Logout complete.'); | |
| // If on room details page, refresh to update UI | |
| if (state.currentPage === 'room-details') { | |
| renderRoomDetails(); | |
| } | |
| } | |
| } | |
| function promptLoginIfNeeded(action) { | |
| if (!state.currentUser) { | |
| state.loginRedirect = action; | |
| loginPage.classList.remove('hidden'); | |
| } else { | |
| action(); | |
| } | |
| } | |
| // Helper functions | |
| function getSpacesForType(type) { | |
| switch (type) { | |
| case 'fields': | |
| return [ | |
| { id: 'field1', name: 'Main Sports Field', description: 'Grass field suitable for soccer, rugby, and other field sports', icon: 'fas fa-futbol', capacity: '100 people', type: 'Outdoor Field', image: 'https://via.placeholder.com/800x400?text=Main+Sports+Field' }, | |
| { id: 'field2', name: 'Secondary Field', description: 'Smaller grass field for practice sessions', icon: 'fas fa-running', capacity: '50 people', type: 'Outdoor Field', image: 'https://via.placeholder.com/800x400?text=Secondary+Field' } | |
| ]; | |
| case 'classrooms': | |
| return [ | |
| { id: 'b-block', name: 'B Block', description: 'Classrooms B1-B5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=B+Block' }, | |
| { id: 'c-block', name: 'C Block', description: 'Classrooms C1-C5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=C+Block' }, | |
| { id: 'd-block', name: 'D Block', description: 'Classrooms D1-D5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=D+Block' }, | |
| { id: 'e-block', name: 'E Block', description: 'Classrooms E1-E3', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=E+Block' }, | |
| { id: 'f-block', name: 'F Block', description: 'F1 (Library), F2 (MPR), F3-F4', icon: 'fas fa-book', capacity: 'Varies', type: 'Mixed Use', image: 'https://via.placeholder.com/800x400?text=F+Block' }, | |
| { id: 'i-block', name: 'I Block', description: 'Upper and Down classrooms', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=I+Block' }, | |
| { id: 'j-block', name: 'J Block', description: 'Upper and Down classrooms', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=J+Block' }, | |
| { id: 's-block', name: 'S Block', description: 'Classrooms S1-S3', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=S+Block' }, | |
| { id: 't-block', name: 'T Block', description: 'Classrooms T1-T7', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=T+Block' } | |
| ]; | |
| case 'mpr-library': | |
| return [ | |
| { id: 'mpr', name: 'Multi-Purpose Room', description: 'Large space for events, presentations, and gatherings', icon: 'fas fa-users', capacity: '100 people', type: 'Event Space', image: 'https://via.placeholder.com/800x400?text=Multi-Purpose+Room' }, | |
| { id: 'library', name: 'Library', description: 'School library with study spaces', icon: 'fas fa-book-reader', capacity: '50 people', type: 'Study Space', image: 'https://via.placeholder.com/800x400?text=Library' } | |
| ]; | |
| case 'courts': | |
| return [ | |
| { id: 'basketball1', name: 'Basketball Court 1', description: 'Main basketball court with bleachers', icon: 'fas fa-basketball-ball', capacity: '30 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Basketball+Court+1' }, | |
| { id: 'basketball2', name: 'Basketball Court 2', description: 'Secondary basketball court', icon: 'fas fa-basketball-ball', capacity: '30 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Basketball+Court+2' }, | |
| { id: 'tennis', name: 'Tennis Court', description: 'Outdoor tennis court', icon: 'fas fa-table-tennis', capacity: '4 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Tennis+Court' } | |
| ]; | |
| default: | |
| return []; | |
| } | |
| } | |
| function getSpaceById(id) { | |
| const spaces = getSpacesForType(state.currentSpaceType); | |
| return spaces.find(space => space.id === id); | |
| } | |
| function saveBookings() { | |
| localStorage.setItem('bookings', JSON.stringify(state.bookings)); | |
| } | |
| function generateId() { | |
| return Math.random().toString(36).substr(2, 9); | |
| } | |
| function showToast(message) { | |
| toastMessage.textContent = message; | |
| toast.classList.remove('hidden'); | |
| setTimeout(() => { | |
| toast.classList.add('hidden'); | |
| }, 3000); | |
| } | |
| // Initialize the app when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', init); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=davphi17/freespace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |