File size: 29,457 Bytes
fe0367e
 
 
 
 
e04a7ac
fe0367e
e04a7ac
 
fe0367e
e04a7ac
 
 
 
fe0367e
e04a7ac
 
fe0367e
e04a7ac
 
 
fe0367e
e04a7ac
 
fe0367e
e04a7ac
 
 
fe0367e
e04a7ac
 
fe0367e
e04a7ac
 
 
fe0367e
 
 
e04a7ac
fe0367e
e04a7ac
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
fe0367e
 
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
 
fe0367e
e04a7ac
 
 
1874386
e04a7ac
 
 
 
 
 
 
 
1874386
e04a7ac
 
 
 
 
 
1874386
 
e04a7ac
 
 
 
 
 
 
 
 
1874386
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
1874386
fe0367e
e04a7ac
 
fe0367e
e04a7ac
 
 
fe0367e
 
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
fe0367e
 
e04a7ac
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
 
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1874386
e04a7ac
1874386
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1874386
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1874386
e04a7ac
 
fe0367e
 
e04a7ac
 
 
fe0367e
e04a7ac
 
 
 
 
 
 
 
1874386
e04a7ac
 
 
 
 
 
 
 
 
 
 
 
 
 
fe0367e
e04a7ac
 
 
 
 
fe0367e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home โ†” Work Commute Tracker</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">
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>
    <style>
        .map-container {
            height: 400px;
            width: 100%;
            border-radius: 0.75rem;
        }
        .transport-card {
            transition: all 0.3s ease;
        }
        .transport-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .loading-spinner {
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .slide-in {
            animation: slideIn 0.5s forwards;
        }
        @keyframes slideIn {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-8 text-center">
            <h1 class="text-3xl md:text-4xl font-bold text-blue-600 mb-2">Home โ†” Work Commute Tracker</h1>
            <p class="text-gray-600">์‹ค์‹œ๊ฐ„์œผ๋กœ ์ง‘๊ณผ ํšŒ์‚ฌ ์‚ฌ์ด์˜ ์ตœ์ ์˜ ์ด๋™ ๊ฒฝ๋กœ๋ฅผ ํ™•์ธํ•˜์„ธ์š”</p>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Location Input Section -->
            <div class="lg:col-span-1 bg-white rounded-xl shadow-md p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">์œ„์น˜ ์„ค์ •</h2>
                
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1" for="home-location">์ง‘ ์œ„์น˜</label>
                        <div class="flex">
                            <input type="text" id="home-location" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="์ง‘ ์ฃผ์†Œ ์ž…๋ ฅ">
                            <button id="home-current" class="bg-gray-100 px-3 py-2 border border-gray-300 rounded-r-md hover:bg-gray-200">
                                <i class="fas fa-location-arrow"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1" for="work-location">ํšŒ์‚ฌ ์œ„์น˜</label>
                        <div class="flex">
                            <input type="text" id="work-location" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="ํšŒ์‚ฌ ์ฃผ์†Œ ์ž…๋ ฅ">
                            <button id="work-current" class="bg-gray-100 px-3 py-2 border border-gray-300 rounded-r-md hover:bg-gray-200">
                                <i class="fas fa-location-arrow"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="pt-2">
                        <button id="save-locations" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition duration-300">
                            ์œ„์น˜ ์ €์žฅํ•˜๊ธฐ
                        </button>
                    </div>
                </div>
                
                <div class="mt-6 pt-4 border-t border-gray-200">
                    <h3 class="text-lg font-medium text-gray-800 mb-3">์ €์žฅ๋œ ์œ„์น˜</h3>
                    <div id="saved-locations" class="space-y-2">
                        <div class="text-gray-500 italic">์œ„์น˜๋ฅผ ์ €์žฅํ•ด์ฃผ์„ธ์š”</div>
                    </div>
                </div>
            </div>
            
            <!-- Map and Results Section -->
            <div class="lg:col-span-2 space-y-6">
                <!-- Map Container -->
                <div class="bg-white rounded-xl shadow-md p-4">
                    <h2 class="text-xl font-semibold mb-4 text-gray-800">๊ฒฝ๋กœ ์ง€๋„</h2>
                    <div id="map" class="map-container bg-gray-100 flex items-center justify-center">
                        <div class="text-center text-gray-500">
                            <i class="fas fa-map-marked-alt text-4xl mb-2"></i>
                            <p>์œ„์น˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ง€๋„๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค</p>
                        </div>
                    </div>
                </div>
                
                <!-- Transportation Options -->
                <div class="bg-white rounded-xl shadow-md p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="text-xl font-semibold text-gray-800">์ด๋™ ์˜ต์…˜</h2>
                        <div class="flex space-x-2">
                            <button id="refresh-btn" class="bg-gray-100 p-2 rounded-full hover:bg-gray-200">
                                <i class="fas fa-sync-alt"></i>
                            </button>
                            <div class="relative">
                                <button id="direction-btn" class="bg-gray-100 px-3 py-1 rounded-md hover:bg-gray-200 flex items-center">
                                    <span id="direction-text">์ง‘ โ†’ ํšŒ์‚ฌ</span>
                                    <i class="fas fa-chevron-down ml-2 text-sm"></i>
                                </button>
                                <div id="direction-dropdown" class="hidden absolute right-0 mt-1 w-40 bg-white rounded-md shadow-lg z-10">
                                    <a href="#" class="direction-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-direction="home-work">์ง‘ โ†’ ํšŒ์‚ฌ</a>
                                    <a href="#" class="direction-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-direction="work-home">ํšŒ์‚ฌ โ†’ ์ง‘</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div id="transport-results">
                        <div class="text-center py-10">
                            <div class="inline-block p-4 bg-blue-50 rounded-full mb-3">
                                <i class="fas fa-bus text-blue-500 text-2xl"></i>
                            </div>
                            <h3 class="text-lg font-medium text-gray-700 mb-1">์ด๋™ ์˜ต์…˜์„ ํ™•์ธํ•ด๋ณด์„ธ์š”</h3>
                            <p class="text-gray-500 text-sm">์œ„์น˜๋ฅผ ์ €์žฅํ•œ ํ›„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค</p>
                        </div>
                    </div>
                    
                    <div id="loading" class="hidden text-center py-10">
                        <div class="inline-block p-4">
                            <i class="fas fa-circle-notch loading-spinner text-blue-500 text-2xl"></i>
                        </div>
                        <p class="text-gray-500 mt-2">์ด๋™ ์˜ต์…˜์„ ๊ฒ€์ƒ‰ ์ค‘์ž…๋‹ˆ๋‹ค...</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            initMap();
            // UI Elements
            const homeLocationInput = document.getElementById('home-location');
            const workLocationInput = document.getElementById('work-location');
            const homeCurrentBtn = document.getElementById('home-current');
            const workCurrentBtn = document.getElementById('work-current');
            const saveLocationsBtn = document.getElementById('save-locations');
            const savedLocationsDiv = document.getElementById('saved-locations');
            const transportResults = document.getElementById('transport-results');
            const loadingDiv = document.getElementById('loading');
            const refreshBtn = document.getElementById('refresh-btn');
            const directionBtn = document.getElementById('direction-btn');
            const directionText = document.getElementById('direction-text');
            const directionDropdown = document.getElementById('direction-dropdown');
            
            let currentDirection = 'home-work'; // 'home-work' or 'work-home'
            
            // Initialize saved locations from localStorage
            let savedLocations = JSON.parse(localStorage.getItem('commuteLocations')) || {};
            
            // Display saved locations if they exist
            updateSavedLocationsDisplay();
            
            // Event Listeners
            homeCurrentBtn.addEventListener('click', () => {
                getCurrentLocation('home');
            });
            
            workCurrentBtn.addEventListener('click', () => {
                getCurrentLocation('work');
            });
            
            saveLocationsBtn.addEventListener('click', saveLocations);
            
            refreshBtn.addEventListener('click', fetchTransportOptions);
            
            directionBtn.addEventListener('click', toggleDirectionDropdown);
            
            document.querySelectorAll('.direction-option').forEach(option => {
                option.addEventListener('click', function(e) {
                    e.preventDefault();
                    currentDirection = this.dataset.direction;
                    directionText.textContent = this.textContent;
                    directionDropdown.classList.add('hidden');
                    fetchTransportOptions();
                });
            });
            
            // Close dropdown when clicking outside
            document.addEventListener('click', function(e) {
                if (!directionBtn.contains(e.target) && !directionDropdown.contains(e.target)) {
                    directionDropdown.classList.add('hidden');
                }
            });
            
            // Functions
            // Map variables
            let map;
            let homeMarker;
            let workMarker;
            let directionsService;
            let directionsRenderer;
            
            // Initialize map
            function initMap() {
                map = new google.maps.Map(document.getElementById('map'), {
                    center: {lat: 37.5665, lng: 126.9780}, // Seoul coordinates
                    zoom: 12
                });
                
                directionsService = new google.maps.DirectionsService();
                directionsRenderer = new google.maps.DirectionsRenderer();
                directionsRenderer.setMap(map);
                
                // Add autocomplete to location inputs
                const homeAutocomplete = new google.maps.places.Autocomplete(homeLocationInput);
                const workAutocomplete = new google.maps.places.Autocomplete(workLocationInput);
                
                homeAutocomplete.addListener('place_changed', () => {
                    const place = homeAutocomplete.getPlace();
                    if (place.geometry) {
                        updateMapMarker('home', place.geometry.location);
                    }
                });
                
                workAutocomplete.addListener('place_changed', () => {
                    const place = workAutocomplete.getPlace();
                    if (place.geometry) {
                        updateMapMarker('work', place.geometry.location);
                    }
                });
            }
            
            // Update map marker for home or work location
            function updateMapMarker(type, location) {
                const markerOptions = {
                    position: location,
                    map: map,
                    animation: google.maps.Animation.DROP
                };
                
                if (type === 'home') {
                    if (homeMarker) homeMarker.setMap(null);
                    markerOptions.icon = {
                        url: 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png'
                    };
                    homeMarker = new google.maps.Marker(markerOptions);
                } else {
                    if (workMarker) workMarker.setMap(null);
                    markerOptions.icon = {
                        url: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
                    };
                    workMarker = new google.maps.Marker(markerOptions);
                }
                
                map.panTo(location);
                map.setZoom(14);
                
                // If both locations are set, show route
                if (homeMarker && workMarker) {
                    calculateAndDisplayRoute();
                }
            }
            
            // Calculate and display route between home and work
            function calculateAndDisplayRoute() {
                const start = currentDirection === 'home-work' ? homeMarker.getPosition() : workMarker.getPosition();
                const end = currentDirection === 'home-work' ? workMarker.getPosition() : homeMarker.getPosition();
                
                directionsService.route({
                    origin: start,
                    destination: end,
                    travelMode: 'TRANSIT',
                    provideRouteAlternatives: true
                }, (response, status) => {
                    if (status === 'OK') {
                        directionsRenderer.setDirections(response);
                    } else {
                        console.error('Directions request failed due to ' + status);
                    }
                });
            }
            
            function getCurrentLocation(type) {
                if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(
                        (position) => {
                            const { latitude, longitude } = position.coords;
                            const geocoder = new google.maps.Geocoder();
                            const latLng = new google.maps.LatLng(latitude, longitude);
                            
                            geocoder.geocode({ location: latLng }, (results, status) => {
                                if (status === 'OK' && results[0]) {
                                    const inputField = type === 'home' ? homeLocationInput : workLocationInput;
                                    inputField.value = results[0].formatted_address;
                                    updateMapMarker(type, latLng);
                                } else {
                                    alert('์ฃผ์†Œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.');
                                }
                            });
                        },
                        (error) => {
                            alert('์œ„์น˜ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค: ' + error.message);
                        }
                    );
                } else {
                    alert('์ด ๋ธŒ๋ผ์šฐ์ €๋Š” ์œ„์น˜ ์ •๋ณด ๊ธฐ๋Šฅ์„ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.');
                }
            }
            
            function saveLocations() {
                const homeLocation = homeLocationInput.value.trim();
                const workLocation = workLocationInput.value.trim();
                
                if (!homeLocation || !workLocation) {
                    alert('์ง‘๊ณผ ํšŒ์‚ฌ ์œ„์น˜๋ฅผ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.');
                    return;
                }
                
                savedLocations = {
                    home: homeLocation,
                    work: workLocation
                };
                
                localStorage.setItem('commuteLocations', JSON.stringify(savedLocations));
                updateSavedLocationsDisplay();
                
                // Show success message
                const originalText = saveLocationsBtn.textContent;
                saveLocationsBtn.textContent = '์ €์žฅ ์™„๋ฃŒ!';
                saveLocationsBtn.classList.remove('bg-blue-600', 'hover:bg-blue-700');
                saveLocationsBtn.classList.add('bg-green-500', 'hover:bg-green-600');
                
                setTimeout(() => {
                    saveLocationsBtn.textContent = originalText;
                    saveLocationsBtn.classList.remove('bg-green-500', 'hover:bg-green-600');
                    saveLocationsBtn.classList.add('bg-blue-600', 'hover:bg-blue-700');
                }, 2000);
                
                // Fetch transport options after saving
                fetchTransportOptions();
            }
            
            function updateSavedLocationsDisplay() {
                if (savedLocations.home && savedLocations.work) {
                    savedLocationsDiv.innerHTML = `
                        <div class="flex items-start">
                            <div class="bg-blue-100 p-2 rounded-full mr-3">
                                <i class="fas fa-home text-blue-500"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">์ง‘</h4>
                                <p class="text-sm text-gray-600">${savedLocations.home}</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 p-2 rounded-full mr-3">
                                <i class="fas fa-briefcase text-purple-500"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800">ํšŒ์‚ฌ</h4>
                                <p class="text-sm text-gray-600">${savedLocations.work}</p>
                            </div>
                        </div>
                    `;
                    
                    // Update input fields to show saved values
                    homeLocationInput.value = savedLocations.home;
                    workLocationInput.value = savedLocations.work;
                }
            }
            
            function toggleDirectionDropdown() {
                directionDropdown.classList.toggle('hidden');
            }
            
            function fetchTransportOptions() {
                if (!savedLocations.home || !savedLocations.work) {
                    alert('๋จผ์ € ์ง‘๊ณผ ํšŒ์‚ฌ ์œ„์น˜๋ฅผ ์ €์žฅํ•ด์ฃผ์„ธ์š”.');
                    return;
                }
                
                // Show loading state
                transportResults.classList.add('hidden');
                loadingDiv.classList.remove('hidden');
                
                // Geocode both addresses
                const geocoder = new google.maps.Geocoder();
                
                geocoder.geocode({ address: savedLocations.home }, (homeResults, homeStatus) => {
                    if (homeStatus !== 'OK') {
                        alert('์ง‘ ์ฃผ์†Œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.');
                        loadingDiv.classList.add('hidden');
                        return;
                    }
                    
                    geocoder.geocode({ address: savedLocations.work }, (workResults, workStatus) => {
                        loadingDiv.classList.add('hidden');
                        
                        if (workStatus !== 'OK') {
                            alert('ํšŒ์‚ฌ ์ฃผ์†Œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.');
                            return;
                        }
                        
                        // Update map markers
                        updateMapMarker('home', homeResults[0].geometry.location);
                        updateMapMarker('work', workResults[0].geometry.location);
                        
                        // Generate transport options
                        const mockOptions = generateMockTransportOptions();
                        transportResults.innerHTML = mockOptions;
                        transportResults.classList.remove('hidden');
                        
                        // Animate the cards
                        const cards = document.querySelectorAll('.transport-card');
                        cards.forEach((card, index) => {
                            setTimeout(() => {
                                card.classList.add('slide-in');
                            }, index * 100);
                        });
                    });
                });
            }
            
            function generateMockTransportOptions() {
                const now = new Date();
                const options = [];
                
                // Bus options
                const busOptions = [
                    {
                        type: 'bus',
                        number: '146',
                        from: currentDirection === 'home-work' ? '์—ญ์‚ผ๋™' : '์—ฌ์˜๋„',
                        to: currentDirection === 'home-work' ? '์—ฌ์˜๋„' : '์—ญ์‚ผ๋™',
                        departure: formatTime(addMinutes(now, 5)),
                        arrival: formatTime(addMinutes(now, 35)),
                        duration: '30๋ถ„',
                        stops: 12,
                        distance: '8.5km'
                    },
                    {
                        type: 'bus',
                        number: '740',
                        from: currentDirection === 'home-work' ? '์—ญ์‚ผ๋™' : '์—ฌ์˜๋„',
                        to: currentDirection === 'home-work' ? '์—ฌ์˜๋„' : '์—ญ์‚ผ๋™',
                        departure: formatTime(addMinutes(now, 15)),
                        arrival: formatTime(addMinutes(now, 50)),
                        duration: '35๋ถ„',
                        stops: 15,
                        distance: '9.2km'
                    }
                ];
                
                // Subway options
                const subwayOptions = [
                    {
                        type: 'subway',
                        line: '2ํ˜ธ์„ ',
                        from: currentDirection === 'home-work' ? '๊ฐ•๋‚จ์—ญ' : '์—ฌ์˜๋„์—ญ',
                        to: currentDirection === 'home-work' ? '์—ฌ์˜๋„์—ญ' : '๊ฐ•๋‚จ์—ญ',
                        departure: formatTime(addMinutes(now, 8)),
                        arrival: formatTime(addMinutes(now, 28)),
                        duration: '20๋ถ„',
                        stops: 5,
                        distance: '7.8km'
                    },
                    {
                        type: 'subway',
                        line: '9ํ˜ธ์„ ',
                        from: currentDirection === 'home-work' ? '์„ ์ •๋ฆ‰์—ญ' : '๊ตญํšŒ์˜์‚ฌ๋‹น์—ญ',
                        to: currentDirection === 'home-work' ? '๊ตญํšŒ์˜์‚ฌ๋‹น์—ญ' : '์„ ์ •๋ฆ‰์—ญ',
                        departure: formatTime(addMinutes(now, 12)),
                        arrival: formatTime(addMinutes(now, 32)),
                        duration: '20๋ถ„',
                        stops: 4,
                        distance: '7.2km'
                    }
                ];
                
                // Combine and sort by departure time
                const allOptions = [...busOptions, ...subwayOptions]
                    .sort((a, b) => new Date(a.departure) - new Date(b.departure));
                
                // Generate HTML for each option
                allOptions.forEach(option => {
                    options.push(`
                        <div class="transport-card mb-4 bg-white border border-gray-200 rounded-lg overflow-hidden slide-in" style="opacity: 0;">
                            <div class="flex items-start p-4">
                                <div class="mr-4 mt-1">
                                    ${option.type === 'bus' ? 
                                        `<div class="bg-blue-100 p-3 rounded-full">
                                            <i class="fas fa-bus text-blue-500 text-xl"></i>
                                        </div>` : 
                                        `<div class="bg-green-100 p-3 rounded-full">
                                            <i class="fas fa-subway text-green-500 text-xl"></i>
                                        </div>`}
                                </div>
                                <div class="flex-1">
                                    <div class="flex justify-between items-start">
                                        <div>
                                            <h3 class="font-bold text-lg">
                                                ${option.type === 'bus' ? `๋ฒ„์Šค ${option.number}` : `์ง€ํ•˜์ฒ  ${option.line}`}
                                            </h3>
                                            <p class="text-gray-600 text-sm">
                                                ${option.from} โ†’ ${option.to}
                                            </p>
                                        </div>
                                        <div class="text-right">
                                            <span class="font-bold text-gray-800">${option.duration}</span>
                                            <p class="text-gray-500 text-xs">${option.distance}</p>
                                        </div>
                                    </div>
                                    
                                    <div class="mt-3 flex items-center justify-between">
                                        <div>
                                            <span class="font-medium">${option.departure}</span>
                                            <span class="mx-2 text-gray-400">โ†’</span>
                                            <span class="font-medium">${option.arrival}</span>
                                        </div>
                                        <div class="text-sm text-gray-500">
                                            ${option.stops}๊ฐœ ์ •๋ฅ˜์žฅ
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="bg-gray-50 px-4 py-3 text-sm text-gray-600 border-t border-gray-200">
                                <i class="far fa-clock mr-1"></i> 
                                ${getNextDepartureText(option.departure)}
                            </div>
                        </div>
                    `);
                });
                
                return options.join('');
            }
            
            function formatTime(date) {
                return date.toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit', hour12: false });
            }
            
            function addMinutes(date, minutes) {
                return new Date(date.getTime() + minutes * 60000);
            }
            
            function getNextDepartureText(departureTime) {
                const now = new Date();
                const [hours, minutes] = departureTime.split(':').map(Number);
                const departureDate = new Date();
                departureDate.setHours(hours, minutes, 0, 0);
                
                if (departureDate < now) {
                    departureDate.setDate(departureDate.getDate() + 1);
                }
                
                const diffMs = departureDate - now;
                const diffMins = Math.round(diffMs / 60000);
                
                if (diffMins <= 0) {
                    return "๊ณง ์ถœ๋ฐœํ•ฉ๋‹ˆ๋‹ค!";
                } else if (diffMins < 60) {
                    return `${diffMins}๋ถ„ ํ›„ ์ถœ๋ฐœ`;
                } else {
                    const diffHours = Math.floor(diffMins / 60);
                    const remainingMins = diffMins % 60;
                    return `${diffHours}์‹œ๊ฐ„ ${remainingMins}๋ถ„ ํ›„ ์ถœ๋ฐœ`;
                }
            }
            
            // Initialize with saved locations if they exist
            if (savedLocations.home && savedLocations.work) {
                fetchTransportOptions();
            }
        });
    </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=r2d209/mybooks" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>