Formatting

This commit is contained in:
Carsten Graf
2025-07-12 17:06:42 +02:00
parent 337e12078b
commit 3b4c5d2b92
6 changed files with 1651 additions and 1462 deletions

View File

@@ -1,436 +1,439 @@
html {
overflow: hidden;
height: 100%;
width: 100%;
}
overflow: hidden;
height: 100%;
width: 100%;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Arial", sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
color: white;
position: relative;
overflow: hidden;
box-sizing: border-box;
}
body {
font-family: "Arial", sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
color: white;
position: relative;
overflow: hidden;
box-sizing: border-box;
}
.logo {
position: fixed;
top: 20px;
left: 20px;
width: auto;
height: auto;
z-index: 1000;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease;
text-decoration: none;
display: block;
cursor: pointer;
padding-left: 5px;
padding-right: 5px;
}
.logo {
position: fixed;
top: 20px;
left: 20px;
width: auto;
height: auto;
z-index: 1000;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease;
text-decoration: none;
display: block;
cursor: pointer;
padding-left: 5px;
padding-right: 5px;
}
.logo:hover {
transform: scale(1.1);
}
.logo:hover {
transform: scale(1.1);
}
.logo img {
width: 100%;
height: 100%;
object-fit: contain;
border-radius: 10px;
}
.logo img {
width: 100%;
height: 100%;
object-fit: contain;
border-radius: 10px;
}
.settings-btn {
position: fixed;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
padding: 15px;
border-radius: 50%;
text-decoration: none;
font-size: 1.5rem;
transition: all 0.3s ease;
z-index: 1000;
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
.settings-btn {
position: fixed;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
padding: 15px;
border-radius: 50%;
text-decoration: none;
font-size: 1.5rem;
transition: all 0.3s ease;
z-index: 1000;
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
.settings-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
transform: scale(1.1);
}
.settings-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
transform: scale(1.1);
}
.heartbeat-indicators {
position: fixed;
top: 20px;
right: 90px;
display: flex;
gap: 15px;
z-index: 1000;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 25px;
padding: 10px 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.heartbeat-indicators {
position: fixed;
top: 20px;
right: 90px;
display: flex;
gap: 15px;
z-index: 1000;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 25px;
padding: 10px 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.heartbeat-indicator {
width: 20px;
height: 20px;
border-radius: 50%;
background: #e74c3c;
transition: all 0.3s ease;
position: relative;
}
.heartbeat-indicator {
width: 20px;
height: 20px;
border-radius: 50%;
background: #e74c3c;
transition: all 0.3s ease;
position: relative;
}
.heartbeat-indicator::before {
content: attr(data-label);
position: absolute;
top: -25px;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
font-weight: bold;
white-space: nowrap;
color: rgba(255, 255, 255, 0.8);
}
.heartbeat-indicator::before {
content: attr(data-label);
position: absolute;
top: -25px;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
font-weight: bold;
white-space: nowrap;
color: rgba(255, 255, 255, 0.8);
}
.heartbeat-indicator.active {
background: #2ecc71;
box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}
.heartbeat-indicator.active {
background: #2ecc71;
box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}
/* Batterie-Banner Styling */
.battery-banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
color: white;
padding: 15px 20px;
text-align: center;
z-index: 2000;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
border-bottom: 3px solid rgba(255, 255, 255, 0.2);
animation: batteryPulse 2s infinite;
transform: translateY(-100%);
transition: transform 0.5s ease;
}
/* Batterie-Banner Styling */
.battery-banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
color: white;
padding: 15px 20px;
text-align: center;
z-index: 2000;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
border-bottom: 3px solid rgba(255, 255, 255, 0.2);
animation: batteryPulse 2s infinite;
transform: translateY(-100%);
transition: transform 0.5s ease;
}
.battery-banner.show {
transform: translateY(0);
}
.battery-banner.show {
transform: translateY(0);
}
.battery-banner .banner-content {
display: flex;
align-items: center;
justify-content: center;
gap: 15px;
flex-wrap: wrap;
}
.battery-banner .banner-content {
display: flex;
align-items: center;
justify-content: center;
gap: 15px;
flex-wrap: wrap;
}
.battery-banner .banner-icon {
font-size: 2rem;
animation: batteryBlink 1.5s infinite;
}
.battery-banner .banner-icon {
font-size: 2rem;
animation: batteryBlink 1.5s infinite;
}
.battery-banner .banner-text {
font-size: 1.1rem;
font-weight: bold;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.battery-banner .banner-text {
font-size: 1.1rem;
font-weight: bold;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.battery-banner .banner-devices {
font-size: 0.9rem;
opacity: 0.9;
margin-top: 5px;
}
.battery-banner .banner-devices {
font-size: 0.9rem;
opacity: 0.9;
margin-top: 5px;
}
.battery-banner .close-btn {
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
width: 35px;
height: 35px;
border-radius: 50%;
cursor: pointer;
font-size: 1.2rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.battery-banner .close-btn {
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
width: 35px;
height: 35px;
border-radius: 50%;
cursor: pointer;
font-size: 1.2rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.battery-banner .close-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
transform: translateY(-50%) scale(1.1);
}
.battery-banner .close-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
transform: translateY(-50%) scale(1.1);
}
@keyframes batteryPulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.8;
}
}
@keyframes batteryPulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.8;
}
}
@keyframes batteryBlink {
0%, 50% {
opacity: 1;
}
51%, 100% {
opacity: 0.5;
}
}
@keyframes batteryBlink {
0%,
50% {
opacity: 1;
}
51%,
100% {
opacity: 0.5;
}
}
/* Anpassung für mobile Geräte */
@media (max-width: 768px) {
.battery-banner {
padding: 12px 15px;
}
/* Anpassung für mobile Geräte */
@media (max-width: 768px) {
.battery-banner {
padding: 12px 15px;
}
.battery-banner .banner-content {
gap: 10px;
}
.battery-banner .banner-content {
gap: 10px;
}
.battery-banner .banner-icon {
font-size: 1.5rem;
}
.battery-banner .banner-icon {
font-size: 1.5rem;
}
.battery-banner .banner-text {
font-size: 1rem;
}
.battery-banner .banner-text {
font-size: 1rem;
}
.battery-banner .close-btn {
width: 30px;
height: 30px;
font-size: 1rem;
right: 15px;
}
}
.battery-banner .close-btn {
width: 30px;
height: 30px;
font-size: 1rem;
right: 15px;
}
}
/* Hauptcontent nach unten verschieben wenn Banner sichtbar */
.content-shifted {
margin-top: 80px;
transition: margin-top 0.5s ease;
}
/* Hauptcontent nach unten verschieben wenn Banner sichtbar */
.content-shifted {
margin-top: 80px;
transition: margin-top 0.5s ease;
}
@media (max-width: 768px) {
.content-shifted {
margin-top: 70px;
}
}
@media (max-width: 768px) {
.content-shifted {
margin-top: 70px;
}
}
.header {
text-align: center;
margin-bottom: 2vh;
flex-shrink: 0;
}
.header {
text-align: center;
margin-bottom: 2vh;
flex-shrink: 0;
}
.header h1 {
font-size: clamp(1.8rem, 4vw, 2.5rem);
margin-bottom: 0.5vh;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.header h1 {
font-size: clamp(1.8rem, 4vw, 2.5rem);
margin-bottom: 0.5vh;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.header p {
font-size: clamp(0.8rem, 1.8vw, 1rem);
}
.header p {
font-size: clamp(0.8rem, 1.8vw, 1rem);
}
.timer-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: clamp(15px, 2vw, 30px);
width: 100%;
max-width: 100%;
flex-grow: 1;
padding: 0 2vw;
max-height: 60vh;
}
.timer-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: clamp(15px, 2vw, 30px);
width: 100%;
max-width: 100%;
flex-grow: 1;
padding: 0 2vw;
max-height: 60vh;
}
@media (max-width: 768px) {
.timer-container {
grid-template-columns: 1fr;
gap: clamp(15px, 3vw, 30px);
padding: 0 15px;
}
}
@media (max-width: 768px) {
.timer-container {
grid-template-columns: 1fr;
gap: clamp(15px, 3vw, 30px);
padding: 0 15px;
}
}
.lane {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: clamp(15px, 2.5vh, 25px);
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
overflow: hidden;
}
.lane {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: clamp(15px, 2.5vh, 25px);
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
overflow: hidden;
}
.lane h2 {
font-size: clamp(1.2rem, 2.5vw, 1.8rem);
margin-bottom: clamp(10px, 1vh, 15px);
color: #fff;
}
.lane h2 {
font-size: clamp(1.2rem, 2.5vw, 1.8rem);
margin-bottom: clamp(10px, 1vh, 15px);
color: #fff;
}
.swimmer-name {
font-size: clamp(1.5rem, 3.5vw, 2.2rem);
font-weight: bold;
margin-bottom: clamp(15px, 2vh, 25px);
padding: clamp(8px, 1.5vh, 12px) clamp(12px, 2vw, 18px);
background: rgba(255, 255, 255, 0.2);
border-radius: 15px;
border: 2px solid rgba(255, 255, 255, 0.3);
color: #fff;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(5px);
animation: fadeIn 0.5s ease-in;
text-align: center;
word-wrap: break-word;
line-height: 1.2;
}
.swimmer-name {
font-size: clamp(1.5rem, 3.5vw, 2.2rem);
font-weight: bold;
margin-bottom: clamp(15px, 2vh, 25px);
padding: clamp(8px, 1.5vh, 12px) clamp(12px, 2vw, 18px);
background: rgba(255, 255, 255, 0.2);
border-radius: 15px;
border: 2px solid rgba(255, 255, 255, 0.3);
color: #fff;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(5px);
animation: fadeIn 0.5s ease-in;
text-align: center;
word-wrap: break-word;
line-height: 1.2;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.time-display {
font-size: clamp(3rem, 9vw, 10rem);
font-weight: bold;
margin: clamp(10px, 1vh, 15px) 0;
font-family: "Courier New", monospace;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
line-height: 1;
}
.time-display {
font-size: clamp(3rem, 9vw, 10rem);
font-weight: bold;
margin: clamp(10px, 1vh, 15px) 0;
font-family: "Courier New", monospace;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
line-height: 1;
}
.status {
font-size: clamp(3rem, 1.8vw, 1.2rem);
margin: clamp(8px, 1vh, 12px) 0;
padding: clamp(6px, 1vh, 10px) clamp(12px, 2vw, 18px);
border-radius: 20px;
display: inline-block;
font-weight: 600;
}
.status {
font-size: clamp(3rem, 1.8vw, 1.2rem);
margin: clamp(8px, 1vh, 12px) 0;
padding: clamp(6px, 1vh, 10px) clamp(12px, 2vw, 18px);
border-radius: 20px;
display: inline-block;
font-weight: 600;
}
.status.ready {
background-color: rgba(52, 152, 219, 0.3);
border: 2px solid #3498db;
}
.status.ready {
background-color: rgba(52, 152, 219, 0.3);
border: 2px solid #3498db;
}
.status.running {
background-color: rgba(46, 204, 113, 0.3);
border: 2px solid #2ecc71;
animation: pulse 1s infinite;
}
.status.running {
background-color: rgba(46, 204, 113, 0.3);
border: 2px solid #2ecc71;
animation: pulse 1s infinite;
}
.status.finished {
background-color: rgba(231, 76, 60, 0.3);
border: 2px solid #e74c3c;
}
.status.finished {
background-color: rgba(231, 76, 60, 0.3);
border: 2px solid #e74c3c;
}
@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0.7;
}
100% {
opacity: 1;
}
}
@keyframes pulse {
0% {
opacity: 1;
}
50% {
opacity: 0.7;
}
100% {
opacity: 1;
}
}
.best-times {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: clamp(10px, 1.5vh, 15px);
margin: 1vh 0 0 0;
width: 50%;
max-width: 50%;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
flex-shrink: 0;
align-self: center;
}
.best-times {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: clamp(10px, 1.5vh, 15px);
margin: 1vh 0 0 0;
width: 50%;
max-width: 50%;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.2);
flex-shrink: 0;
align-self: center;
}
.best-times h3 {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
margin-bottom: clamp(5px, 0.5vh, 8px);
}
.best-times h3 {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
margin-bottom: clamp(5px, 0.5vh, 8px);
}
.best-time-row {
display: flex;
justify-content: space-between;
margin: clamp(3px, 0.5vh, 5px) 0;
font-size: clamp(0.8rem, 1.5vw, 1rem);
font-weight: 500;
background: rgba(255, 255, 255, 0.1);
padding: clamp(5px, 1vh, 8px) clamp(8px, 1.5vw, 12px);
border-radius: 8px;
}
.best-time-row {
display: flex;
justify-content: space-between;
margin: clamp(3px, 0.5vh, 5px) 0;
font-size: clamp(0.8rem, 1.5vw, 1rem);
font-weight: 500;
background: rgba(255, 255, 255, 0.1);
padding: clamp(5px, 1vh, 8px) clamp(8px, 1.5vw, 12px);
border-radius: 8px;
}
.learning-mode {
background: rgba(255, 193, 7, 0.2);
border: 2px solid #ffc107;
border-radius: 15px;
padding: clamp(15px, 2vh, 20px);
margin: 2vh 0;
text-align: center;
animation: pulse 2s infinite;
width: 100%;
position: absolute;
top: 15vh;
left: 50%;
transform: translateX(-50%);
z-index: 100;
}
.learning-mode {
background: rgba(255, 193, 7, 0.2);
border: 2px solid #ffc107;
border-radius: 15px;
padding: clamp(15px, 2vh, 20px);
margin: 2vh 0;
text-align: center;
animation: pulse 2s infinite;
width: 100%;
position: absolute;
top: 15vh;
left: 50%;
transform: translateX(-50%);
z-index: 100;
}
.learning-mode h3 {
color: #ffc107;
margin-bottom: 10px;
font-size: clamp(1rem, 2vw, 1.3rem);
}
.learning-mode h3 {
color: #ffc107;
margin-bottom: 10px;
font-size: clamp(1rem, 2vw, 1.3rem);
}
.learning-mode p {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
}
.learning-mode p {
font-size: clamp(0.9rem, 1.8vw, 1.1rem);
}

