undefined - Initial Deployment
Browse filesFiles changed (2)
- README.md+7-5
- index.html+996-19
12345678910---title: Freespaceemoji: 🚀colorFrom: pinkcolorTo: pinksdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: freespaceemoji: 🐳colorFrom: greencolorTo: purplesdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996<!DOCTYPE html><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 managementconst 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 Elementsconst 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 appfunction init() {// Check if user is logged in from localStorageconst savedUser = localStorage.getItem('currentUser');if (savedUser) {state.currentUser = JSON.parse(savedUser);logoutContainer.classList.remove('hidden');}// Set up event listenershomeLink.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 defaultshowPage('homepage');}// Page navigation functionsfunction showPage(pageId) {pages.forEach(page => {if (page.id === pageId) {page.classList.remove('hidden');state.currentPage = pageId;} else {page.classList.add('hidden');}});// Update navigation buttonsif (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 visibilityif (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 typelet 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 functionsfunction renderSpaceSelection() {spaceContent.innerHTML = '';// Get spaces based on current space typeconst 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 buttonsdocument.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 displayconst monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];roomCurrentMonth.textContent = `${monthNames[state.currentMonth]} ${state.currentYear}`;// Render calendarrenderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id);// Show user's bookings if logged inif (state.currentUser) {myBookingsSection.classList.remove('hidden');renderUserBookings();} else {myBookingsSection.classList.add('hidden');}// Clear time slots and booking formtimeSlots.innerHTML = '';bookingForm.classList.add('hidden');}function renderCalendar(container, year, month, roomId) {container.innerHTML = '';// Add day headersconst 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 daysconst firstDay = new Date(year, month, 1).getDay();const daysInMonth = new Date(year, month + 1, 0).getDate();// Add empty cells for days before first dayfor (let i = 0; i < firstDay; i++) {const emptyCell = document.createElement('div');emptyCell.className = 'h-10';container.appendChild(emptyCell);}// Add day cellsconst 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 aheadconst 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 bookedconst 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 daysif (!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 displayconst 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 slotsdocument.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 slottimeSlot.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 formbookingForm.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 buttonsdocument.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 functionsfunction 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 bookingconst 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 arraystate.bookings.push(newBooking);saveBookings();// Reset form and show success messagebookingForm.classList.add('hidden');bookingPurpose.value = '';state.selectedDate = null;state.selectedTime = null;showToast('Booking confirmed successfully!');// Refresh calendar and bookings listrenderCalendar(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 formstate.selectedDate = new Date(booking.date);state.selectedTime = booking.time;bookingPurpose.value = booking.purpose;// Format date for displayconst options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };bookingDate.value = state.selectedDate.toLocaleDateString('en-US', options);bookingTime.value = state.selectedTime;// Show booking formbookingForm.classList.remove('hidden');// Scroll to formbookingForm.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 listrenderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id);renderUserBookings();}}// Auth functionsfunction handleLogin(e) {e.preventDefault();const email = loginEmail.value.trim();const password = loginPassword.value.trim();// Simple validationif (!email || !password) {showToast('Please enter both email and password');return;}// Check if it's a Gmail accountif (!email.endsWith('@gmail.com')) {showToast('Please use a Gmail account to login');return;}// For demo purposes, any password worksstate.currentUser = {id: generateId(),email: email,name: email.split('@')[0]};// Save to localStorage if "Remember me" is checkedif (document.getElementById('remember-me').checked) {localStorage.setItem('currentUser', JSON.stringify(state.currentUser));}// Hide login pageloginPage.classList.add('hidden');// Show success messageshowToast('Login successful!');// Update UIlogoutContainer.classList.remove('hidden');// If there was a redirect, go to that pageif (state.loginRedirect) {state.loginRedirect();state.loginRedirect = null;} else {// Otherwise refresh current pageif (state.currentPage === 'room-details') {renderRoomDetails();}}}function handleGoogleLogin() {// Simulate Google loginstate.currentUser = {id: generateId(),email: 'demo@gmail.com',name: 'Demo User'};// Save to localStoragelocalStorage.setItem('currentUser', JSON.stringify(state.currentUser));// Hide login pageloginPage.classList.add('hidden');// Show success messageshowToast('Google login successful!');// Update UIlogoutContainer.classList.remove('hidden');// If there was a redirect, go to that pageif (state.loginRedirect) {state.loginRedirect();state.loginRedirect = null;} else {// Otherwise refresh current pageif (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 UIif (state.currentPage === 'room-details') {renderRoomDetails();}}}function promptLoginIfNeeded(action) {if (!state.currentUser) {state.loginRedirect = action;loginPage.classList.remove('hidden');} else {action();}}// Helper functionsfunction 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 loadeddocument.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>
README.md+7-5
index.html+996-19