du.html aktualisiert

This commit is contained in:
develcookingtest 2024-03-20 17:42:34 +00:00
parent 2c66275a0a
commit 97d2c6ec46
1 changed files with 169 additions and 141 deletions

310
du.html
View File

@ -1,141 +1,169 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wecker in Übersicht</title> <title>Wecker in Übersicht</title>
<style> <style>
.json-element { .json-element {
border: 1px solid #ccc; border: 1px solid #ccc;
margin-bottom: 10px; margin-bottom: 10px;
padding: 10px; padding: 10px;
} position: relative; /* Um Positionierung für den edit-button zu ermöglichen */
.weekday-btn-container { }
display: flex; .weekday-btn-container {
flex-wrap: wrap; display: flex;
} flex-wrap: wrap;
.weekday-btn-container div { }
margin-right: 10px; .weekday-btn-container div {
} margin-right: 10px;
.custom-checkbox { }
position: relative; .custom-checkbox {
cursor: pointer; position: relative;
width: 24px; cursor: pointer;
height: 24px; width: 24px;
display: flex; height: 24px;
align-items: center; display: flex;
justify-content: center; align-items: center;
margin-right: 5px; justify-content: center;
} margin-right: 5px;
.custom-checkbox input { }
position: absolute; .custom-checkbox input {
opacity: 0; position: absolute;
cursor: pointer; opacity: 0;
height: 0; cursor: pointer;
width: 0; height: 0;
} width: 0;
.checkmark { }
position: absolute; .checkmark {
top: 0; position: absolute;
left: 0; top: 0;
height: 24px; left: 0;
width: 24px; height: 24px;
background-color: #eee; width: 24px;
border-radius: 50%; background-color: #eee;
z-index: -1; border-radius: 50%;
} z-index: -1;
.custom-checkbox input:checked ~ .checkmark { }
background-color: #54f17b; .custom-checkbox input:checked ~ .checkmark {
} background-color: #54f17b;
.checkmark:after { }
content: ""; .checkmark:after {
position: absolute; content: "";
display: none; position: absolute;
} display: none;
.custom-checkbox input:checked ~ .checkmark:after { }
display: none; .custom-checkbox input:checked ~ .checkmark:after {
} display: none;
.custom-checkbox .checkmark:after { }
content: ""; .custom-checkbox .checkmark:after {
top: 50%; content: "";
left: 50%; top: 50%;
transform: translate(-50%, -50%); left: 50%;
width: 12px; transform: translate(-50%, -50%);
height: 12px; width: 12px;
border-radius: 50%; height: 12px;
background: white; border-radius: 50%;
} background: white;
h1{ }
text-align: center; h1{
text-align: center;
}
</style> }
</head> .edit-button {
<body> position: absolute;
<h1>Wecker in Übersicht</h1> bottom: 5px;
<div id="jsonContainer"></div> right: 5px;
background-color: #2196F3;
<script> color: white;
window.onload = function() { border: none;
fetch('/selectedTime') border-radius: 50%;
.then(response => response.json()) width: 30px;
.then(data => { height: 30px;
const jsonContainer = document.getElementById('jsonContainer'); cursor: pointer;
jsonContainer.innerHTML = ''; display: flex;
justify-content: center;
data.forEach(item => { align-items: center;
const jsonElement = document.createElement('div'); }
jsonElement.classList.add('json-element'); </style>
</head>
const name = document.createElement('p'); <body>
name.textContent = `Name: ${item.NameValue.name}`; <h1>Wecker in Übersicht</h1>
jsonElement.appendChild(name); <div id="jsonContainer"></div>
const time = document.createElement('p'); <script>
time.textContent = `Time: ${item.timeValue.time}`; window.onload = function() {
jsonElement.appendChild(time); fetch('/selectedTime')
.then(response => response.json())
const daysValue = item.daysValue; .then(data => {
const jsonContainer = document.getElementById('jsonContainer');
const weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']; jsonContainer.innerHTML = '';
const weekdayContainer = document.createElement('div'); data.forEach(item => {
weekdayContainer.classList.add('weekday-btn-container'); const jsonElement = document.createElement('div');
jsonElement.classList.add('json-element');
weekdays.forEach((day, index) => {
const checkboxDiv = document.createElement('div'); const name = document.createElement('p');
const checkbox = document.createElement('label'); name.textContent = `Name: ${item.NameValue.name}`;
checkbox.classList.add('custom-checkbox'); jsonElement.appendChild(name);
const input = document.createElement('input'); const time = document.createElement('p');
input.type = 'checkbox'; time.textContent = `Time: ${item.timeValue.time}`;
input.id = `${day.toLowerCase()}Checkbox`; jsonElement.appendChild(time);
input.checked = daysValue[Object.keys(daysValue)[index]];
const daysValue = item.daysValue;
// Preventing checkbox clicks
checkbox.addEventListener('click', function(event) { const weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
event.preventDefault();
}); const weekdayContainer = document.createElement('div');
const checkmark = document.createElement('span'); weekdayContainer.classList.add('weekday-btn-container');
checkmark.classList.add('checkmark');
weekdays.forEach((day, index) => {
const labelText = document.createElement('span'); const checkboxDiv = document.createElement('div');
labelText.textContent = day; const checkbox = document.createElement('label');
checkbox.appendChild(input); checkbox.classList.add('custom-checkbox');
checkbox.appendChild(checkmark);
checkbox.appendChild(labelText); const input = document.createElement('input');
input.type = 'checkbox';
checkboxDiv.appendChild(checkbox); input.id = `${day.toLowerCase()}Checkbox`;
weekdayContainer.appendChild(checkboxDiv); input.checked = daysValue[Object.keys(daysValue)[index]];
});
// Preventing checkbox clicks
jsonElement.appendChild(weekdayContainer); checkbox.addEventListener('click', function(event) {
jsonContainer.appendChild(jsonElement); event.preventDefault();
}); });
})
.catch(error => console.error('Error fetching data:', error)); const checkmark = document.createElement('span');
} checkmark.classList.add('checkmark');
</script>
const labelText = document.createElement('span');
</body> labelText.textContent = day;
</html> checkbox.appendChild(input);
checkbox.appendChild(checkmark);
checkbox.appendChild(labelText);
checkboxDiv.appendChild(checkbox);
weekdayContainer.appendChild(checkboxDiv);
});
jsonElement.appendChild(weekdayContainer);
const editButton = document.createElement('div'); // Jetzt innerhalb der Schleife erstellt
editButton.classList.add('edit-button');
editButton.innerHTML = '&#9998;';
// Add click event for edit button
editButton.addEventListener('click', function() {
console.log('Edit button clicked');
});
jsonElement.appendChild(editButton); // Hinzufügen des edit-buttons zum JSON-Element
jsonContainer.appendChild(jsonElement);
});
})
.catch(error => console.error('Error fetching data:', error));
}
</script>
</body>
</html>