View File

@@ -3,12 +3,11 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="index.css" />
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico">
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico" />
<title>NinjaCross Timer</title>
</head>
<body>
<body>
<!-- Batterie-Banner -->
<div id="battery-banner" class="battery-banner">
<div class="banner-content">
@@ -27,9 +26,17 @@
<a href="/settings" class="settings-btn">⚙️</a>
<div class="heartbeat-indicators">
<div class="heartbeat-indicator" id="heartbeat1" data-label="Start1"></div>
<div
class="heartbeat-indicator"
id="heartbeat1"
data-label="Start1"
></div>
<div class="heartbeat-indicator" id="heartbeat2" data-label="Stop1"></div>
<div class="heartbeat-indicator" id="heartbeat3" data-label="Start2"></div>
<div
class="heartbeat-indicator"
id="heartbeat3"
data-label="Start2"
></div>
<div class="heartbeat-indicator" id="heartbeat4" data-label="Stop2"></div>
</div>
@@ -47,14 +54,14 @@
<div class="timer-container">
<div class="lane">
<div id="name1" class="swimmer-name" style="display: none;"></div>
<div id="name1" class="swimmer-name" style="display: none"></div>
<h2>🏊‍♀️ Bahn 1</h2>
<div id="time1" class="time-display">00.00</div>
<div id="status1" class="status ready">Bereit</div>
</div>
<div class="lane">
<div id="name2" class="swimmer-name" style="display: none;"></div>
<div id="name2" class="swimmer-name" style="display: none"></div>
<h2>🏊‍♂️ Bahn 2</h2>
<div id="time2" class="time-display">00.00</div>
<div id="status2" class="status ready">Bereit</div>
@@ -102,8 +109,8 @@
};
// Set all heartbeats to red initially
["heartbeat1", "heartbeat2", "heartbeat3", "heartbeat4"].forEach(id => {
document.getElementById(id).classList.remove('active');
["heartbeat1", "heartbeat2", "heartbeat3", "heartbeat4"].forEach((id) => {
document.getElementById(id).classList.remove("active");
});
// Handle WebSocket events
@@ -136,15 +143,21 @@
if (indicatorId) {
heartbeatTimeouts[data.button] = Date.now();
document.getElementById(indicatorId).classList.add('active');
document.getElementById(indicatorId).classList.add("active");
}
}
// Namen-Handling
if ((data.firstname == "" || data.lastname == "") && data.lane == "start1") {
if (
(data.firstname == "" || data.lastname == "") &&
data.lane == "start1"
) {
name1 = "";
}
if ((data.firstname == "" || data.lastname == "") && data.lane == "start2") {
if (
(data.firstname == "" || data.lastname == "") &&
data.lane == "start2"
) {
name2 = "";
}
@@ -184,7 +197,7 @@
lowBatteryDevices.add({
button: data.button,
mac: data.mac,
battery: batteryLevel
battery: batteryLevel,
});
}
@@ -193,7 +206,7 @@
}
} else {
// Gerät aus niedrige Batterie Liste entfernen
lowBatteryDevices.forEach(device => {
lowBatteryDevices.forEach((device) => {
if (device.button === data.button && device.mac === data.mac) {
lowBatteryDevices.delete(device);
}
@@ -217,11 +230,11 @@
lowBatteryDevices.clear();
if (data.devices && data.devices.length > 0) {
data.devices.forEach(device => {
data.devices.forEach((device) => {
lowBatteryDevices.add({
button: device.button,
mac: device.mac,
battery: device.battery || 0
battery: device.battery || 0,
});
});
@@ -235,27 +248,29 @@
// Batterie-Banner anzeigen
function showBatteryBanner() {
const banner = document.getElementById('battery-banner');
const deviceList = document.getElementById('low-battery-list');
const banner = document.getElementById("battery-banner");
const deviceList = document.getElementById("low-battery-list");
// Geräteliste erstellen
const deviceNames = Array.from(lowBatteryDevices).map(device => {
const buttonName = getButtonDisplayName(device.button);
return `${buttonName} (${device.battery}%)`;
}).join(', ');
const deviceNames = Array.from(lowBatteryDevices)
.map((device) => {
const buttonName = getButtonDisplayName(device.button);
return `${buttonName} (${device.battery}%)`;
})
.join(", ");
deviceList.textContent = deviceNames;
// Banner anzeigen
banner.classList.add('show');
document.body.classList.add('content-shifted');
banner.classList.add("show");
document.body.classList.add("content-shifted");
}
// Batterie-Banner verstecken
function hideBatteryBanner() {
const banner = document.getElementById('battery-banner');
banner.classList.remove('show');
document.body.classList.remove('content-shifted');
const banner = document.getElementById("battery-banner");
banner.classList.remove("show");
document.body.classList.remove("content-shifted");
batteryBannerDismissed = false;
}
@@ -267,12 +282,17 @@
// Button-Namen für Anzeige
function getButtonDisplayName(button) {
switch(button) {
case 'start1': return 'Start Bahn 1';
case 'stop1': return 'Stop Bahn 1';
case 'start2': return 'Start Bahn 2';
case 'stop2': return 'Stop Bahn 2';
default: return button;
switch (button) {
case "start1":
return "Start Bahn 1";
case "stop1":
return "Stop Bahn 1";
case "start2":
return "Start Bahn 2";
case "stop2":
return "Stop Bahn 2";
default:
return button;
}
}
@@ -301,8 +321,8 @@
status1 === "ready"
? "Bereit"
: status1 === "running"
? "Läuft..."
: "Beendet";
? "Läuft..."
: "Beendet";
document.getElementById("time2").textContent = formatTime(display2);
const s2 = document.getElementById("status2");
@@ -311,8 +331,8 @@
status2 === "ready"
? "Bereit"
: status2 === "running"
? "Läuft..."
: "Beendet";
? "Läuft..."
: "Beendet";
document.getElementById("best1").textContent =
best1 > 0 ? formatTime(best1) + "s" : "--.-";
@@ -340,7 +360,8 @@
// Lernmodus
const learningDisplay = document.getElementById("learning-display");
if (learningMode) {
document.getElementById("learning-button").textContent = learningButton;
document.getElementById("learning-button").textContent =
learningButton;
learningDisplay.style.display = "block";
} else {
learningDisplay.style.display = "none";
@@ -363,7 +384,7 @@
updateDisplay();
})
.catch((error) =>
console.error("Fehler beim Laden der Daten:", error)
console.error("Fehler beim Laden der Daten:", error),
);
}
@@ -377,13 +398,13 @@
setInterval(() => {
const now = Date.now();
[
{button: "start1", id: "heartbeat1"},
{button: "stop1", id: "heartbeat2"},
{button: "start2", id: "heartbeat3"},
{button: "stop2", id: "heartbeat4"},
].forEach(({button, id}) => {
{ button: "start1", id: "heartbeat1" },
{ button: "stop1", id: "heartbeat2" },
{ button: "start2", id: "heartbeat3" },
{ button: "stop2", id: "heartbeat4" },
].forEach(({ button, id }) => {
if (now - heartbeatTimeouts[button] > 10000) {
document.getElementById(id).classList.remove('active');
document.getElementById(id).classList.remove("active");
}
});
}, 1000);

View File

@@ -1,235 +1,242 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: rgba(255, 255, 255, 0.95);
padding: 40px;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
width: 100%;
max-width: 500px;
animation: slideIn 0.5s ease-out;
}
.container {
background: rgba(255, 255, 255, 0.95);
padding: 40px;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
width: 100%;
max-width: 500px;
animation: slideIn 0.5s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.header {
text-align: center;
margin-bottom: 30px;
}
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
color: #333;
font-size: 2em;
margin-bottom: 10px;
}
.header h1 {
color: #333;
font-size: 2em;
margin-bottom: 10px;
}
.header p {
color: #666;
font-size: 1.1em;
}
.header p {
color: #666;
font-size: 1.1em;
}
.form-group {
margin-bottom: 25px;
position: relative;
}
.form-group {
margin-bottom: 25px;
position: relative;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 1em;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 1em;
}
.form-group input {
width: 100%;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 10px;
font-size: 1em;
transition: all 0.3s ease;
background: #fff;
}
.form-group input {
width: 100%;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 10px;
font-size: 1em;
transition: all 0.3s ease;
background: #fff;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
transform: translateY(-2px);
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
transform: translateY(-2px);
}
.form-group input:hover {
border-color: #667eea;
}
.form-group input:hover {
border-color: #667eea;
}
.required {
color: #e74c3c;
}
.required {
color: #e74c3c;
}
.btn-container {
display: flex;
gap: 15px;
margin-top: 30px;
}
.btn-container {
display: flex;
gap: 15px;
margin-top: 30px;
}
.btn {
flex: 1;
padding: 15px 25px;
border: none;
border-radius: 10px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.btn {
flex: 1;
padding: 15px 25px;
border: none;
border-radius: 10px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.btn-secondary {
background: #f8f9fa;
color: #666;
border: 2px solid #e1e5e9;
}
.btn-secondary {
background: #f8f9fa;
color: #666;
border: 2px solid #e1e5e9;
}
.btn-secondary:hover {
background: #e9ecef;
transform: translateY(-2px);
}
.btn-secondary:hover {
background: #e9ecef;
transform: translateY(-2px);
}
.success-message {
background: #d4edda;
color: #155724;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #c3e6cb;
animation: fadeIn 0.3s ease-out;
}
.success-message {
background: #d4edda;
color: #155724;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #c3e6cb;
animation: fadeIn 0.3s ease-out;
}
.read-uid-btn {
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
color: white;
border: none;
padding: 15px 20px;
border-radius: 10px;
font-size: 0.9em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
white-space: nowrap;
min-width: 120px;
}
.read-uid-btn {
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
color: white;
border: none;
padding: 15px 20px;
border-radius: 10px;
font-size: 0.9em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
white-space: nowrap;
min-width: 120px;
}
.read-uid-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(40, 167, 69, 0.3);
}
.read-uid-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(40, 167, 69, 0.3);
}
.read-uid-btn:disabled {
background: #6c757d;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.read-uid-btn:disabled {
background: #6c757d;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.read-uid-btn.reading {
background: linear-gradient(135deg, #fd7e14 0%, #e83e8c 100%);
animation: pulse 1.5s infinite;
}
.read-uid-btn.reading {
background: linear-gradient(135deg, #fd7e14 0%, #e83e8c 100%);
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* Geburtsdatum Styling */
.date-input-group {
position: relative;
}
/* Geburtsdatum Styling */
.date-input-group {
position: relative;
}
.date-input-group input[type="date"] {
position: relative;
color-scheme: light;
}
.date-input-group input[type="date"] {
position: relative;
color-scheme: light;
}
.date-input-group input[type="date"]::-webkit-calendar-picker-indicator {
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23667eea" viewBox="0 0 16 16"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/></svg>') no-repeat;
background-size: contain;
width: 20px;
height: 20px;
cursor: pointer;
}
.date-input-group input[type="date"]::-webkit-calendar-picker-indicator {
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23667eea" viewBox="0 0 16 16"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/></svg>')
no-repeat;
background-size: contain;
width: 20px;
height: 20px;
cursor: pointer;
}
.age-display {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
color: #667eea;
font-weight: 600;
font-size: 0.9em;
pointer-events: none;
background: rgba(255, 255, 255, 0.9);
padding: 2px 8px;
border-radius: 4px;
border: 1px solid #e1e5e9;
}
.age-display {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
color: #667eea;
font-weight: 600;
font-size: 0.9em;
pointer-events: none;
background: rgba(255, 255, 255, 0.9);
padding: 2px 8px;
border-radius: 4px;
border: 1px solid #e1e5e9;
}
@media (max-width: 600px) {
.container {
padding: 30px 20px;
margin: 10px;
}
@media (max-width: 600px) {
.container {
padding: 30px 20px;
margin: 10px;
}
.btn-container {
flex-direction: column;
}
}
.btn-container {
flex-direction: column;
}
}

View File

@@ -1,206 +1,278 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="rfid.css" />
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico">
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico" />
<title>RFID Daten Eingabe</title>
</head>
<body>
</head>
<body>
<div class="container">
<div class="header">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<button onclick="window.location.href='/settings'" class="back-btn" style="background: #6c757d; color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 5px;">
← Zurück zu Einstellungen
</button>
</div>
<h1>🏷️ RFID Daten Eingabe</h1>
<p>Erfassen Sie RFID-Tag Informationen</p>
<div class="header">
<div
style="
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
"
>
<button
onclick="window.location.href='/settings'"
class="back-btn"
style="
background: #6c757d;
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
display: flex;
align-items: center;
gap: 5px;
"
>
← Zurück zu Einstellungen
</button>
</div>
<h1>🏷️ RFID Daten Eingabe</h1>
<p>Erfassen Sie RFID-Tag Informationen</p>
</div>
<div id="successMessage" class="success-message" style="display: none">
✅ Daten erfolgreich gespeichert!
</div>
<form id="rfidForm">
<div class="form-group">
<label for="uid">RFID UID <span class="required">*</span></label>
<div style="display: flex; gap: 10px; align-items: stretch">
<input
type="text"
id="uid"
name="uid"
placeholder="z.B. A1:B2:C3:D4"
required
style="flex: 1"
/>
<button
type="button"
id="readUidBtn"
class="read-uid-btn"
onclick="readRFIDUID()"
>
📡 Read Chip
</button>
</div>
</div>
<div id="successMessage" class="success-message" style="display: none;">
✅ Daten erfolgreich gespeichert!
<div class="form-group">
<label for="vorname">Vorname <span class="required">*</span></label>
<input
type="text"
id="vorname"
name="vorname"
placeholder="Vorname eingeben"
required
/>
</div>
<form id="rfidForm">
<div class="form-group">
<label for="uid">RFID UID <span class="required">*</span></label>
<div style="display: flex; gap: 10px; align-items: stretch;">
<input type="text" id="uid" name="uid" placeholder="z.B. A1:B2:C3:D4" required style="flex: 1;">
<button type="button" id="readUidBtn" class="read-uid-btn" onclick="readRFIDUID()">
📡 Read Chip
</button>
</div>
</div>
<div class="form-group">
<label for="nachname">Nachname <span class="required">*</span></label>
<input
type="text"
id="nachname"
name="nachname"
placeholder="Nachname eingeben"
required
/>
</div>
<div class="form-group">
<label for="vorname">Vorname <span class="required">*</span></label>
<input type="text" id="vorname" name="vorname" placeholder="Vorname eingeben" required>
</div>
<div class="form-group">
<label for="nachname">Nachname <span class="required">*</span></label>
<input type="text" id="nachname" name="nachname" placeholder="Nachname eingeben" required>
</div>
<div class="form-group">
<label for="geburtsdatum">Geburtsdatum <span class="required">*</span></label>
<div class="date-input-group">
<input type="date" id="geburtsdatum" name="geburtsdatum" required max="">
<div id="ageDisplay" class="age-display" style="display: none;"></div>
</div>
</div>
<div class="btn-container">
<button type="submit" class="btn btn-primary">💾 Speichern</button>
<button type="button" class="btn btn-secondary" onclick="clearForm()">🗑️ Zurücksetzen</button>
</div>
</form>
<div class="form-group">
<label for="geburtsdatum"
>Geburtsdatum <span class="required">*</span></label
>
<div class="date-input-group">
<input
type="date"
id="geburtsdatum"
name="geburtsdatum"
required
max=""
/>
<div
id="ageDisplay"
class="age-display"
style="display: none"
></div>
</div>
</div>
<div class="btn-container">
<button type="submit" class="btn btn-primary">💾 Speichern</button>
<button type="button" class="btn btn-secondary" onclick="clearForm()">
🗑️ Zurücksetzen
</button>
</div>
</form>
</div>
<script>
// Globale Variablen
let rfidData = [];
let isLoading = false;
let DBUrl = "db.reptilfpv.de:3000";
var APIKey;
// Globale Variablen
let rfidData = [];
let isLoading = false;
let DBUrl = "db.reptilfpv.de:3000";
var APIKey;
// Maximales Datum auf heute setzen
document.addEventListener('DOMContentLoaded', function() {
const today = new Date().toISOString().split('T')[0];
document.getElementById('geburtsdatum').setAttribute('max', today);
});
// Maximales Datum auf heute setzen
document.addEventListener("DOMContentLoaded", function () {
const today = new Date().toISOString().split("T")[0];
document.getElementById("geburtsdatum").setAttribute("max", today);
});
// Alter berechnen und anzeigen
function calculateAge(birthDate) {
const today = new Date();
const birth = new Date(birthDate);
let age = today.getFullYear() - birth.getFullYear();
const monthDiff = today.getMonth() - birth.getMonth();
// Alter berechnen und anzeigen
function calculateAge(birthDate) {
const today = new Date();
const birth = new Date(birthDate);
let age = today.getFullYear() - birth.getFullYear();
const monthDiff = today.getMonth() - birth.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
age--;
}
return age;
if (
monthDiff < 0 ||
(monthDiff === 0 && today.getDate() < birth.getDate())
) {
age--;
}
// Geburtsdatum Change Event
document.getElementById('geburtsdatum').addEventListener('change', function(e) {
const birthDate = e.target.value;
const ageDisplay = document.getElementById('ageDisplay');
return age;
}
if (birthDate) {
const age = calculateAge(birthDate);
if (age >= 0 && age <= 150) {
ageDisplay.textContent = `${age} Jahre`;
ageDisplay.style.display = 'block';
} else {
ageDisplay.style.display = 'none';
if (age < 0) {
showErrorMessage('Das Geburtsdatum kann nicht in der Zukunft liegen!');
e.target.value = '';
} else {
showErrorMessage('Bitte überprüfen Sie das Geburtsdatum!');
e.target.value = '';
}
}
// Geburtsdatum Change Event
document
.getElementById("geburtsdatum")
.addEventListener("change", function (e) {
const birthDate = e.target.value;
const ageDisplay = document.getElementById("ageDisplay");
if (birthDate) {
const age = calculateAge(birthDate);
if (age >= 0 && age <= 150) {
ageDisplay.textContent = `${age} Jahre`;
ageDisplay.style.display = "block";
} else {
ageDisplay.style.display = 'none';
ageDisplay.style.display = "none";
if (age < 0) {
showErrorMessage(
"Das Geburtsdatum kann nicht in der Zukunft liegen!",
);
e.target.value = "";
} else {
showErrorMessage("Bitte überprüfen Sie das Geburtsdatum!");
e.target.value = "";
}
}
} else {
ageDisplay.style.display = "none";
}
});
// Form Submit Handler
document.getElementById('rfidForm').addEventListener('submit', async function(e) {
e.preventDefault();
// Form Submit Handler
document
.getElementById("rfidForm")
.addEventListener("submit", async function (e) {
e.preventDefault();
if (isLoading) return;
if (isLoading) return;
// Daten aus dem Formular holen
const uid = document.getElementById('uid').value.trim();
const vorname = document.getElementById('vorname').value.trim();
const nachname = document.getElementById('nachname').value.trim();
const geburtsdatum = document.getElementById('geburtsdatum').value;
// Daten aus dem Formular holen
const uid = document.getElementById("uid").value.trim();
const vorname = document.getElementById("vorname").value.trim();
const nachname = document.getElementById("nachname").value.trim();
const geburtsdatum = document.getElementById("geburtsdatum").value;
// Validierung
if (!uid || !vorname || !nachname || !geburtsdatum) {
showErrorMessage('Bitte füllen Sie alle Pflichtfelder aus!');
return;
}
// Alter berechnen
const alter = calculateAge(geburtsdatum);
if (alter < 0) {
showErrorMessage('Das Geburtsdatum kann nicht in der Zukunft liegen!');
return;
}
// Loading State
setLoadingState(true);
try {
// API Aufruf zum Erstellen des Benutzers
const response = await fetch(`/api/users/insert`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
uid: uid,
vorname: vorname,
nachname: nachname,
geburtsdatum: geburtsdatum,
alter: alter // Berechnetes Alter wird mit gesendet
})
});
const result = await response.json();
if (result.success) {
// Erfolg anzeigen
showSuccessMessage('Benutzer erfolgreich gespeichert!');
// Formular zurücksetzen
clearForm();
// UID Feld fokussieren für nächsten Eintrag
setTimeout(() => {
document.getElementById('uid').focus();
}, 100);
} else {
// Fehler anzeigen
showErrorMessage(result.error || 'Fehler beim Speichern der Daten');
}
} catch (error) {
console.error('Fehler beim Speichern:', error);
showErrorMessage('Verbindungsfehler zum Server. Bitte versuchen Sie es später erneut.');
} finally {
setLoadingState(false);
// Validierung
if (!uid || !vorname || !nachname || !geburtsdatum) {
showErrorMessage("Bitte füllen Sie alle Pflichtfelder aus!");
return;
}
// Alter berechnen
const alter = calculateAge(geburtsdatum);
if (alter < 0) {
showErrorMessage(
"Das Geburtsdatum kann nicht in der Zukunft liegen!",
);
return;
}
// Loading State
setLoadingState(true);
try {
// API Aufruf zum Erstellen des Benutzers
const response = await fetch(`/api/users/insert`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
uid: uid,
vorname: vorname,
nachname: nachname,
geburtsdatum: geburtsdatum,
alter: alter, // Berechnetes Alter wird mit gesendet
}),
});
const result = await response.json();
if (result.success) {
// Erfolg anzeigen
showSuccessMessage("Benutzer erfolgreich gespeichert!");
// Formular zurücksetzen
clearForm();
// UID Feld fokussieren für nächsten Eintrag
setTimeout(() => {
document.getElementById("uid").focus();
}, 100);
} else {
// Fehler anzeigen
showErrorMessage(
result.error || "Fehler beim Speichern der Daten",
);
}
} catch (error) {
console.error("Fehler beim Speichern:", error);
showErrorMessage(
"Verbindungsfehler zum Server. Bitte versuchen Sie es später erneut.",
);
} finally {
setLoadingState(false);
}
});
function showSuccessMessage(message = 'Daten erfolgreich gespeichert!') {
const successMsg = document.getElementById('successMessage');
successMsg.textContent = `${message}`;
successMsg.style.display = 'block';
setTimeout(() => {
successMsg.style.display = 'none';
}, 3000);
}
function showSuccessMessage(message = "Daten erfolgreich gespeichert!") {
const successMsg = document.getElementById("successMessage");
successMsg.textContent = `${message}`;
successMsg.style.display = "block";
setTimeout(() => {
successMsg.style.display = "none";
}, 3000);
}
function showErrorMessage(message) {
// Fehlermeldung dynamisch erstellen
let errorDiv = document.getElementById('errorMessage');
if (!errorDiv) {
errorDiv = document.createElement('div');
errorDiv.id = 'errorMessage';
errorDiv.className = 'error-message';
errorDiv.style.cssText = `
function showErrorMessage(message) {
// Fehlermeldung dynamisch erstellen
let errorDiv = document.getElementById("errorMessage");
if (!errorDiv) {
errorDiv = document.createElement("div");
errorDiv.id = "errorMessage";
errorDiv.className = "error-message";
errorDiv.style.cssText = `
background: #f8d7da;
color: #721c24;
padding: 15px;
@@ -210,159 +282,164 @@
animation: fadeIn 0.3s ease-out;
display: none;
`;
document.querySelector('.container').insertBefore(errorDiv, document.getElementById('rfidForm'));
}
document
.querySelector(".container")
.insertBefore(errorDiv, document.getElementById("rfidForm"));
}
errorDiv.textContent = `${message}`;
errorDiv.style.display = 'block';
errorDiv.textContent = `${message}`;
errorDiv.style.display = "block";
setTimeout(() => {
errorDiv.style.display = "none";
}, 10000);
}
function setLoadingState(loading) {
isLoading = loading;
const submitBtn = document.querySelector(".btn-primary");
const form = document.getElementById("rfidForm");
if (loading) {
submitBtn.textContent = "⏳ Speichern...";
submitBtn.disabled = true;
form.style.opacity = "0.7";
} else {
submitBtn.textContent = "💾 Speichern";
submitBtn.disabled = false;
form.style.opacity = "1";
}
}
function clearForm() {
document.getElementById("rfidForm").reset();
document.getElementById("ageDisplay").style.display = "none";
document.getElementById("uid").focus();
}
// Beim Laden der Seite
window.addEventListener("load", function () {
document.getElementById("uid").focus();
checkServerStatus();
loadLicence();
});
// Enter-Taste in UID Feld zum nächsten Feld springen
document.getElementById("uid").addEventListener("keydown", function (e) {
if (e.key === "Enter") {
e.preventDefault();
document.getElementById("vorname").focus();
}
});
// Automatische UID Formatierung
document.getElementById("uid").addEventListener("input", function (e) {
let value = e.target.value.toUpperCase();
// Entfernen aller nicht-hexadezimalen Zeichen außer Doppelpunkt
value = value.replace(/[^0-9A-F:]/g, "");
e.target.value = value;
});
// RFID UID lesen
async function readRFIDUID() {
const readBtn = document.getElementById("readUidBtn");
const uidInput = document.getElementById("uid");
// Button Status ändern
readBtn.disabled = true;
readBtn.className = "read-uid-btn reading";
readBtn.innerHTML = "📡 Lese UID...";
try {
// API Aufruf zum RFID Reader
const response = await fetch(`/api/rfid/read`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const result = await response.json();
if (result.success && result.uid) {
// UID in das Eingabefeld setzen
uidInput.value = result.uid
.match(/.{1,2}/g)
.join(":")
.toUpperCase();
uidInput.focus();
// Visuelles Feedback
uidInput.style.borderColor = "#28a745";
setTimeout(() => {
errorDiv.style.display = 'none';
uidInput.style.borderColor = "#e1e5e9";
}, 2000);
showSuccessMessage("UID erfolgreich gelesen!");
// Automatisch zum nächsten Feld springen
setTimeout(() => {
document.getElementById("vorname").focus();
}, 500);
} else {
// Fehler beim Lesen
const errorMsg = result.error || "Keine UID gefunden";
showErrorMessage(`RFID Fehler: ${errorMsg}`);
// UID Feld rot markieren
uidInput.style.borderColor = "#dc3545";
setTimeout(() => {
uidInput.style.borderColor = "#e1e5e9";
}, 10000);
}
} catch (error) {
console.error("Fehler beim Lesen der UID:", error);
showErrorMessage(
"Verbindungsfehler zum RFID Reader. Bitte prüfen Sie die Verbindung.",
);
// UID Feld rot markieren
uidInput.style.borderColor = "#dc3545";
setTimeout(() => {
uidInput.style.borderColor = "#e1e5e9";
}, 3000);
} finally {
// Button Status zurücksetzen
readBtn.disabled = false;
readBtn.className = "read-uid-btn";
readBtn.innerHTML = "📡 Read Chip";
}
}
function setLoadingState(loading) {
isLoading = loading;
const submitBtn = document.querySelector('.btn-primary');
const form = document.getElementById('rfidForm');
async function checkServerStatus() {
try {
const response = await fetch("/api/health");
const data = await response.json();
if (loading) {
submitBtn.textContent = '⏳ Speichern...';
submitBtn.disabled = true;
form.style.opacity = '0.7';
} else {
submitBtn.textContent = '💾 Speichern';
submitBtn.disabled = false;
form.style.opacity = '1';
}
if (!data.status || data.status !== "connected") {
showErrorMessage(
"Server nicht verbunden. Einige Funktionen könnten eingeschränkt sein.",
);
return false;
}
return true;
} catch (error) {
console.error("Server Status Check fehlgeschlagen:", error);
showErrorMessage("Verbindung zum Server nicht möglich.");
return false;
}
}
function clearForm() {
document.getElementById('rfidForm').reset();
document.getElementById('ageDisplay').style.display = 'none';
document.getElementById('uid').focus();
}
// Beim Laden der Seite
window.addEventListener('load', function() {
document.getElementById('uid').focus();
checkServerStatus();
loadLicence();
});
// Enter-Taste in UID Feld zum nächsten Feld springen
document.getElementById('uid').addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
document.getElementById('vorname').focus();
}
});
// Automatische UID Formatierung
document.getElementById('uid').addEventListener('input', function(e) {
let value = e.target.value.toUpperCase();
// Entfernen aller nicht-hexadezimalen Zeichen außer Doppelpunkt
value = value.replace(/[^0-9A-F:]/g, '');
e.target.value = value;
});
// RFID UID lesen
async function readRFIDUID() {
const readBtn = document.getElementById('readUidBtn');
const uidInput = document.getElementById('uid');
// Button Status ändern
readBtn.disabled = true;
readBtn.className = 'read-uid-btn reading';
readBtn.innerHTML = '📡 Lese UID...';
try {
// API Aufruf zum RFID Reader
const response = await fetch(`/api/rfid/read`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
});
const result = await response.json();
if (result.success && result.uid) {
// UID in das Eingabefeld setzen
uidInput.value = result.uid.match(/.{1,2}/g).join(':').toUpperCase();
uidInput.focus();
// Visuelles Feedback
uidInput.style.borderColor = '#28a745';
setTimeout(() => {
uidInput.style.borderColor = '#e1e5e9';
}, 2000);
showSuccessMessage('UID erfolgreich gelesen!');
// Automatisch zum nächsten Feld springen
setTimeout(() => {
document.getElementById('vorname').focus();
}, 500);
} else {
// Fehler beim Lesen
const errorMsg = result.error || 'Keine UID gefunden';
showErrorMessage(`RFID Fehler: ${errorMsg}`);
// UID Feld rot markieren
uidInput.style.borderColor = '#dc3545';
setTimeout(() => {
uidInput.style.borderColor = '#e1e5e9';
}, 10000);
}
} catch (error) {
console.error('Fehler beim Lesen der UID:', error);
showErrorMessage('Verbindungsfehler zum RFID Reader. Bitte prüfen Sie die Verbindung.');
// UID Feld rot markieren
uidInput.style.borderColor = '#dc3545';
setTimeout(() => {
uidInput.style.borderColor = '#e1e5e9';
}, 3000);
} finally {
// Button Status zurücksetzen
readBtn.disabled = false;
readBtn.className = 'read-uid-btn';
readBtn.innerHTML = '📡 Read Chip';
}
}
async function checkServerStatus() {
try {
const response = await fetch('/api/health');
const data = await response.json();
if (!data.status || data.status !== 'connected') {
showErrorMessage('Server nicht verbunden. Einige Funktionen könnten eingeschränkt sein.');
return false;
}
return true;
} catch (error) {
console.error('Server Status Check fehlgeschlagen:', error);
showErrorMessage('Verbindung zum Server nicht möglich.');
return false;
}
}
function loadLicence() {
function loadLicence() {
fetch("/api/get-licence")
.then((response) => response.json())
.then((data) => {
APIKey = data.licence || "";
})
.catch((error) =>
showMessage("Fehler beim Laden der Lizenz", "error")
showMessage("Fehler beim Laden der Lizenz", "error"),
);
}
</script>
</body>
</body>
</html>

View File

@@ -1,340 +1,340 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
overflow: hidden;
backdrop-filter: blur(10px);
}
.container {
max-width: 600px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
overflow: hidden;
backdrop-filter: blur(10px);
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
position: relative;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
position: relative;
}
.header::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="40%" r="50%"><stop offset="0%" stop-color="white" stop-opacity="0.1"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><rect width="100" height="20" fill="url(%23a)"/></svg>');
opacity: 0.3;
}
.header::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="40%" r="50%"><stop offset="0%" stop-color="white" stop-opacity="0.1"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><rect width="100" height="20" fill="url(%23a)"/></svg>');
opacity: 0.3;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
position: relative;
z-index: 1;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
position: relative;
z-index: 1;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
position: relative;
z-index: 1;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
position: relative;
z-index: 1;
}
.content {
padding: 40px;
}
.content {
padding: 40px;
}
.nav-buttons {
display: flex;
gap: 15px;
margin-bottom: 30px;
}
.nav-buttons {
display: flex;
gap: 15px;
margin-bottom: 30px;
}
.nav-button {
flex: 1;
padding: 12px 20px;
background: #f8f9fa;
border: 2px solid #e9ecef;
border-radius: 10px;
color: #495057;
text-decoration: none;
text-align: center;
font-weight: 600;
transition: all 0.3s ease;
}
.nav-button {
flex: 1;
padding: 12px 20px;
background: #f8f9fa;
border: 2px solid #e9ecef;
border-radius: 10px;
color: #495057;
text-decoration: none;
text-align: center;
font-weight: 600;
transition: all 0.3s ease;
}
.nav-button:hover {
background: #667eea;
color: white;
border-color: #667eea;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}
.nav-button:hover {
background: #667eea;
color: white;
border-color: #667eea;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}
.section {
margin-bottom: 30px;
background: #f8f9fa;
border-radius: 15px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.section {
margin-bottom: 30px;
background: #f8f9fa;
border-radius: 15px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.section h2 {
color: #495057;
margin-bottom: 20px;
font-size: 1.4em;
display: flex;
align-items: center;
gap: 10px;
}
.section h2 {
color: #495057;
margin-bottom: 20px;
font-size: 1.4em;
display: flex;
align-items: center;
gap: 10px;
}
.section h2::before {
content: "";
width: 4px;
height: 25px;
background: linear-gradient(135deg, #667eea, #764ba2);
border-radius: 2px;
}
.section h2::before {
content: "";
width: 4px;
height: 25px;
background: linear-gradient(135deg, #667eea, #764ba2);
border-radius: 2px;
}
.form-group {
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #495057;
font-weight: 600;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #495057;
font-weight: 600;
}
.form-group input {
width: 100%;
padding: 12px 15px;
border: 2px solid #e9ecef;
border-radius: 10px;
font-size: 16px;
transition: all 0.3s ease;
}
.form-group input {
width: 100%;
padding: 12px 15px;
border: 2px solid #e9ecef;
border-radius: 10px;
font-size: 16px;
transition: all 0.3s ease;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-group input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.time-row {
display: flex;
gap: 15px;
align-items: end;
}
.time-row {
display: flex;
gap: 15px;
align-items: end;
}
.time-input {
flex: 1;
}
.time-input {
flex: 1;
}
.current-time {
background: white;
padding: 15px;
border-radius: 10px;
text-align: center;
font-family: monospace;
font-size: 18px;
color: #495057;
border: 2px solid #e9ecef;
margin-bottom: 15px;
}
.current-time {
background: white;
padding: 15px;
border-radius: 10px;
text-align: center;
font-family: monospace;
font-size: 18px;
color: #495057;
border: 2px solid #e9ecef;
margin-bottom: 15px;
}
.button-group {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.button-group {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.btn {
padding: 15px 25px;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
display: inline-block;
text-align: center;
min-width: 150px;
}
.btn {
padding: 15px 25px;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
display: inline-block;
text-align: center;
min-width: 150px;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}
.btn-secondary {
background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
color: white;
}
.btn-secondary {
background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
color: white;
}
.btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(116, 185, 255, 0.3);
}
.btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(116, 185, 255, 0.3);
}
.btn-warning {
background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
color: #d84315;
}
.btn-warning {
background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
color: #d84315;
}
.btn-warning:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(252, 182, 159, 0.3);
}
.btn-warning:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(252, 182, 159, 0.3);
}
.btn-danger {
background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
color: #c62828;
}
.btn-danger {
background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
color: #c62828;
}
.btn-danger:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(255, 154, 158, 0.3);
}
.btn-danger:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(255, 154, 158, 0.3);
}
.btn-disabled {
background: #e9ecef !important;
color: #6c757d !important;
cursor: not-allowed !important;
transform: none !important;
box-shadow: none !important;
}
.btn-disabled {
background: #e9ecef !important;
color: #6c757d !important;
cursor: not-allowed !important;
transform: none !important;
box-shadow: none !important;
}
.btn-disabled:hover {
transform: none !important;
box-shadow: none !important;
}
.btn-disabled:hover {
transform: none !important;
box-shadow: none !important;
}
.restriction-notice {
background: #fff3cd;
color: #856404;
padding: 15px;
border-radius: 10px;
border: 2px solid #ffeaa7;
margin-bottom: 15px;
font-weight: 600;
text-align: center;
}
.restriction-notice {
background: #fff3cd;
color: #856404;
padding: 15px;
border-radius: 10px;
border: 2px solid #ffeaa7;
margin-bottom: 15px;
font-weight: 600;
text-align: center;
}
.status-message {
margin-top: 20px;
padding: 15px;
border-radius: 10px;
font-weight: 600;
text-align: center;
display: none;
}
.status-message {
margin-top: 20px;
padding: 15px;
border-radius: 10px;
font-weight: 600;
text-align: center;
display: none;
}
.status-success {
background: #d4edda;
color: #155724;
border: 2px solid #c3e6cb;
}
.status-success {
background: #d4edda;
color: #155724;
border: 2px solid #c3e6cb;
}
.status-error {
background: #f8d7da;
color: #721c24;
border: 2px solid #f5c6cb;
}
.status-error {
background: #f8d7da;
color: #721c24;
border: 2px solid #f5c6cb;
}
.status-info {
background: #cce7ff;
color: #004085;
border: 2px solid #b3d9ff;
}
.status-info {
background: #cce7ff;
color: #004085;
border: 2px solid #b3d9ff;
}
.learning-mode {
display: none;
text-align: center;
padding: 30px;
background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
border-radius: 15px;
margin-top: 20px;
}
.learning-mode {
display: none;
text-align: center;
padding: 30px;
background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
border-radius: 15px;
margin-top: 20px;
}
.learning-mode h3 {
color: #d84315;
font-size: 1.5em;
margin-bottom: 15px;
}
.learning-mode h3 {
color: #d84315;
font-size: 1.5em;
margin-bottom: 15px;
}
.learning-mode p {
color: #bf360c;
font-size: 1.2em;
margin-bottom: 20px;
}
.learning-mode p {
color: #bf360c;
font-size: 1.2em;
margin-bottom: 20px;
}
.pulse {
animation: pulse 2s infinite;
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
@media (max-width: 600px) {
.container {
margin: 10px;
border-radius: 15px;
}
@media (max-width: 600px) {
.container {
margin: 10px;
border-radius: 15px;
}
.content {
padding: 20px;
}
.content {
padding: 20px;
}
.nav-buttons {
flex-direction: column;
}
.nav-buttons {
flex-direction: column;
}
.button-group {
flex-direction: column;
}
.button-group {
flex-direction: column;
}
.btn {
width: 100%;
}
.btn {
width: 100%;
}
.time-row {
flex-direction: column;
gap: 10px;
}
}
.time-row {
flex-direction: column;
gap: 10px;
}
}
.section select {
.section select {
width: 100%;
padding: 12px 16px;
font-size: 16px;

View File

@@ -1,10 +1,10 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<!-- Meta Tags -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico">
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico" />
<!-- Stylesheets -->
<link rel="stylesheet" href="settings.css" />
@@ -143,8 +143,14 @@
<!-- WiFi Configuration Section -->
<div class="section" id="wifiSection">
<h2>📡 WLAN-Konfiguration</h2>
<div id="wifiRestrictionNotice" class="restriction-notice" style="display: none;">
🔒 WLAN-Konfiguration ist nur mit Lizenz Level 3 oder höher verfügbar. Aktuelle Lizenz: Level <span id="currentLicenseLevel">0</span>
<div
id="wifiRestrictionNotice"
class="restriction-notice"
style="display: none"
>
🔒 WLAN-Konfiguration ist nur mit Lizenz Level 3 oder höher
verfügbar. Aktuelle Lizenz: Level
<span id="currentLicenseLevel">0</span>
</div>
<form id="wifiForm">
<div class="form-group">
@@ -176,8 +182,14 @@
<div class="section">
<h2>📍 Standort</h2>
<div id="locationRestrictionNotice" class="restriction-notice" style="display: none;">
🔒 Standort-Konfiguration ist nur mit Lizenz Level 3 oder höher verfügbar. Aktuelle Lizenz: Level <span id="currentLocationLicenseLevel">0</span>
<div
id="locationRestrictionNotice"
class="restriction-notice"
style="display: none"
>
🔒 Standort-Konfiguration ist nur mit Lizenz Level 3 oder höher
verfügbar. Aktuelle Lizenz: Level
<span id="currentLocationLicenseLevel">0</span>
</div>
<form id="locationForm">
<div class="form-group">
@@ -187,7 +199,11 @@
</select>
</div>
<div class="button-group">
<button type="submit" id="locationSubmitBtn" class="btn btn-primary">
<button
type="submit"
id="locationSubmitBtn"
class="btn btn-primary"
>
💾 Standort speichern
</button>
</div>
@@ -197,8 +213,13 @@
<!-- OTA Update Section -->
<div class="section">
<h2>🔄 OTA Update</h2>
<div id="otaRestrictionNotice" class="restriction-notice" style="display: none;">
🔒 OTA Updates sind nur mit Lizenz Level 2 oder höher verfügbar. Aktuelle Lizenz: Level <span id="currentLicenseLevel">0</span>
<div
id="otaRestrictionNotice"
class="restriction-notice"
style="display: none"
>
🔒 OTA Updates sind nur mit Lizenz Level 2 oder höher verfügbar.
Aktuelle Lizenz: Level <span id="currentLicenseLevel">0</span>
</div>
<div class="button-group">
<button
@@ -235,7 +256,9 @@
<div>Kanal: <span id="channel">Laden...</span></div>
<div>MAC-Adresse: <span id="macAddress">Laden...</span></div>
<div>Freier Speicher: <span id="freeMemory">Laden...</span></div>
<div>Verbundene Buttons: <span id="connectedButtons">Laden...</span></div>
<div>
Verbundene Buttons: <span id="connectedButtons">Laden...</span>
</div>
<div>Lizenz gültig: <span id="isLicenceValid">Laden...</span></div>
<div>Lizenz Level: <span id="licenceLevel">Laden...</span></div>
</div>
@@ -247,7 +270,12 @@
<form id="licenceForm">
<div class="form-group">
<label for="licencekey">Lizensschlüssel:</label>
<input type="password" id="licencekey" name="licence" value="Key" />
<input
type="password"
id="licencekey"
name="licence"
value="Key"
/>
</div>
<div class="button-group">
<button type="submit" class="btn btn-primary">
@@ -297,9 +325,8 @@
minute: "2-digit",
second: "2-digit",
});
document.getElementById(
"currentTime"
).textContent = `System Zeit: ${timeString}`;
document.getElementById("currentTime").textContent =
`System Zeit: ${timeString}`;
} else {
document.getElementById("currentTime").textContent =
"Aktuelle Zeit: Fehler beim Laden";
@@ -329,7 +356,7 @@
})
.catch((error) => {
console.log(
"Zeit konnte nicht geladen werden, verwende Browser-Zeit"
"Zeit konnte nicht geladen werden, verwende Browser-Zeit",
);
syncWithBrowserTime();
});
@@ -374,12 +401,13 @@
}
})
.catch((error) =>
showMessage("Verbindungsfehler beim Setzen der Zeit", "error")
showMessage("Verbindungsfehler beim Setzen der Zeit", "error"),
);
}
// Zeit setzen
document.getElementById("timeForm")
document
.getElementById("timeForm")
.addEventListener("submit", function (e) {
e.preventDefault();
@@ -410,14 +438,16 @@
}
})
.catch((error) =>
showMessage("Verbindungsfehler beim Setzen der Zeit", "error")
showMessage("Verbindungsfehler beim Setzen der Zeit", "error"),
);
});
document.getElementById("licenceForm").addEventListener("submit", function(e) {
e.preventDefault();
saveLicence();
});
document
.getElementById("licenceForm")
.addEventListener("submit", function (e) {
e.preventDefault();
saveLicence();
});
// Einstellungen laden
function loadSettings() {
@@ -429,7 +459,7 @@
data.maxTimeDisplay || 20;
})
.catch((error) =>
showMessage("Fehler beim Laden der Einstellungen", "error")
showMessage("Fehler beim Laden der Einstellungen", "error"),
);
}
@@ -449,13 +479,13 @@
document.getElementById("connectedButtons").textContent =
data.connectedButtons || 0;
document.getElementById("isLicenceValid").textContent =
data.valid || "";
data.valid || "";
document.getElementById("licenceLevel").textContent =
data.tier || "";
data.tier || "";
// Check license level and update OTA button accordingly
updateOTAButtonAccess(data.tier || 0);
updateWifiButtonAccess(data.tier || 0)
updateWifiButtonAccess(data.tier || 0);
updateLocationAccess(data.tier || 0);
})
.catch((error) => console.log("Info konnte nicht geladen werden"));
@@ -469,7 +499,7 @@
loadLocations();
})
.catch((error) =>
showMessage("Fehler beim Laden der Lizenz", "error")
showMessage("Fehler beim Laden der Lizenz", "error"),
);
}
@@ -500,56 +530,74 @@
// WLAN-Einstellungen laden
function loadWifiSettings() {
fetch("/api/get-wifi")
.then(response => response.json())
.then(data => {
.then((response) => response.json())
.then((data) => {
document.getElementById("wifi-ssid").value = data.ssid || "";
document.getElementById("wifi-password").value = data.password || "";
document.getElementById("wifi-password").value =
data.password || "";
})
.catch(error => showMessage("Fehler beim Laden der WLAN-Einstellungen", "error"));
.catch((error) =>
showMessage("Fehler beim Laden der WLAN-Einstellungen", "error"),
);
}
// WLAN-Einstellungen beim Laden der Seite abrufen
window.addEventListener('load', loadWifiSettings);
window.addEventListener("load", loadWifiSettings);
// WLAN-Formular Handler
document.getElementById("wifiForm").addEventListener("submit", function(e) {
e.preventDefault();
document
.getElementById("wifiForm")
.addEventListener("submit", function (e) {
e.preventDefault();
const ssid = document.getElementById("wifi-ssid").value;
const password = document.getElementById("wifi-password").value;
const ssid = document.getElementById("wifi-ssid").value;
const password = document.getElementById("wifi-password").value;
if (!ssid) {
showMessage("Bitte WLAN-Namen eingeben", "error");
return;
}
if (!confirm("Der Server wird nach dem setzten neu gestartet. Fortsetzten?")) {
return;
}
if (!ssid) {
showMessage("Bitte WLAN-Namen eingeben", "error");
return;
}
if (
!confirm(
"Der Server wird nach dem setzten neu gestartet. Fortsetzten?",
)
) {
return;
}
fetch("/api/set-wifi", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `ssid=${encodeURIComponent(ssid)}&password=${encodeURIComponent(password)}`,
})
.then(response => response.json())
.then(data => {
if (data.success) {
showMessage("WLAN-Einstellungen erfolgreich gespeichert!", "success");
} else {
showMessage(data.error || "Fehler beim Speichern der WLAN-Einstellungen", "error");
}
fetch("/api/set-wifi", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `ssid=${encodeURIComponent(ssid)}&password=${encodeURIComponent(password)}`,
})
.catch(error => showMessage("Verbindungsfehler", "error"));
});
.then((response) => response.json())
.then((data) => {
if (data.success) {
showMessage(
"WLAN-Einstellungen erfolgreich gespeichert!",
"success",
);
} else {
showMessage(
data.error || "Fehler beim Speichern der WLAN-Einstellungen",
"error",
);
}
})
.catch((error) => showMessage("Verbindungsfehler", "error"));
});
// Update OTA button access based on license level
function updateOTAButtonAccess(licenseLevel) {
const otaButton = document.getElementById("otaUpdateBtn");
const otarestrictionNotice = document.getElementById("otaRestrictionNotice");
const otacurrentLevelSpan = document.getElementById("currentLicenseLevel");
const otarestrictionNotice = document.getElementById(
"otaRestrictionNotice",
);
const otacurrentLevelSpan = document.getElementById(
"currentLicenseLevel",
);
const level = parseInt(licenseLevel) || 0;
@@ -569,71 +617,91 @@
// MQTT Message publish function
function updateButtons() {
if (confirm("Update Buttons?")) {
fetch("/api/updateButtons", {
method: "GET"
})
.then((response) => {
if (response.status === 200) {
showMessage("Buttons führen das Update erfolgreich aus!", "success");
} else {
showMessage("Fehler beim Senden der MQTT Message", "error");
if (confirm("Update Buttons?")) {
fetch("/api/updateButtons", {
method: "GET",
})
.then((response) => {
if (response.status === 200) {
showMessage(
"Buttons führen das Update erfolgreich aus!",
"success",
);
} else {
showMessage("Fehler beim Senden der MQTT Message", "error");
}
})
.catch((error) =>
showMessage("Verbindungsfehler beim MQTT Publish", "error"),
);
}
})
.catch((error) => showMessage("Verbindungsfehler beim MQTT Publish", "error"));
}
}
}
function updateWifiButtonAccess(licenseLevel) {
const wifiSubmitBtn = document.getElementById("wifiSubmitBtn");
const wifiForm = document.getElementById("wifiForm");
const wifiRestrictionNotice = document.getElementById("wifiRestrictionNotice");
const wifiCurrentLevelSpan = document.getElementById("currentLicenseLevel");
const wifiSubmitBtn = document.getElementById("wifiSubmitBtn");
const wifiForm = document.getElementById("wifiForm");
const wifiRestrictionNotice = document.getElementById(
"wifiRestrictionNotice",
);
const wifiCurrentLevelSpan = document.getElementById(
"currentLicenseLevel",
);
const level = parseInt(licenseLevel) || 0;
const level = parseInt(licenseLevel) || 0;
if (level >= 3) {
// License level 3 or higher - enable form
wifiSubmitBtn.classList.remove("btn-disabled");
wifiSubmitBtn.disabled = false;
wifiForm.querySelectorAll('input').forEach(input => {
if (level >= 3) {
// License level 3 or higher - enable form
wifiSubmitBtn.classList.remove("btn-disabled");
wifiSubmitBtn.disabled = false;
wifiForm.querySelectorAll("input").forEach((input) => {
input.disabled = false;
});
wifiRestrictionNotice.style.display = "none";
} else {
// License level below 3 - disable form
wifiSubmitBtn.classList.add("btn-disabled");
wifiSubmitBtn.disabled = true;
wifiForm.querySelectorAll('input').forEach(input => {
});
wifiRestrictionNotice.style.display = "none";
} else {
// License level below 3 - disable form
wifiSubmitBtn.classList.add("btn-disabled");
wifiSubmitBtn.disabled = true;
wifiForm.querySelectorAll("input").forEach((input) => {
input.disabled = true;
});
wifiRestrictionNotice.style.display = "block";
wifiCurrentLevelSpan.textContent = level;
}
}
});
wifiRestrictionNotice.style.display = "block";
wifiCurrentLevelSpan.textContent = level;
}
}
// OTA Update function with license check
function performOTAUpdate() {
const otaButton = document.getElementById("otaUpdateBtn");
if (otaButton.disabled || otaButton.classList.contains("btn-disabled")) {
showMessage("OTA Update erfordert Lizenz Level 2 oder höher", "error");
if (
otaButton.disabled ||
otaButton.classList.contains("btn-disabled")
) {
showMessage(
"OTA Update erfordert Lizenz Level 2 oder höher",
"error",
);
return;
}
if (confirm("Möchten Sie wirklich ein OTA Update durchführen? Das Gerät wird während des Updates neu gestartet.")) {
window.location.href = '/update';
if (
confirm(
"Möchten Sie wirklich ein OTA Update durchführen? Das Gerät wird während des Updates neu gestartet.",
)
) {
window.location.href = "/update";
}
}
// Einstellungen speichern
document.getElementById("settingsForm")
document
.getElementById("settingsForm")
.addEventListener("submit", function (e) {
e.preventDefault();
const maxTime = parseInt(document.getElementById("maxTime").value);
const maxTimeDisplay = parseInt(
document.getElementById("maxTimeDisplay").value
document.getElementById("maxTimeDisplay").value,
);
fetch("/api/set-max-time", {
@@ -652,7 +720,7 @@
if (data.success) {
showMessage(
"Einstellungen erfolgreich gespeichert!",
"success"
"success",
);
} else {
showMessage("Fehler beim Speichern der Einstellungen", "error");
@@ -670,7 +738,7 @@
if (data.success) {
showMessage(
"Beste Zeiten erfolgreich zurückgesetzt!",
"success"
"success",
);
} else {
showMessage("Fehler beim Zurücksetzen", "error");
@@ -718,13 +786,11 @@
// Anlern-Anweisung aktualisieren
function updateLearningInstruction() {
if (learningStep < learningSteps.length) {
document.getElementById(
"learningInstruction"
).innerHTML = `Drücken Sie jetzt den Button für: <strong>${learningSteps[learningStep]}</strong>`;
document.getElementById("learningInstruction").innerHTML =
`Drücken Sie jetzt den Button für: <strong>${learningSteps[learningStep]}</strong>`;
}
}
// Anlern-Status abfragen
function pollLearningStatus() {
const pollInterval = setInterval(() => {
@@ -748,7 +814,7 @@
if (learningStep > 0) {
showMessage(
`${learningSteps[learningStep - 1]} erfolgreich angelernt!`,
"success"
"success",
);
}
}
@@ -770,13 +836,13 @@
if (data.success) {
showMessage(
"Button-Zuweisungen erfolgreich zurückgesetzt!",
"success"
"success",
);
loadSystemInfo();
} else {
showMessage(
"Fehler beim Zurücksetzen der Button-Zuweisungen",
"error"
"error",
);
}
})
@@ -806,48 +872,47 @@
alert(statusText);
})
.catch((error) =>
showMessage("Fehler beim Laden des Button-Status", "error")
showMessage("Fehler beim Laden des Button-Status", "error"),
);
}
//location functions
// Locations laden und Dropdown befüllen
// Locations laden und Dropdown befüllen
function loadLocations() {
const licence = document.getElementById("licencekey").value; // Get the licence key from the input field
fetch("http://db.reptilfpv.de:3000/api/location/", {
method: "GET",
headers: {
Authorization: `Bearer ${licence}`, // Add Bearer token using licenkey
},
})
.then((response) => response.json())
.then((data) => {
const licence = document.getElementById("licencekey").value; // Get the licence key from the input field
fetch("http://db.reptilfpv.de:3000/api/location/", {
method: "GET",
headers: {
Authorization: `Bearer ${licence}`, // Add Bearer token using licenkey
},
})
.then((response) => response.json())
.then((data) => {
const select = document.getElementById("locationSelect");
const select = document.getElementById("locationSelect");
// Vorhandene Optionen löschen (außer der ersten "Bitte wählen...")
while (select.children.length > 1) {
select.removeChild(select.lastChild);
}
// Vorhandene Optionen löschen (außer der ersten "Bitte wählen...")
while (select.children.length > 1) {
select.removeChild(select.lastChild);
// Neue Optionen aus Backend-Response hinzufügen
// Neue Optionen aus Backend-Response hinzufügen
data.forEach((location) => {
const option = document.createElement("option");
option.value = location.id;
option.textContent = location.name;
select.appendChild(option);
});
// Aktuell gespeicherten Standort laden
loadCurrentLocation();
})
.catch((error) => {
console.log("Locations konnten nicht geladen werden:", error);
showMessage("Fehler beim Laden der Locations", "error");
});
}
// Neue Optionen aus Backend-Response hinzufügen
// Neue Optionen aus Backend-Response hinzufügen
data.forEach((location) => {
const option = document.createElement("option");
option.value = location.id;
option.textContent = location.name;
select.appendChild(option);
});
// Aktuell gespeicherten Standort laden
loadCurrentLocation();
})
.catch((error) => {
console.log("Locations konnten nicht geladen werden:", error);
showMessage("Fehler beim Laden der Locations", "error");
});
}
// Aktuell gespeicherten Standort laden
function loadCurrentLocation() {
fetch("/api/get-location")
@@ -858,15 +923,22 @@
}
})
.catch((error) => {
console.log("Aktueller Standort konnte nicht geladen werden:", error);
console.log(
"Aktueller Standort konnte nicht geladen werden:",
error,
);
});
}
// Location-Zugriff basierend auf Lizenz-Level kontrollieren
function updateLocationAccess(licenseLevel) {
const locationSubmitBtn = document.getElementById("locationSubmitBtn");
const locationRestrictionNotice = document.getElementById("locationRestrictionNotice");
const locationCurrentLevelSpan = document.getElementById("currentLocationLicenseLevel");
const locationRestrictionNotice = document.getElementById(
"locationRestrictionNotice",
);
const locationCurrentLevelSpan = document.getElementById(
"currentLocationLicenseLevel",
);
const locationSelect = document.getElementById("locationSelect");
const level = parseInt(licenseLevel) || 0;
@@ -888,42 +960,51 @@
}
// Location Form Handler
document.getElementById("locationForm").addEventListener("submit", function(e) {
e.preventDefault();
document
.getElementById("locationForm")
.addEventListener("submit", function (e) {
e.preventDefault();
const locationSubmitBtn = document.getElementById("locationSubmitBtn");
const locationSubmitBtn =
document.getElementById("locationSubmitBtn");
// Lizenz-Level prüfen
if (locationSubmitBtn.disabled || locationSubmitBtn.classList.contains("btn-disabled")) {
showMessage("Standort-Konfiguration erfordert Lizenz Level 3 oder höher", "error");
return;
}
// Lizenz-Level prüfen
if (
locationSubmitBtn.disabled ||
locationSubmitBtn.classList.contains("btn-disabled")
) {
showMessage(
"Standort-Konfiguration erfordert Lizenz Level 3 oder höher",
"error",
);
return;
}
const locationId = document.getElementById("locationSelect").value;
const locationId = document.getElementById("locationSelect").value;
if (!locationId) {
showMessage("Bitte einen Standort auswählen", "error");
return;
}
if (!locationId) {
showMessage("Bitte einen Standort auswählen", "error");
return;
}
// Standort an Backend senden
fetch("/api/set-location", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "locationId=" + encodeURIComponent(locationId),
})
.then((response) => response.json())
.then((data) => {
if (data.success) {
showMessage("Standort erfolgreich gespeichert!", "success");
} else {
showMessage("Fehler beim Speichern des Standorts", "error");
}
// Standort an Backend senden
fetch("/api/set-location", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "locationId=" + encodeURIComponent(locationId),
})
.catch((error) => showMessage("Verbindungsfehler", "error"));
});
.then((response) => response.json())
.then((data) => {
if (data.success) {
showMessage("Standort erfolgreich gespeichert!", "success");
} else {
showMessage("Fehler beim Speichern des Standorts", "error");
}
})
.catch((error) => showMessage("Verbindungsfehler", "error"));
});
// Status-Nachricht anzeigen
function showMessage(message, type) {