Files
SignageHTML/index.html

1808 lines
58 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SL Transport Departures - Ambassaderna (1411)</title>
<!-- Global configuration -->
<script>
// Global variables
window.API_URL = 'http://localhost:3002/api/departures';
window.REFRESH_INTERVAL = 5000;
</script>
<!-- Leaflet.js for map functionality -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<!-- Include the modular scripts in dependency order -->
<script src="config.js"></script> <!-- Load first as others depend on it -->
<script src="clock.js"></script> <!-- Independent module -->
<script src="weather.js"></script> <!-- Depends on config for location -->
<script src="departures.js"></script> <!-- Depends on config for sites -->
<style>
/* Base styles */
body {
font-family: Arial, sans-serif;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
color: #333;
transition: all 0.5s ease;
}
/* Auto-apply landscape layout for wide screens */
@media (min-width: 1200px) {
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) {
max-width: 100%;
padding: 8px 12px 0 12px; /* Minimal padding to maximize space */
padding-bottom: 0;
}
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) #content-wrapper {
display: grid;
grid-template-rows: auto 1fr auto;
gap: 8px; /* Reduced gap */
height: 100vh;
max-height: 100vh;
overflow: hidden;
}
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .clock-container {
grid-row: 1;
margin-bottom: 0;
padding: 6px 16px; /* Reduced padding */
}
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .main-content-grid {
grid-row: 2;
display: block;
overflow-y: auto;
overflow-x: hidden;
min-height: 0;
width: 100%;
}
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .departure-container {
display: grid;
grid-template-columns: repeat(4, 1fr); /* Fixed 4 columns to use all space */
gap: 6px; /* Minimal gap */
margin-bottom: 0;
width: 100%;
box-sizing: border-box;
padding: 0; /* Remove any padding */
}
/* Ensure each column uses equal space */
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .departure-container > * {
min-width: 0; /* Allow flex shrinking */
max-width: 100%; /* Prevent overflow */
}
/* Weather fixed at bottom */
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .weather-section {
grid-row: 3;
position: sticky;
bottom: 0;
background-color: inherit;
padding: 8px 0; /* Reduced padding */
margin-top: 0;
}
body:not(.vertical):not(.upsidedown):not(.vertical-reverse) .weather-container {
margin: 0;
max-width: 100%;
}
}
/* Dark mode styles */
body.dark-mode {
background-color: #222;
color: #f5f5f5;
}
body.dark-mode .departure-card {
background-color: #333;
border-left-color: #0077cc;
}
body.dark-mode .config-modal-content {
background-color: #333;
color: #f5f5f5;
}
body.dark-mode .config-modal-body {
background-color: #333;
}
body.dark-mode .config-modal-footer {
background-color: #444;
}
body.dark-mode #config-cancel-button {
background-color: #555;
color: #f5f5f5;
}
body.dark-mode .time,
body.dark-mode .destination {
color: #f5f5f5;
}
body.dark-mode .direction,
body.dark-mode .details,
body.dark-mode .countdown,
body.dark-mode .last-updated {
color: #aaa;
}
body.dark-mode h2 {
color: #0077cc;
}
body.dark-mode .sun-times {
color: #aaa;
}
body.dark-mode .line-number {
background-color: #0077cc;
}
/* Normal orientation */
body.normal {
max-width: 800px;
}
body.normal .departure-container {
display: grid;
grid-template-columns: 1fr;
gap: 10px;
}
/* Landscape orientation - Optimized for wide screens */
body.landscape {
max-width: 100%;
padding: 20px 40px;
}
/* Main content area: clock at top, then two-column layout below */
body.landscape #content-wrapper {
display: grid;
grid-template-rows: auto 1fr;
gap: 20px;
height: 100vh;
max-height: 100vh;
overflow: hidden;
}
body.landscape .clock-container {
grid-row: 1;
margin-bottom: 0;
}
/* Main content grid: departures on left, weather on right */
body.landscape .main-content-grid {
grid-row: 2;
display: grid;
grid-template-columns: 1fr 380px;
gap: 20px;
overflow: hidden;
min-height: 0;
}
/* Departures container: multi-column grid */
body.landscape .departure-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
gap: 15px;
overflow-y: auto;
overflow-x: hidden;
padding-right: 10px;
min-height: 0;
}
/* Weather container: fixed width, scrollable */
body.landscape .weather-container {
overflow-y: auto;
overflow-x: hidden;
max-height: 100%;
position: sticky;
top: 0;
align-self: start;
}
/* Better horizontal space usage in landscape */
body.landscape .departure-card {
min-height: 120px;
}
body.landscape .line-number-box {
min-width: 120px;
width: 120px;
}
body.landscape .line-number-large {
font-size: 3.5em;
}
/* Site containers in landscape should be more compact */
body.landscape .site-container {
margin-bottom: 15px;
}
body.landscape .site-header {
font-size: 1em;
padding: 8px 12px;
}
/* Vertical orientation (90 degrees rotated) */
body.vertical {
max-width: 100%;
height: 100vh;
padding: 0;
margin: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
body.vertical #content-wrapper {
transform: rotate(90deg);
transform-origin: center center;
position: absolute;
width: 100vh; /* Use viewport height for width */
height: 100vw; /* Use viewport width for height */
max-width: 800px; /* Limit width for better readability */
padding: 20px;
box-sizing: border-box;
overflow-y: auto;
background-color: transparent; /* Remove background color */
left: 50%;
top: 50%;
margin-left: -50vh; /* Half of width */
margin-top: -50vw; /* Half of height */
}
body.vertical .config-button {
transform: rotate(-90deg);
position: fixed;
right: 10px;
bottom: 10px; /* Changed from top to bottom */
z-index: 1000;
}
body.vertical .departure-container {
display: grid;
grid-template-columns: 1fr;
gap: 10px;
}
/* Upside down orientation (180 degrees rotated) */
body.upsidedown {
max-width: 100%;
height: 100vh;
padding: 0;
margin: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
body.upsidedown #content-wrapper {
transform: rotate(180deg);
transform-origin: center center;
position: absolute;
width: 100%;
max-width: 800px;
padding: 20px;
box-sizing: border-box;
overflow-y: auto;
background-color: transparent; /* Remove background color */
left: 50%;
top: 50%;
margin-left: -400px; /* Half of max-width */
margin-top: -50vh; /* Half of viewport height */
}
body.upsidedown .config-button {
transform: rotate(-180deg);
position: fixed;
right: 10px;
bottom: 10px; /* Changed from top to bottom */
z-index: 1000;
}
body.upsidedown .departure-container {
display: grid;
grid-template-columns: 1fr;
gap: 10px;
}
/* Vertical reverse orientation (270 degrees rotated) */
body.vertical-reverse {
max-width: 100%;
height: 100vh;
padding: 0;
margin: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
body.vertical-reverse #content-wrapper {
transform: rotate(270deg);
transform-origin: center center;
position: absolute;
width: 100vh; /* Use viewport height for width */
height: 100vw; /* Use viewport width for height */
max-width: none; /* Remove max-width limitation */
padding: 20px;
box-sizing: border-box;
overflow: visible; /* Show all content */
background-color: transparent; /* Remove background color to show background image */
left: 50%;
top: 50%;
margin-left: -50vh; /* Half of width */
margin-top: -50vw; /* Half of height */
}
body.vertical-reverse .config-button {
transform: rotate(-270deg);
position: fixed;
right: 10px;
bottom: 10px; /* Changed from top to bottom */
z-index: 1000;
}
body.vertical-reverse .departure-container {
display: grid;
grid-template-columns: 1fr;
gap: 10px;
width: 100%; /* Ensure full width */
}
/* Mode indicators - using a class instead of pseudo-element */
.mode-indicator {
font-size: 0.7em;
color: #666;
font-weight: normal;
display: inline;
}
/* Clock styles - Modern entryway kiosk design with blue glow - Ribbon banner */
.clock-container {
background: linear-gradient(135deg, #003366 0%, #004080 50%, #0059b3 100%);
color: white;
padding: 8px 20px; /* Reduced padding for ribbon style */
border-radius: 8px; /* Smaller radius for ribbon */
margin-bottom: 8px; /* Reduced margin */
text-align: center;
box-shadow: 0 0 20px rgba(0, 89, 179, 0.6),
0 0 40px rgba(0, 89, 179, 0.4),
0 4px 12px rgba(0, 0, 0, 0.15),
inset 0 1px 0 rgba(255, 255, 255, 0.3);
position: relative;
overflow: hidden;
backdrop-filter: blur(10px);
transition: box-shadow 0.3s ease;
border: 2px solid rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
gap: 15px; /* Space between time and date */
}
.clock-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.1) 100%);
pointer-events: none;
}
.clock-container:hover {
box-shadow: 0 0 30px rgba(0, 89, 179, 0.8),
0 0 60px rgba(0, 89, 179, 0.5),
0 4px 12px rgba(0, 0, 0, 0.15),
inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
body.dark-mode .clock-container {
background: linear-gradient(135deg, #001a33 0%, #002d5c 50%, #004080 100%);
box-shadow: 0 0 25px rgba(0, 89, 179, 0.7),
0 0 50px rgba(0, 89, 179, 0.4),
0 4px 12px rgba(0, 0, 0, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
body.dark-mode .clock-container:hover {
box-shadow: 0 0 35px rgba(0, 89, 179, 0.9),
0 0 70px rgba(0, 89, 179, 0.6),
0 4px 12px rgba(0, 0, 0, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
/* Configuration button styles */
.config-button {
position: fixed;
bottom: 20px; /* Changed from top to bottom */
right: 20px;
width: 40px;
height: 40px;
background-color: rgba(0, 97, 161, 0.3); /* Translucent by default */
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
z-index: 100;
transition: transform 0.3s ease, background-color 0.3s ease, opacity 0.3s ease;
opacity: 0.5; /* Translucent */
}
.config-button:hover {
transform: rotate(30deg);
background-color: #0061a1; /* Full color on hover */
opacity: 1; /* Fully opaque on hover */
}
.config-button svg {
transition: opacity 0.3s ease;
opacity: 0.7; /* Icon also translucent */
}
.config-button:hover svg {
opacity: 1; /* Full opacity on hover */
}
/* Configuration modal styles */
.config-modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 200;
justify-content: center;
align-items: center;
}
.config-modal-content {
background-color: white;
border-radius: 8px;
width: 90%;
max-width: 600px;
max-height: 90vh;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
overflow: hidden;
display: flex;
flex-direction: column;
}
body.dark-mode .config-modal-content {
background-color: #333;
}
.config-modal-header {
background-color: #0061a1;
color: white;
padding: 15px 20px;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
}
.config-modal-header h2 {
margin: 0;
font-size: 1.5em;
}
.config-modal-close {
font-size: 1.8em;
cursor: pointer;
line-height: 1;
}
.config-modal-close:hover {
opacity: 0.8;
}
/* Tab navigation */
.config-tabs {
display: flex;
background-color: #f0f0f0;
border-bottom: 2px solid #ddd;
flex-shrink: 0;
}
body.dark-mode .config-tabs {
background-color: #444;
border-bottom-color: #555;
}
.config-tab {
flex: 1;
padding: 12px 20px;
background-color: transparent;
border: none;
border-bottom: 3px solid transparent;
cursor: pointer;
font-size: 0.95em;
font-weight: 500;
color: #666;
transition: all 0.2s ease;
}
body.dark-mode .config-tab {
color: #aaa;
}
.config-tab:hover {
background-color: #e0e0e0;
color: #333;
}
body.dark-mode .config-tab:hover {
background-color: #555;
color: #f5f5f5;
}
.config-tab.active {
background-color: white;
color: #0061a1;
border-bottom-color: #0061a1;
font-weight: 600;
}
body.dark-mode .config-tab.active {
background-color: #333;
color: #4fc3f7;
border-bottom-color: #4fc3f7;
}
.config-modal-body {
padding: 20px;
overflow-y: auto;
flex: 1;
min-height: 0;
max-height: calc(90vh - 200px);
}
/* Custom scrollbar for modal body */
.config-modal-body::-webkit-scrollbar {
width: 8px;
}
.config-modal-body::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.config-modal-body::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
.config-modal-body::-webkit-scrollbar-thumb:hover {
background: #555;
}
body.dark-mode .config-modal-body::-webkit-scrollbar-track {
background: #444;
}
body.dark-mode .config-modal-body::-webkit-scrollbar-thumb {
background: #666;
}
body.dark-mode .config-modal-body::-webkit-scrollbar-thumb:hover {
background: #888;
}
.config-tab-content {
display: none;
}
.config-tab-content.active {
display: block;
}
.config-option {
margin-bottom: 15px;
}
.config-option label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.config-option select,
.config-option input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1em;
box-sizing: border-box;
}
body.dark-mode .config-option select,
body.dark-mode .config-option input[type="text"] {
background-color: #444;
color: #f5f5f5;
border-color: #555;
}
.config-option input[type="range"] {
width: 100%;
}
.config-option button {
padding: 5px 10px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #f5f5f5;
cursor: pointer;
font-size: 0.9em;
}
body.dark-mode .config-option button {
background-color: #555;
color: #f5f5f5;
border-color: #666;
}
.config-option button:hover {
background-color: #e0e0e0;
}
body.dark-mode .config-option button:hover {
background-color: #666;
}
/* Site search styles */
#site-search-results {
border: 1px solid #ddd;
border-radius: 4px;
background: white;
margin-top: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
body.dark-mode #site-search-results {
background-color: #444;
border-color: #555;
}
.site-search-result {
padding: 10px;
border-bottom: 1px solid #eee;
cursor: pointer;
transition: background-color 0.2s;
}
.site-search-result:last-child {
border-bottom: none;
}
.site-search-result:hover {
background-color: #f5f5f5;
}
body.dark-mode .site-search-result {
border-bottom-color: #555;
}
body.dark-mode .site-search-result:hover {
background-color: #555;
}
.site-search-result div:first-child {
font-weight: bold;
color: #0061a1;
margin-bottom: 4px;
}
body.dark-mode .site-search-result div:first-child {
color: #4fc3f7;
}
.site-search-result div:last-child {
font-size: 0.85em;
color: #666;
}
body.dark-mode .site-search-result div:last-child {
color: #aaa;
}
#search-site-button {
background-color: #0061a1;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.2s;
}
#search-site-button:hover {
background-color: #004d80;
}
body.dark-mode #search-site-button {
background-color: #4fc3f7;
color: #333;
}
body.dark-mode #search-site-button:hover {
background-color: #29b6f6;
}
/* Map selector button */
#select-from-map-button {
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.2s;
}
#select-from-map-button:hover {
background-color: #218838;
}
body.dark-mode #select-from-map-button {
background-color: #34ce57;
color: #333;
}
body.dark-mode #select-from-map-button:hover {
background-color: #28a745;
}
/* Map selector modal styles */
#map-selector-modal .config-modal-content {
width: 90vw;
max-width: 1200px;
}
#map-container {
z-index: 1;
}
.map-modal-close {
font-size: 1.8em;
cursor: pointer;
line-height: 1;
color: white;
}
.map-modal-close:hover {
opacity: 0.8;
}
.config-modal-footer {
padding: 15px 20px;
background-color: #f5f5f5;
text-align: right;
border-top: 1px solid #ddd;
flex-shrink: 0;
}
body.dark-mode .config-modal-footer {
background-color: #444;
border-top-color: #555;
}
.config-modal-footer button {
padding: 8px 15px;
margin-left: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
}
#config-save-button {
background-color: #0061a1;
color: white;
}
#config-save-button:hover {
background-color: #004d80;
}
#config-cancel-button {
background-color: #ddd;
}
body.dark-mode #config-cancel-button {
background-color: #555;
color: #f5f5f5;
}
#config-cancel-button:hover {
background-color: #ccc;
}
body.dark-mode #config-cancel-button:hover {
background-color: #666;
}
.clock-time {
font-size: 2.2em; /* Further reduced for ribbon */
font-weight: 700;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
white-space: nowrap;
display: inline-block; /* Changed to inline-block for same line */
letter-spacing: 1px;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
0 1px 4px rgba(255, 255, 255, 0.3);
margin: 0; /* No margin for inline layout */
position: relative;
z-index: 1;
line-height: 1;
color: #FFFFFF;
}
.clock-date {
font-size: 2.2em; /* Match time size */
font-weight: 400;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
display: inline-block; /* Changed to inline-block for same line */
opacity: 0.98;
letter-spacing: 0.5px;
text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15),
0 1px 2px rgba(255, 255, 255, 0.2);
text-transform: capitalize;
position: relative;
z-index: 1;
line-height: 1;
margin: 0; /* No margin for inline layout */
color: #FFFFFF;
}
body.dark-mode .clock-time,
body.dark-mode .clock-date {
color: #E6F4FF;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
0 1px 4px rgba(0, 0, 0, 0.2);
}
/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
.clock-time {
font-size: 1.8em;
letter-spacing: 1px;
}
.clock-date {
font-size: 1.8em; /* Match time size */
}
.clock-container {
padding: 6px 16px;
gap: 10px;
}
}
@media (max-width: 480px) {
.clock-time {
font-size: 1.5em;
}
.clock-date {
font-size: 1.5em; /* Match time size */
}
.clock-container {
padding: 6px 12px;
gap: 8px;
}
}
h2 {
color: #0061a1;
text-align: center;
}
.status {
text-align: center;
margin-bottom: 20px;
font-style: italic;
display: none; /* Hide the status message to avoid layout disruptions */
}
.departure-container {
display: grid;
grid-template-columns: 1fr;
gap: 12px;
margin-bottom: 20px;
}
/* Main content grid wrapper */
.main-content-grid {
display: block; /* Default: single column for normal/vertical modes */
}
.departures-section {
width: 100%;
}
.weather-section {
width: 100%;
}
/* New card-based layout similar to card.JPG */
.departure-card {
background-color: white;
border-radius: 6px; /* Further reduced radius */
padding: 0;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
margin-bottom: 6px; /* Further reduced margin */
min-height: 75px; /* Further reduced min height */
display: flex;
overflow: hidden;
width: 100%; /* Ensure card uses full column width */
box-sizing: border-box; /* Include padding/border in width */
max-width: 100%; /* Prevent overflow */
}
body.dark-mode .departure-card {
background-color: #333;
}
/* Large line number box on the left */
.line-number-box {
background: linear-gradient(135deg, #0061a1 0%, #004d80 100%); /* Changed from green to blue */
color: white;
min-width: 50px; /* Further reduced */
width: 50px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 4px; /* Further reduced padding */
border-radius: 4px 0 0 4px; /* Further reduced radius */
position: relative;
}
/* Transport mode icon */
.transport-mode-icon {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 2px;
opacity: 0.95;
}
.transport-mode-icon .transport-icon {
width: 20px; /* Increased icon size */
height: 20px;
fill: currentColor;
}
/* Large line number */
.line-number-large {
font-size: 1.6em; /* Increased - more space available */
font-weight: bold;
line-height: 1;
color: #fff; /* Changed to white */
}
/* Transport-specific colors */
.line-number-box.bus {
background: linear-gradient(135deg, #0061a1 0%, #004d80 100%);
}
.line-number-box.bus .line-number-large {
color: white;
}
.line-number-box.metro {
background: linear-gradient(135deg, #c41e3a 0%, #9a1629 100%);
}
.line-number-box.metro .line-number-large {
color: white;
}
.line-number-box.train {
background: linear-gradient(135deg, #0061a1 0%, #004d80 100%);
}
.line-number-box.train .line-number-large {
color: white;
}
.line-number-box.tram {
background: linear-gradient(135deg, #0061a1 0%, #004d80 100%); /* Blue like bus/train */
}
.line-number-box.tram .line-number-large {
color: white;
}
.line-number-box.ship {
background: linear-gradient(135deg, #0061a1 0%, #004d80 100%);
}
.line-number-box.ship .line-number-large {
color: white;
}
/* Directions container on the right */
.directions-wrapper {
flex: 1;
display: flex;
flex-direction: column;
padding: 6px 10px; /* Increased padding - more space available */
gap: 5px; /* Increased gap */
min-width: 0; /* Allow flex shrinking */
overflow: hidden; /* Prevent overflow */
}
/* Single direction row */
.direction-row {
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
min-height: 36px; /* Increased */
gap: 8px; /* Increased gap between direction-info and times-container */
min-width: 0; /* Allow flex shrinking */
}
/* Direction info (arrow + destination) */
.direction-info {
display: flex;
align-items: center;
gap: 6px; /* Increased gap */
flex: 1;
min-width: 0; /* Allow flex shrinking */
overflow: hidden; /* Prevent overflow */
}
/* Direction arrow indicator - Increased size */
.direction-arrow-box {
width: 32px; /* Increased */
height: 32px;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.4em; /* Increased */
font-weight: bold;
flex-shrink: 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
border: 1.5px solid rgba(255, 255, 255, 0.3);
}
.direction-arrow-box.left {
background: repeating-linear-gradient(
45deg,
#fff5e6,
#fff5e6 4px,
#ffe6cc 4px,
#ffe6cc 8px
);
color: #ff6600;
border-color: #ff6600;
}
.direction-arrow-box.right {
background: repeating-linear-gradient(
45deg,
#e6f2ff,
#e6f2ff 4px,
#cce6ff 4px,
#cce6ff 8px
);
color: #0066cc;
border-color: #0066cc;
}
body.dark-mode .direction-arrow-box.left {
background: repeating-linear-gradient(
45deg,
#664422,
#664422 4px,
#553311 4px,
#553311 8px
);
color: #ff8800;
border-color: #ff8800;
}
body.dark-mode .direction-arrow-box.right {
background: repeating-linear-gradient(
45deg,
#223366,
#223366 4px,
#112255 4px,
#112255 8px
);
color: #4fc3f7;
border-color: #4fc3f7;
}
/* Destination text */
.direction-destination {
font-size: 1.1em; /* Increased - more space available */
font-weight: 600;
color: #333;
white-space: nowrap; /* Prevent wrapping */
overflow: hidden;
text-overflow: ellipsis; /* Show ellipsis if too long */
flex: 1;
min-width: 0; /* Allow flex shrinking */
}
body.dark-mode .direction-destination {
color: #f5f5f5;
}
/* Times container */
.times-container {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 3px; /* Increased gap */
min-width: 110px; /* Increased slightly */
flex-shrink: 0; /* Prevent shrinking */
max-width: 110px; /* Prevent overflow */
}
/* Time display */
.time-display {
display: flex;
align-items: baseline;
gap: 6px; /* Increased gap */
white-space: nowrap; /* Prevent wrapping */
font-size: 1em; /* Increased */
}
/* Pulse animation for urgent and now states - sharp text with exterior glow only */
@keyframes pulse-glow {
0%, 100% {
text-shadow: 0 0 8px currentColor, 0 0 12px currentColor, 0 0 16px currentColor;
}
50% {
text-shadow: 0 0 12px currentColor, 0 0 18px currentColor, 0 0 24px currentColor;
}
}
@keyframes pulse-scale {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
}
.countdown-large {
font-size: 1.4em; /* Increased - more space available */
font-weight: bold;
color: white; /* Default: white for 5+ minutes */
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
white-space: nowrap; /* Prevent wrapping */
}
.countdown-large.urgent {
color: #c41e3a; /* Red: less than 5 minutes */
animation: pulse-glow 2s ease-in-out infinite, pulse-scale 2s ease-in-out infinite;
text-shadow: 0 0 8px #c41e3a, 0 0 12px #c41e3a, 0 0 16px rgba(196, 30, 58, 0.9);
}
.countdown-large.now {
color: #00a651; /* Green: "Nu" (now) */
animation: pulse-glow 2s ease-in-out infinite, pulse-scale 2s ease-in-out infinite;
text-shadow: 0 0 8px #00a651, 0 0 12px #00a651, 0 0 16px rgba(0, 166, 81, 0.9);
}
body.dark-mode .countdown-large {
color: #f5f5f5; /* White for 5+ minutes in dark mode */
}
body.dark-mode .countdown-large.urgent {
color: #ff6b6b; /* Red: less than 5 minutes in dark mode */
text-shadow: 0 0 8px #ff6b6b, 0 0 12px #ff6b6b, 0 0 16px rgba(255, 107, 107, 0.9);
}
body.dark-mode .countdown-large.now {
color: #4ecdc4; /* Green: "Nu" in dark mode */
text-shadow: 0 0 8px #4ecdc4, 0 0 12px #4ecdc4, 0 0 16px rgba(78, 205, 196, 0.9);
}
/* Time range */
.time-range {
font-size: 0.85em; /* Increased - more space available */
color: #666;
font-weight: 500;
white-space: nowrap; /* Prevent wrapping */
}
body.dark-mode .time-range {
color: #aaa;
}
/* Legacy styles for compatibility */
.departure-header {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.line-number {
background-color: #0061a1;
color: white;
padding: 6px 12px;
border-radius: 6px;
font-weight: bold;
font-size: 1.8em;
display: flex;
align-items: center;
gap: 8px;
margin-right: 10px;
}
.transport-icon {
width: 24px;
height: 24px;
fill: currentColor;
}
.line-destination {
font-size: 0.65em;
font-weight: normal;
margin-left: 6px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 120px;
display: inline-block;
vertical-align: middle;
}
.time {
font-size: 1.5em;
font-weight: bold;
color: #333;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
gap: 8px;
}
.arrival-time {
font-size: 1.3em;
}
.countdown {
font-size: 1.1em;
color: white; /* Default: white for 5+ minutes */
}
.countdown.urgent {
color: #c41e3a; /* Red: less than 5 minutes */
animation: pulse-glow 2s ease-in-out infinite, pulse-scale 2s ease-in-out infinite;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-shadow: 0 0 6px #c41e3a, 0 0 10px #c41e3a, 0 0 14px rgba(196, 30, 58, 0.9);
}
.countdown.now {
color: #00a651; /* Green: "Nu" (now) */
font-weight: bold;
animation: pulse-glow 2s ease-in-out infinite, pulse-scale 2s ease-in-out infinite;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-shadow: 0 0 6px #00a651, 0 0 10px #00a651, 0 0 14px rgba(0, 166, 81, 0.9);
}
body.dark-mode .countdown {
color: #f5f5f5; /* White for 5+ minutes in dark mode */
}
body.dark-mode .countdown.urgent {
color: #ff6b6b; /* Red: less than 5 minutes in dark mode */
text-shadow: 0 0 6px #ff6b6b, 0 0 10px #ff6b6b, 0 0 14px rgba(255, 107, 107, 0.9);
}
body.dark-mode .countdown.now {
color: #4ecdc4; /* Green: "Nu" in dark mode */
text-shadow: 0 0 6px #4ecdc4, 0 0 10px #4ecdc4, 0 0 14px rgba(78, 205, 196, 0.9);
}
.destination {
font-weight: bold;
font-size: 1.4em;
margin: 10px 0;
}
.direction {
color: #666;
}
.details {
margin-top: 10px;
font-size: 0.9em;
color: #666;
}
/* Weather widget styles */
.weather-container {
margin: 20px 0;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
body.dark-mode .weather-container {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
/* Custom weather display */
#custom-weather {
padding: 8px; /* Reduced from 12px */
background-color: rgba(30, 36, 50, 0.8); /* Semi-transparent background */
color: white;
border-radius: 8px;
text-align: center;
}
/* Ensure weather widget is visible in vertical-reverse mode */
body.vertical-reverse #custom-weather {
width: auto;
max-width: none;
}
#custom-weather .current-weather {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-bottom: 12px;
flex-wrap: wrap;
}
#custom-weather .location-info {
display: flex;
align-items: center;
margin-right: 15px;
}
#custom-weather h3 {
margin: 0;
margin-right: 8px;
font-size: 1em; /* Reduced from 1.1em */
}
#custom-weather .weather-icon {
display: flex;
align-items: center;
margin-right: 8px; /* Reduced from 10px */
}
#custom-weather .weather-icon img {
width: 48px; /* Reduced from 64px */
height: 48px;
margin-right: 5px;
}
/* Make sun icons RGB(255, 224, 0) - bright yellow */
/* For clear sun (no clouds): apply full yellow filter */
#custom-weather .weather-icon img.weather-clear-sun,
#custom-weather .weather-icon img[data-condition="Clear"],
#custom-weather .forecast-hour .icon img.weather-clear-sun,
#custom-weather .forecast-hour .icon img[data-condition="Clear"] {
filter: brightness(0) saturate(100%) invert(100%) sepia(100%) saturate(10000%) hue-rotate(0deg) brightness(1.12);
}
/* For clouds with sun: preserve white clouds (#FFFFFF), color only sun parts yellow */
/* Use brightness to preserve white areas, then selective saturation/hue for yellow sun */
#custom-weather .weather-icon img.weather-clouds-sun,
#custom-weather .weather-icon img[data-condition*="Clouds"]:not([data-condition="Clear"]),
#custom-weather .forecast-hour .icon img.weather-clouds-sun,
#custom-weather .forecast-hour .icon img[data-condition*="Clouds"]:not([data-condition="Clear"]) {
/* High brightness preserves white clouds, saturation and hue-rotate color the sun yellow */
filter: brightness(1.25) saturate(3) hue-rotate(-30deg) contrast(1.05);
}
/* Make snow icons #F5F5F5 - light grey/white (RGB: 245, 245, 245) */
/* Convert to light grey: brightness(0) -> black, invert(96%) -> #F5F5F5 equivalent */
#custom-weather .weather-icon img[data-condition*="Snow"],
#custom-weather .weather-icon img.weather-snow,
#custom-weather .forecast-hour .icon img.weather-snow {
filter: brightness(0) saturate(0%) invert(96%);
}
#custom-weather .temperature {
font-size: 1.5em; /* Reduced from 1.8em */
font-weight: bold;
white-space: nowrap;
}
#custom-weather .sun-times {
text-align: center;
margin-top: 6px; /* Reduced from 10px */
font-size: 0.75em; /* Reduced from 0.85em */
color: #aaa;
}
/* Hourly forecast styles */
#custom-weather .forecast {
display: flex;
justify-content: center;
overflow-x: auto;
padding-bottom: 6px; /* Reduced from 10px */
margin-bottom: 6px; /* Reduced from 10px */
scrollbar-width: thin;
scrollbar-color: #4fc3f7 #1e2432;
}
#custom-weather .forecast::-webkit-scrollbar {
height: 6px;
}
#custom-weather .forecast::-webkit-scrollbar-track {
background: #1e2432;
}
#custom-weather .forecast::-webkit-scrollbar-thumb {
background-color: #4fc3f7;
border-radius: 6px;
}
#custom-weather .forecast-hour {
text-align: center;
min-width: 50px; /* Reduced from 60px */
margin-right: 6px; /* Reduced from 10px */
flex-shrink: 0;
background-color: rgba(30, 40, 60, 0.5);
border: 1px solid #4fc3f7;
border-radius: 4px; /* Reduced from 6px */
padding: 6px 4px; /* Reduced from 8px 5px */
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
height: 90px; /* Reduced from 120px */
}
#custom-weather .forecast-hour:last-child {
margin-right: 0;
}
#custom-weather .forecast-hour .time {
margin-bottom: 3px; /* Reduced from 5px */
font-size: 0.75em; /* Reduced from 0.9em */
font-weight: bold;
color: white;
display: block;
}
#custom-weather .forecast-hour .icon {
margin: 3px 0; /* Reduced from 5px */
}
#custom-weather .forecast-hour .icon img {
width: 40px; /* Reduced from 56px */
height: 40px;
}
/* Sun icons already handled above - removing duplicate */
#custom-weather .forecast-hour .temp {
font-weight: bold;
font-size: 0.8em; /* Added size reduction */
}
#custom-weather .attribution {
margin-top: 10px;
font-size: 0.7em;
text-align: right;
}
#custom-weather .attribution a {
color: #4fc3f7;
text-decoration: none;
}
/* Sun times display in config */
.sun-times {
margin-top: 5px;
color: #666;
}
/* Background image settings */
#background-image-url {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1em;
margin-bottom: 10px;
}
.background-preview {
width: 100%;
height: 120px;
border: 1px solid #ddd;
border-radius: 4px;
margin-top: 5px;
margin-bottom: 15px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background-color: #f5f5f5;
}
.background-preview img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.background-preview .no-image {
color: #999;
font-style: italic;
}
#background-opacity {
width: 100%;
margin-top: 5px;
}
#opacity-value {
font-weight: normal;
color: #0077cc;
}
.last-updated {
text-align: center;
font-size: 0.8em;
color: #666;
margin-top: 20px;
}
/* Site header styles */
.site-header {
margin-bottom: 10px; /* Reduced to create more consistent spacing */
position: relative;
}
/* Site container styles */
.site-container {
margin-bottom: 10px; /* Reduced to match other spacing */
}
.site-name {
display: inline-block;
background-color: white;
color: #0061a1;
font-weight: bold;
padding: 5px 15px;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: relative;
z-index: 1;
}
.error {
color: red;
text-align: center;
padding: 20px;
background-color: #ffeeee;
border-radius: 8px;
margin: 20px 0;
}
</style>
</head>
<body>
<!-- Content wrapper for vertical orientation -->
<div id="content-wrapper">
<!-- Clock element -->
<div id="clock"></div>
<!-- Site ID header removed as requested -->
<!-- Main content grid for landscape layout -->
<div class="main-content-grid">
<!-- Left side: Departures -->
<div class="departures-section">
<div class="status" id="status">Loading departures...</div>
<div class="departure-container" id="departures">
<!-- Departures will be inserted here by JavaScript -->
</div>
</div>
</div> <!-- End of main-content-grid -->
<!-- Weather widget - fixed at bottom -->
<div class="weather-section">
<div class="weather-container">
<!-- Custom weather display with hourly forecast -->
<div id="custom-weather">
<div class="current-weather">
<div class="location-info">
<h3>Stockholm</h3>
<div class="weather-icon">
<img src="https://cdn.weatherapi.com/weather/64x64/day/113.png" alt="Clear" />
<div>Clear</div>
</div>
</div>
<div class="temperature">7.1 °C</div>
</div>
<div class="forecast">
<div class="forecast-hour">
<div class="time">Nu</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/day/113.png" alt="Clear" width="40" />
</div>
<div class="temp">7.1 °C</div>
</div>
<div class="forecast-hour">
<div class="time">19:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/113.png" alt="Clear" width="40" />
</div>
<div class="temp">6.8 °C</div>
</div>
<div class="forecast-hour">
<div class="time">20:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/113.png" alt="Clear" width="40" />
</div>
<div class="temp">6.5 °C</div>
</div>
<div class="forecast-hour">
<div class="time">21:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/116.png" alt="Partly cloudy" width="40" />
</div>
<div class="temp">6.2 °C</div>
</div>
<div class="forecast-hour">
<div class="time">22:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/116.png" alt="Partly cloudy" width="40" />
</div>
<div class="temp">6.0 °C</div>
</div>
<div class="forecast-hour">
<div class="time">23:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/116.png" alt="Partly cloudy" width="40" />
</div>
<div class="temp">5.8 °C</div>
</div>
<div class="forecast-hour">
<div class="time">00:00</div>
<div class="icon">
<img src="https://cdn.weatherapi.com/weather/64x64/night/116.png" alt="Partly cloudy" width="40" />
</div>
<div class="temp">5.5 °C</div>
</div>
</div>
<div class="sun-times">
☀️ Sunrise: 06:45 AM | 🌙 Sunset: 05:32 PM
</div>
</div> <!-- End of weather-section -->
<div class="last-updated" id="last-updated"></div>
</div> <!-- End of content-wrapper -->
<script>
// Function to ensure content wrapper exists
function ensureContentWrapper() {
if (!document.getElementById('content-wrapper')) {
console.log('Creating content wrapper');
const wrapper = document.createElement('div');
wrapper.id = 'content-wrapper';
// Move all body children to the wrapper except excluded elements
const excludedElements = ['config-button', 'config-modal', 'background-overlay'];
// Create an array of nodes to move (can't modify while iterating)
const nodesToMove = [];
for (let i = 0; i < document.body.children.length; i++) {
const child = document.body.children[i];
if (!excludedElements.includes(child.id) && child.id !== 'content-wrapper') {
nodesToMove.push(child);
}
}
// Move the nodes to the wrapper
nodesToMove.forEach(node => {
wrapper.appendChild(node);
});
// Add the wrapper back to the body
document.body.appendChild(wrapper);
}
}
// Initialize components when the DOM is loaded
document.addEventListener('DOMContentLoaded', async function() {
console.log('DOM fully loaded');
try {
// Initialize ConfigManager first
console.log('Creating ConfigManager...');
window.configManager = new ConfigManager({
defaultOrientation: 'normal',
defaultDarkMode: 'auto'
});
// Create config button
const buttonContainer = document.createElement('div');
buttonContainer.id = 'config-button';
buttonContainer.className = 'config-button';
buttonContainer.title = 'Settings';
buttonContainer.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path d="M12 15.5A3.5 3.5 0 0 1 8.5 12 3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5 3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.65.07-.97 0-.32-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1 0 .33.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.66z" fill="#fff"/>
</svg>
`;
buttonContainer.addEventListener('click', () => window.configManager.toggleConfigModal());
document.body.appendChild(buttonContainer);
// Initialize Clock
window.clock = new Clock({
elementId: 'clock',
timezone: 'Europe/Stockholm'
});
// Initialize WeatherManager
window.weatherManager = new WeatherManager({
latitude: 59.3293, // Stockholm latitude
longitude: 18.0686 // Stockholm longitude
});
// Initialize departures
initDepartures();
// Set up event listeners
document.addEventListener('darkModeChanged', event => {
document.body.classList.toggle('dark-mode', event.detail.isDarkMode);
});
document.addEventListener('configChanged', event => {
if (['vertical', 'upsidedown', 'vertical-reverse'].includes(event.detail.config.orientation)) {
ensureContentWrapper();
}
});
// Ensure content wrapper exists initially
ensureContentWrapper();
console.log('All components initialized successfully');
} catch (error) {
console.error('Error during initialization:', error);
const errorDiv = document.createElement('div');
errorDiv.className = 'error';
errorDiv.textContent = `Initialization error: ${error.message}`;
document.body.appendChild(errorDiv);
}
});
</script>