Spaces:
Running
Running
Develop a React-based interactive web application that visualizes a 24-hour daily schedule using a circular radial timeline. The timeline acts as a full-day planner where users can view, add, modify, and delete events directly on a clock-like circular interface. Tech Stack: React (TypeScript) SVG or Canvas for rendering the circular timeline TailwindCSS or styled-components for styling Framer Motion for smooth transitions Optional: Zustand or Redux for state management Core Functional Requirements: Circular Time Representation: SVG-based full circle representing 24 hours. Tick marks at each hour; minor ticks for 15/30 min intervals. Time starts at top center (00:00), proceeds clockwise. Schedule Display: Activities visualized as colored arc segments along the circle. Each segment: start time, end time, activity label. Color-coded by category: Sleep, Routine, Work, Meals, Exercise, Custom. Interactivity: Hover on a segment: tooltip with full info. Click: open modal for edit/delete. Click empty space: add new event (start and duration picker). Drag start/end handles to adjust duration live. Drag segment to shift time. Center Display: Shows date (e.g., “Tuesday”) and summary info (e.g., total planned hours). Central "Add Task" button opens time/category input modal. UX/UI Enhancements: Smooth transitions on interaction (Framer Motion). Responsive for mobile and desktop views. Custom themes (dark/light mode). Data Features: Save/load from localStorage or backend. Export to image (PNG) or printable format. Sync with Google Calendar or ICS. Structure Example (TypeScript + React): type ScheduleEntry = { id: string; label: string; start: number; // in hours (e.g., 22.5 for 10:30 PM) end: number; color: string; }; Component Outline: CircularTimeline.tsx – renders the SVG-based timeline. ScheduleSegment.tsx – visual arc for one activity. ScheduleEditorModal.tsx – add/edit UI. useScheduleStore.ts – state logic. Goal: An aesthetically clean, tactile circular scheduler that’s intuitive for managing daily time visually, optimized for both structured planning and spontaneous editing. - Initial Deployment
Browse files- README.md +6 -4
- index.html +630 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: purple
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: calender
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: green
|
5 |
colorTo: purple
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,630 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Circular Daily Scheduler</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
9 |
+
<style>
|
10 |
+
.circle-container {
|
11 |
+
position: relative;
|
12 |
+
width: 100%;
|
13 |
+
max-width: 600px;
|
14 |
+
aspect-ratio: 1/1;
|
15 |
+
margin: 0 auto;
|
16 |
+
}
|
17 |
+
|
18 |
+
.time-tick {
|
19 |
+
position: absolute;
|
20 |
+
width: 2px;
|
21 |
+
height: 12px;
|
22 |
+
background-color: #64748b;
|
23 |
+
transform-origin: bottom center;
|
24 |
+
}
|
25 |
+
|
26 |
+
.time-tick.minor {
|
27 |
+
height: 6px;
|
28 |
+
background-color: #94a3b8;
|
29 |
+
}
|
30 |
+
|
31 |
+
.time-label {
|
32 |
+
position: absolute;
|
33 |
+
font-size: 0.8rem;
|
34 |
+
color: #64748b;
|
35 |
+
transform: translate(-50%, -50%);
|
36 |
+
}
|
37 |
+
|
38 |
+
.segment {
|
39 |
+
position: absolute;
|
40 |
+
width: 100%;
|
41 |
+
height: 100%;
|
42 |
+
clip-path: circle(50% at 50% 50%);
|
43 |
+
}
|
44 |
+
|
45 |
+
.segment-arc {
|
46 |
+
position: absolute;
|
47 |
+
width: 100%;
|
48 |
+
height: 100%;
|
49 |
+
border-radius: 50%;
|
50 |
+
clip-path: polygon(50% 50%, 50% 0%, 100% 0%, 100% 100%, 50% 100%);
|
51 |
+
opacity: 0.7;
|
52 |
+
transition: opacity 0.2s;
|
53 |
+
}
|
54 |
+
|
55 |
+
.segment-arc:hover {
|
56 |
+
opacity: 0.9;
|
57 |
+
}
|
58 |
+
|
59 |
+
.segment-handle {
|
60 |
+
position: absolute;
|
61 |
+
width: 12px;
|
62 |
+
height: 12px;
|
63 |
+
border-radius: 50%;
|
64 |
+
background-color: white;
|
65 |
+
border: 2px solid #334155;
|
66 |
+
cursor: pointer;
|
67 |
+
z-index: 10;
|
68 |
+
}
|
69 |
+
|
70 |
+
.segment-label {
|
71 |
+
position: absolute;
|
72 |
+
font-size: 0.7rem;
|
73 |
+
font-weight: 500;
|
74 |
+
color: white;
|
75 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
|
76 |
+
pointer-events: none;
|
77 |
+
transform-origin: center;
|
78 |
+
}
|
79 |
+
|
80 |
+
.dark .segment-label {
|
81 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.8);
|
82 |
+
}
|
83 |
+
|
84 |
+
@media (max-width: 640px) {
|
85 |
+
.segment-label {
|
86 |
+
font-size: 0.6rem;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
</style>
|
90 |
+
</head>
|
91 |
+
<body class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 transition-colors duration-200 min-h-screen">
|
92 |
+
<div class="container mx-auto px-4 py-8">
|
93 |
+
<header class="flex justify-between items-center mb-8">
|
94 |
+
<h1 class="text-3xl font-bold">Circular Scheduler</h1>
|
95 |
+
<div class="flex items-center space-x-4">
|
96 |
+
<button id="theme-toggle" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700">
|
97 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
98 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
|
99 |
+
</svg>
|
100 |
+
</button>
|
101 |
+
<button id="add-event" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center">
|
102 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
|
103 |
+
<path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd" />
|
104 |
+
</svg>
|
105 |
+
Add Event
|
106 |
+
</button>
|
107 |
+
</div>
|
108 |
+
</header>
|
109 |
+
|
110 |
+
<div class="flex flex-col lg:flex-row gap-8">
|
111 |
+
<div class="lg:w-2/3">
|
112 |
+
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6">
|
113 |
+
<div class="flex justify-between items-center mb-6">
|
114 |
+
<h2 class="text-xl font-semibold">Daily Schedule</h2>
|
115 |
+
<div class="text-sm">
|
116 |
+
<span id="current-date" class="font-medium"></span>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="circle-container">
|
121 |
+
<div id="timeline-circle" class="segment">
|
122 |
+
<!-- Time ticks will be added here by JS -->
|
123 |
+
</div>
|
124 |
+
<div id="segments-container" class="segment">
|
125 |
+
<!-- Event segments will be added here by JS -->
|
126 |
+
</div>
|
127 |
+
<div id="center-info" class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-gray-800 rounded-full w-32 h-32 flex flex-col items-center justify-center shadow-inner border border-gray-200 dark:border-gray-700">
|
128 |
+
<div id="day-name" class="text-lg font-bold"></div>
|
129 |
+
<div id="total-hours" class="text-sm text-gray-500 dark:text-gray-400 mt-1"></div>
|
130 |
+
<button id="add-center" class="mt-2 bg-blue-600 hover:bg-blue-700 text-white text-xs px-3 py-1 rounded-full">
|
131 |
+
Add Event
|
132 |
+
</button>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
|
138 |
+
<div class="lg:w-1/3">
|
139 |
+
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 h-full">
|
140 |
+
<h2 class="text-xl font-semibold mb-4">Today's Events</h2>
|
141 |
+
<div id="events-list" class="space-y-3">
|
142 |
+
<!-- Events will be listed here -->
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
<!-- Event Modal -->
|
150 |
+
<div id="event-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
151 |
+
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-xl p-6 w-full max-w-md">
|
152 |
+
<div class="flex justify-between items-center mb-4">
|
153 |
+
<h3 class="text-xl font-semibold" id="modal-title">Add New Event</h3>
|
154 |
+
<button id="close-modal" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
|
155 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
156 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
157 |
+
</svg>
|
158 |
+
</button>
|
159 |
+
</div>
|
160 |
+
|
161 |
+
<form id="event-form" class="space-y-4">
|
162 |
+
<input type="hidden" id="event-id">
|
163 |
+
<div>
|
164 |
+
<label for="event-name" class="block text-sm font-medium mb-1">Event Name</label>
|
165 |
+
<input type="text" id="event-name" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700">
|
166 |
+
</div>
|
167 |
+
|
168 |
+
<div class="grid grid-cols-2 gap-4">
|
169 |
+
<div>
|
170 |
+
<label for="start-time" class="block text-sm font-medium mb-1">Start Time</label>
|
171 |
+
<input type="time" id="start-time" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700">
|
172 |
+
</div>
|
173 |
+
<div>
|
174 |
+
<label for="end-time" class="block text-sm font-medium mb-1">End Time</label>
|
175 |
+
<input type="time" id="end-time" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700">
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
+
|
179 |
+
<div>
|
180 |
+
<label for="event-category" class="block text-sm font-medium mb-1">Category</label>
|
181 |
+
<select id="event-category" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700">
|
182 |
+
<option value="sleep">Sleep</option>
|
183 |
+
<option value="routine">Routine</option>
|
184 |
+
<option value="work">Work</option>
|
185 |
+
<option value="meals">Meals</option>
|
186 |
+
<option value="exercise">Exercise</option>
|
187 |
+
<option value="custom">Custom</option>
|
188 |
+
</select>
|
189 |
+
</div>
|
190 |
+
|
191 |
+
<div class="flex justify-end space-x-3 pt-4">
|
192 |
+
<button type="button" id="delete-event" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg hidden">Delete</button>
|
193 |
+
<button type="button" id="cancel-event" class="px-4 py-2 border border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg">Cancel</button>
|
194 |
+
<button type="submit" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">Save</button>
|
195 |
+
</div>
|
196 |
+
</form>
|
197 |
+
</div>
|
198 |
+
</div>
|
199 |
+
|
200 |
+
<script>
|
201 |
+
// Initialize theme
|
202 |
+
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
203 |
+
document.documentElement.classList.add('dark');
|
204 |
+
} else {
|
205 |
+
document.documentElement.classList.remove('dark');
|
206 |
+
}
|
207 |
+
|
208 |
+
// Theme toggle
|
209 |
+
document.getElementById('theme-toggle').addEventListener('click', function() {
|
210 |
+
if (localStorage.getItem('color-theme')) {
|
211 |
+
if (localStorage.getItem('color-theme') === 'light') {
|
212 |
+
document.documentElement.classList.add('dark');
|
213 |
+
localStorage.setItem('color-theme', 'dark');
|
214 |
+
} else {
|
215 |
+
document.documentElement.classList.remove('dark');
|
216 |
+
localStorage.setItem('color-theme', 'light');
|
217 |
+
}
|
218 |
+
} else {
|
219 |
+
if (document.documentElement.classList.contains('dark')) {
|
220 |
+
document.documentElement.classList.remove('dark');
|
221 |
+
localStorage.setItem('color-theme', 'light');
|
222 |
+
} else {
|
223 |
+
document.documentElement.classList.add('dark');
|
224 |
+
localStorage.setItem('color-theme', 'dark');
|
225 |
+
}
|
226 |
+
}
|
227 |
+
});
|
228 |
+
|
229 |
+
// Current date display
|
230 |
+
const now = new Date();
|
231 |
+
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
232 |
+
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
233 |
+
|
234 |
+
document.getElementById('current-date').textContent = `${days[now.getDay()]}, ${months[now.getMonth()]} ${now.getDate()}, ${now.getFullYear()}`;
|
235 |
+
document.getElementById('day-name').textContent = days[now.getDay()];
|
236 |
+
|
237 |
+
// Event categories and colors
|
238 |
+
const categories = {
|
239 |
+
sleep: { name: 'Sleep', color: '#3b82f6', darkColor: '#1d4ed8' },
|
240 |
+
routine: { name: 'Routine', color: '#10b981', darkColor: '#047857' },
|
241 |
+
work: { name: 'Work', color: '#f59e0b', darkColor: '#b45309' },
|
242 |
+
meals: { name: 'Meals', color: '#ef4444', darkColor: '#b91c1c' },
|
243 |
+
exercise: { name: 'Exercise', color: '#8b5cf6', darkColor: '#7e22ce' },
|
244 |
+
custom: { name: 'Custom', color: '#64748b', darkColor: '#475569' }
|
245 |
+
};
|
246 |
+
|
247 |
+
// Sample events data
|
248 |
+
let events = JSON.parse(localStorage.getItem('circular-scheduler-events')) || [
|
249 |
+
{ id: '1', label: 'Sleep', start: 0, end: 7, category: 'sleep' },
|
250 |
+
{ id: '2', label: 'Breakfast', start: 7, end: 7.5, category: 'meals' },
|
251 |
+
{ id: '3', label: 'Work', start: 8, end: 12, category: 'work' },
|
252 |
+
{ id: '4', label: 'Lunch', start: 12, end: 13, category: 'meals' },
|
253 |
+
{ id: '5', label: 'Work', start: 13, end: 17, category: 'work' },
|
254 |
+
{ id: '6', label: 'Exercise', start: 17.5, end: 18.5, category: 'exercise' },
|
255 |
+
{ id: '7', label: 'Dinner', start: 19, end: 20, category: 'meals' },
|
256 |
+
{ id: '8', label: 'Relax', start: 20, end: 22, category: 'routine' },
|
257 |
+
{ id: '9', label: 'Sleep', start: 22, end: 24, category: 'sleep' }
|
258 |
+
];
|
259 |
+
|
260 |
+
// Save events to localStorage
|
261 |
+
function saveEvents() {
|
262 |
+
localStorage.setItem('circular-scheduler-events', JSON.stringify(events));
|
263 |
+
}
|
264 |
+
|
265 |
+
// Generate unique ID
|
266 |
+
function generateId() {
|
267 |
+
return Math.random().toString(36).substr(2, 9);
|
268 |
+
}
|
269 |
+
|
270 |
+
// Convert time string (HH:MM) to decimal hours
|
271 |
+
function timeToDecimal(time) {
|
272 |
+
const [hours, minutes] = time.split(':').map(Number);
|
273 |
+
return hours + minutes / 60;
|
274 |
+
}
|
275 |
+
|
276 |
+
// Convert decimal hours to time string (HH:MM)
|
277 |
+
function decimalToTime(decimal) {
|
278 |
+
const hours = Math.floor(decimal);
|
279 |
+
const minutes = Math.round((decimal - hours) * 60);
|
280 |
+
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
281 |
+
}
|
282 |
+
|
283 |
+
// Draw the circular timeline
|
284 |
+
function drawTimeline() {
|
285 |
+
const container = document.getElementById('timeline-circle');
|
286 |
+
container.innerHTML = '';
|
287 |
+
|
288 |
+
// Draw hour ticks
|
289 |
+
for (let i = 0; i < 24; i++) {
|
290 |
+
// Major tick (hour)
|
291 |
+
const tick = document.createElement('div');
|
292 |
+
tick.className = 'time-tick';
|
293 |
+
tick.style.transform = `rotate(${i * 15}deg) translateY(-50%)`;
|
294 |
+
tick.style.left = '50%';
|
295 |
+
tick.style.top = '0';
|
296 |
+
container.appendChild(tick);
|
297 |
+
|
298 |
+
// Hour label
|
299 |
+
const label = document.createElement('div');
|
300 |
+
label.className = 'time-label';
|
301 |
+
label.textContent = i === 0 ? '12 AM' : i < 12 ? `${i} AM` : i === 12 ? '12 PM' : `${i - 12} PM`;
|
302 |
+
|
303 |
+
// Position label
|
304 |
+
const angle = i * 15;
|
305 |
+
const radius = 45;
|
306 |
+
const x = 50 + radius * Math.sin(angle * Math.PI / 180);
|
307 |
+
const y = 50 - radius * Math.cos(angle * Math.PI / 180);
|
308 |
+
|
309 |
+
label.style.left = `${x}%`;
|
310 |
+
label.style.top = `${y}%`;
|
311 |
+
container.appendChild(label);
|
312 |
+
|
313 |
+
// Minor ticks (15 and 45 minutes)
|
314 |
+
for (let j = 1; j < 4; j++) {
|
315 |
+
const minorTick = document.createElement('div');
|
316 |
+
minorTick.className = 'time-tick minor';
|
317 |
+
minorTick.style.transform = `rotate(${i * 15 + j * 15}deg) translateY(-50%)`;
|
318 |
+
minorTick.style.left = '50%';
|
319 |
+
minorTick.style.top = '0';
|
320 |
+
container.appendChild(minorTick);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
// Draw event segments
|
326 |
+
function drawSegments() {
|
327 |
+
const container = document.getElementById('segments-container');
|
328 |
+
container.innerHTML = '';
|
329 |
+
|
330 |
+
// Calculate total planned hours
|
331 |
+
let totalHours = 0;
|
332 |
+
|
333 |
+
events.forEach(event => {
|
334 |
+
const duration = event.end - event.start;
|
335 |
+
totalHours += duration;
|
336 |
+
|
337 |
+
const startAngle = event.start * 15;
|
338 |
+
const endAngle = event.end * 15;
|
339 |
+
const midAngle = (startAngle + endAngle) / 2;
|
340 |
+
|
341 |
+
// Create arc segment
|
342 |
+
const arc = document.createElement('div');
|
343 |
+
arc.className = 'segment-arc';
|
344 |
+
arc.style.backgroundColor = document.documentElement.classList.contains('dark')
|
345 |
+
? categories[event.category].darkColor
|
346 |
+
: categories[event.category].color;
|
347 |
+
|
348 |
+
// Position the arc
|
349 |
+
arc.style.transform = `rotate(${startAngle}deg)`;
|
350 |
+
arc.style.clipPath = `polygon(50% 50%, 50% 0%, ${startAngle < 180 ? '100%' : '0%'} 0%, ${startAngle < 180 ? '100%' : '0%'} 100%, 50% 100%)`;
|
351 |
+
arc.style.width = `${100 - (duration / 24 * 20)}%`;
|
352 |
+
arc.style.height = `${100 - (duration / 24 * 20)}%`;
|
353 |
+
arc.style.left = `${(duration / 24 * 10)}%`;
|
354 |
+
arc.style.top = `${(duration / 24 * 10)}%`;
|
355 |
+
|
356 |
+
// Add event data as attributes
|
357 |
+
arc.setAttribute('data-event-id', event.id);
|
358 |
+
|
359 |
+
// Add click handler
|
360 |
+
arc.addEventListener('click', (e) => {
|
361 |
+
e.stopPropagation();
|
362 |
+
openEditModal(event.id);
|
363 |
+
});
|
364 |
+
|
365 |
+
container.appendChild(arc);
|
366 |
+
|
367 |
+
// Add start handle
|
368 |
+
const startHandle = document.createElement('div');
|
369 |
+
startHandle.className = 'segment-handle';
|
370 |
+
startHandle.setAttribute('data-event-id', event.id);
|
371 |
+
startHandle.setAttribute('data-handle-type', 'start');
|
372 |
+
|
373 |
+
const startRadius = 45;
|
374 |
+
const startX = 50 + startRadius * Math.sin(startAngle * Math.PI / 180);
|
375 |
+
const startY = 50 - startRadius * Math.cos(startAngle * Math.PI / 180);
|
376 |
+
|
377 |
+
startHandle.style.left = `${startX}%`;
|
378 |
+
startHandle.style.top = `${startY}%`;
|
379 |
+
|
380 |
+
// Add drag functionality
|
381 |
+
makeDraggable(startHandle, 'start', event.id);
|
382 |
+
|
383 |
+
container.appendChild(startHandle);
|
384 |
+
|
385 |
+
// Add end handle
|
386 |
+
const endHandle = document.createElement('div');
|
387 |
+
endHandle.className = 'segment-handle';
|
388 |
+
endHandle.setAttribute('data-event-id', event.id);
|
389 |
+
endHandle.setAttribute('data-handle-type', 'end');
|
390 |
+
|
391 |
+
const endRadius = 45;
|
392 |
+
const endX = 50 + endRadius * Math.sin(endAngle * Math.PI / 180);
|
393 |
+
const endY = 50 - endRadius * Math.cos(endAngle * Math.PI / 180);
|
394 |
+
|
395 |
+
endHandle.style.left = `${endX}%`;
|
396 |
+
endHandle.style.top = `${endY}%`;
|
397 |
+
|
398 |
+
// Add drag functionality
|
399 |
+
makeDraggable(endHandle, 'end', event.id);
|
400 |
+
|
401 |
+
container.appendChild(endHandle);
|
402 |
+
|
403 |
+
// Add label
|
404 |
+
if (duration >= 0.5) { // Only show label if duration is at least 30 minutes
|
405 |
+
const label = document.createElement('div');
|
406 |
+
label.className = 'segment-label';
|
407 |
+
label.textContent = event.label;
|
408 |
+
label.setAttribute('data-event-id', event.id);
|
409 |
+
|
410 |
+
const labelRadius = 30;
|
411 |
+
const labelX = 50 + labelRadius * Math.sin(midAngle * Math.PI / 180);
|
412 |
+
const labelY = 50 - labelRadius * Math.cos(midAngle * Math.PI / 180);
|
413 |
+
|
414 |
+
label.style.left = `${labelX}%`;
|
415 |
+
label.style.top = `${labelY}%`;
|
416 |
+
label.style.transform = `rotate(${midAngle > 90 && midAngle < 270 ? midAngle + 180 : midAngle}deg)`;
|
417 |
+
|
418 |
+
container.appendChild(label);
|
419 |
+
}
|
420 |
+
});
|
421 |
+
|
422 |
+
// Update total hours display
|
423 |
+
document.getElementById('total-hours').textContent = `${totalHours.toFixed(1)}h planned`;
|
424 |
+
|
425 |
+
// Update events list
|
426 |
+
updateEventsList();
|
427 |
+
}
|
428 |
+
|
429 |
+
// Make handles draggable
|
430 |
+
function makeDraggable(handle, type, eventId) {
|
431 |
+
let isDragging = false;
|
432 |
+
let startX, startY;
|
433 |
+
|
434 |
+
handle.addEventListener('mousedown', (e) => {
|
435 |
+
isDragging = true;
|
436 |
+
startX = e.clientX;
|
437 |
+
startY = e.clientY;
|
438 |
+
e.preventDefault();
|
439 |
+
});
|
440 |
+
|
441 |
+
document.addEventListener('mousemove', (e) => {
|
442 |
+
if (!isDragging) return;
|
443 |
+
|
444 |
+
const container = document.querySelector('.circle-container');
|
445 |
+
const rect = container.getBoundingClientRect();
|
446 |
+
const centerX = rect.left + rect.width / 2;
|
447 |
+
const centerY = rect.top + rect.height / 2;
|
448 |
+
|
449 |
+
// Calculate angle from center to mouse position
|
450 |
+
const angle = Math.atan2(e.clientY - centerY, e.clientX - centerX) * 180 / Math.PI + 90;
|
451 |
+
const normalizedAngle = (angle + 360) % 360;
|
452 |
+
|
453 |
+
// Convert angle to time (0-24 hours)
|
454 |
+
const time = normalizedAngle / 15;
|
455 |
+
|
456 |
+
// Update the event
|
457 |
+
const eventIndex = events.findIndex(e => e.id === eventId);
|
458 |
+
if (eventIndex !== -1) {
|
459 |
+
if (type === 'start') {
|
460 |
+
// Don't allow start time to be after end time
|
461 |
+
if (time < events[eventIndex].end) {
|
462 |
+
events[eventIndex].start = Math.max(0, Math.min(24, time));
|
463 |
+
}
|
464 |
+
} else {
|
465 |
+
// Don't allow end time to be before start time
|
466 |
+
if (time > events[eventIndex].start) {
|
467 |
+
events[eventIndex].end = Math.max(0, Math.min(24, time));
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
// Redraw segments
|
472 |
+
drawSegments();
|
473 |
+
}
|
474 |
+
});
|
475 |
+
|
476 |
+
document.addEventListener('mouseup', () => {
|
477 |
+
if (isDragging) {
|
478 |
+
isDragging = false;
|
479 |
+
saveEvents();
|
480 |
+
}
|
481 |
+
});
|
482 |
+
}
|
483 |
+
|
484 |
+
// Update events list
|
485 |
+
function updateEventsList() {
|
486 |
+
const listContainer = document.getElementById('events-list');
|
487 |
+
listContainer.innerHTML = '';
|
488 |
+
|
489 |
+
// Sort events by start time
|
490 |
+
const sortedEvents = [...events].sort((a, b) => a.start - b.start);
|
491 |
+
|
492 |
+
sortedEvents.forEach(event => {
|
493 |
+
const eventElement = document.createElement('div');
|
494 |
+
eventElement.className = 'flex items-start p-3 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer';
|
495 |
+
eventElement.style.borderLeft = `4px solid ${document.documentElement.classList.contains('dark')
|
496 |
+
? categories[event.category].darkColor
|
497 |
+
: categories[event.category].color}`;
|
498 |
+
eventElement.setAttribute('data-event-id', event.id);
|
499 |
+
|
500 |
+
eventElement.innerHTML = `
|
501 |
+
<div class="flex-1">
|
502 |
+
<div class="font-medium">${event.label}</div>
|
503 |
+
<div class="text-sm text-gray-500 dark:text-gray-400">${decimalToTime(event.start)} - ${decimalToTime(event.end)}</div>
|
504 |
+
</div>
|
505 |
+
<div class="text-xs px-2 py-1 rounded-full" style="background-color: ${document.documentElement.classList.contains('dark')
|
506 |
+
? categories[event.category].darkColor
|
507 |
+
: categories[event.category].color}; color: white;">
|
508 |
+
${categories[event.category].name}
|
509 |
+
</div>
|
510 |
+
`;
|
511 |
+
|
512 |
+
eventElement.addEventListener('click', () => {
|
513 |
+
openEditModal(event.id);
|
514 |
+
});
|
515 |
+
|
516 |
+
listContainer.appendChild(eventElement);
|
517 |
+
});
|
518 |
+
}
|
519 |
+
|
520 |
+
// Modal functions
|
521 |
+
function openAddModal() {
|
522 |
+
document.getElementById('modal-title').textContent = 'Add New Event';
|
523 |
+
document.getElementById('event-id').value = '';
|
524 |
+
document.getElementById('event-name').value = '';
|
525 |
+
document.getElementById('start-time').value = '08:00';
|
526 |
+
document.getElementById('end-time').value = '09:00';
|
527 |
+
document.getElementById('event-category').value = 'work';
|
528 |
+
document.getElementById('delete-event').classList.add('hidden');
|
529 |
+
|
530 |
+
document.getElementById('event-modal').classList.remove('hidden');
|
531 |
+
document.getElementById('event-name').focus();
|
532 |
+
}
|
533 |
+
|
534 |
+
function openEditModal(eventId) {
|
535 |
+
const event = events.find(e => e.id === eventId);
|
536 |
+
if (!event) return;
|
537 |
+
|
538 |
+
document.getElementById('modal-title').textContent = 'Edit Event';
|
539 |
+
document.getElementById('event-id').value = event.id;
|
540 |
+
document.getElementById('event-name').value = event.label;
|
541 |
+
document.getElementById('start-time').value = decimalToTime(event.start);
|
542 |
+
document.getElementById('end-time').value = decimalToTime(event.end);
|
543 |
+
document.getElementById('event-category').value = event.category;
|
544 |
+
document.getElementById('delete-event').classList.remove('hidden');
|
545 |
+
|
546 |
+
document.getElementById('event-modal').classList.remove('hidden');
|
547 |
+
document.getElementById('event-name').focus();
|
548 |
+
}
|
549 |
+
|
550 |
+
function closeModal() {
|
551 |
+
document.getElementById('event-modal').classList.add('hidden');
|
552 |
+
}
|
553 |
+
|
554 |
+
// Event handlers
|
555 |
+
document.getElementById('add-event').addEventListener('click', openAddModal);
|
556 |
+
document.getElementById('add-center').addEventListener('click', openAddModal);
|
557 |
+
document.getElementById('close-modal').addEventListener('click', closeModal);
|
558 |
+
document.getElementById('cancel-event').addEventListener('click', closeModal);
|
559 |
+
|
560 |
+
document.getElementById('delete-event').addEventListener('click', function() {
|
561 |
+
const eventId = document.getElementById('event-id').value;
|
562 |
+
events = events.filter(e => e.id !== eventId);
|
563 |
+
saveEvents();
|
564 |
+
drawSegments();
|
565 |
+
closeModal();
|
566 |
+
});
|
567 |
+
|
568 |
+
document.getElementById('event-form').addEventListener('submit', function(e) {
|
569 |
+
e.preventDefault();
|
570 |
+
|
571 |
+
const eventId = document.getElementById('event-id').value;
|
572 |
+
const label = document.getElementById('event-name').value.trim();
|
573 |
+
const startTime = document.getElementById('start-time').value;
|
574 |
+
const endTime = document.getElementById('end-time').value;
|
575 |
+
const category = document.getElementById('event-category').value;
|
576 |
+
|
577 |
+
if (!label) {
|
578 |
+
Swal.fire('Error', 'Please enter an event name', 'error');
|
579 |
+
return;
|
580 |
+
}
|
581 |
+
|
582 |
+
const start = timeToDecimal(startTime);
|
583 |
+
const end = timeToDecimal(endTime);
|
584 |
+
|
585 |
+
if (start >= end) {
|
586 |
+
Swal.fire('Error', 'End time must be after start time', 'error');
|
587 |
+
return;
|
588 |
+
}
|
589 |
+
|
590 |
+
if (eventId) {
|
591 |
+
// Update existing event
|
592 |
+
const eventIndex = events.findIndex(e => e.id === eventId);
|
593 |
+
if (eventIndex !== -1) {
|
594 |
+
events[eventIndex] = {
|
595 |
+
id: eventId,
|
596 |
+
label,
|
597 |
+
start,
|
598 |
+
end,
|
599 |
+
category
|
600 |
+
};
|
601 |
+
}
|
602 |
+
} else {
|
603 |
+
// Add new event
|
604 |
+
events.push({
|
605 |
+
id: generateId(),
|
606 |
+
label,
|
607 |
+
start,
|
608 |
+
end,
|
609 |
+
category
|
610 |
+
});
|
611 |
+
}
|
612 |
+
|
613 |
+
saveEvents();
|
614 |
+
drawSegments();
|
615 |
+
closeModal();
|
616 |
+
});
|
617 |
+
|
618 |
+
// Click on empty space to add event
|
619 |
+
document.getElementById('segments-container').addEventListener('click', function(e) {
|
620 |
+
if (e.target === this) {
|
621 |
+
openAddModal();
|
622 |
+
}
|
623 |
+
});
|
624 |
+
|
625 |
+
// Initialize
|
626 |
+
drawTimeline();
|
627 |
+
drawSegments();
|
628 |
+
</script>
|
629 |
+
<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=triton7777/calender" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
630 |
+
</html>
|