da.html aktualisiert
This commit is contained in:
parent
f8d9d9e36b
commit
1900605b4a
258
da.html
258
da.html
|
@ -1,89 +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;
|
||||||
border-radius: 0.75em;
|
position: relative; /* Um Positionierung für den edit-button zu ermöglichen */
|
||||||
|
}
|
||||||
}
|
.weekday-btn-container {
|
||||||
.weekday-btn-container {
|
display: flex;
|
||||||
display: flex;
|
flex-wrap: wrap;
|
||||||
flex-wrap: wrap;
|
}
|
||||||
}
|
.weekday-btn-container div {
|
||||||
.weekday-btn-container div {
|
margin-right: 10px;
|
||||||
margin-right: 10px;
|
}
|
||||||
}
|
.custom-checkbox {
|
||||||
h1{
|
position: relative;
|
||||||
text-align: center;
|
cursor: pointer;
|
||||||
|
width: 24px;
|
||||||
}
|
height: 24px;
|
||||||
</style>
|
display: flex;
|
||||||
</head>
|
align-items: center;
|
||||||
<body>
|
justify-content: center;
|
||||||
<h1>Wecker in Übersicht</h1>
|
margin-right: 5px;
|
||||||
<div id="jsonContainer"></div>
|
}
|
||||||
|
.custom-checkbox input {
|
||||||
<script>
|
position: absolute;
|
||||||
window.onload = function() {
|
opacity: 0;
|
||||||
fetch('/selectedTime')
|
cursor: pointer;
|
||||||
.then(response => response.json())
|
height: 0;
|
||||||
.then(data => {
|
width: 0;
|
||||||
const jsonContainer = document.getElementById('jsonContainer');
|
}
|
||||||
jsonContainer.innerHTML = '';
|
.checkmark {
|
||||||
|
position: absolute;
|
||||||
data.forEach(item => {
|
top: 0;
|
||||||
const jsonElement = document.createElement('div');
|
left: 0;
|
||||||
jsonElement.classList.add('json-element');
|
height: 24px;
|
||||||
|
width: 24px;
|
||||||
const name = document.createElement('p');
|
background-color: #eee;
|
||||||
name.textContent = `Name: ${item.NameValue.name}`;
|
border-radius: 50%;
|
||||||
jsonElement.appendChild(name);
|
z-index: -1;
|
||||||
|
}
|
||||||
const time = document.createElement('p');
|
.custom-checkbox input:checked ~ .checkmark {
|
||||||
time.textContent = `Time: ${item.timeValue.time}`;
|
background-color: #54f17b;
|
||||||
jsonElement.appendChild(time);
|
}
|
||||||
|
.checkmark:after {
|
||||||
const daysValue = item.daysValue;
|
content: "";
|
||||||
|
position: absolute;
|
||||||
const weekdays = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'];
|
display: none;
|
||||||
|
}
|
||||||
const weekdayContainer = document.createElement('div');
|
.custom-checkbox input:checked ~ .checkmark:after {
|
||||||
weekdayContainer.classList.add('weekday-btn-container');
|
display: none;
|
||||||
|
}
|
||||||
weekdays.forEach(day => {
|
.custom-checkbox .checkmark:after {
|
||||||
const checkboxDiv = document.createElement('div');
|
content: "";
|
||||||
const checkbox = document.createElement('input');
|
top: 50%;
|
||||||
checkbox.type = 'checkbox';
|
left: 50%;
|
||||||
checkbox.id = `${day.toLowerCase()}Checkbox`;
|
transform: translate(-50%, -50%);
|
||||||
checkbox.checked = daysValue[day];
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
// Preventing checkbox clicks
|
border-radius: 50%;
|
||||||
checkbox.addEventListener('click', function(event) {
|
background: white;
|
||||||
event.preventDefault();
|
}
|
||||||
});
|
h1{
|
||||||
|
text-align: center;
|
||||||
const label = document.createElement('label');
|
|
||||||
label.textContent = day;
|
}
|
||||||
label.htmlFor = `${day.toLowerCase()}Checkbox`;
|
.edit-button {
|
||||||
|
position: absolute;
|
||||||
checkboxDiv.appendChild(checkbox);
|
bottom: 5px;
|
||||||
checkboxDiv.appendChild(label);
|
right: 5px;
|
||||||
weekdayContainer.appendChild(checkboxDiv);
|
background-color: #2196F3;
|
||||||
});
|
color: white;
|
||||||
|
border: none;
|
||||||
jsonElement.appendChild(weekdayContainer);
|
border-radius: 50%;
|
||||||
jsonContainer.appendChild(jsonElement);
|
width: 30px;
|
||||||
});
|
height: 30px;
|
||||||
})
|
cursor: pointer;
|
||||||
.catch(error => console.error('Error fetching data:', error));
|
display: flex;
|
||||||
}
|
justify-content: center;
|
||||||
</script>
|
align-items: center;
|
||||||
|
}
|
||||||
</body>
|
</style>
|
||||||
</html>
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Wecker in Übersicht</h1>
|
||||||
|
<div id="jsonContainer"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
fetch('/selectedTime')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const jsonContainer = document.getElementById('jsonContainer');
|
||||||
|
jsonContainer.innerHTML = '';
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const jsonElement = document.createElement('div');
|
||||||
|
jsonElement.classList.add('json-element');
|
||||||
|
|
||||||
|
const name = document.createElement('p');
|
||||||
|
name.textContent = `Name: ${item.NameValue.name}`;
|
||||||
|
jsonElement.appendChild(name);
|
||||||
|
|
||||||
|
const time = document.createElement('p');
|
||||||
|
time.textContent = `Time: ${item.timeValue.time}`;
|
||||||
|
jsonElement.appendChild(time);
|
||||||
|
|
||||||
|
const daysValue = item.daysValue;
|
||||||
|
|
||||||
|
const weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
|
||||||
|
|
||||||
|
const weekdayContainer = document.createElement('div');
|
||||||
|
weekdayContainer.classList.add('weekday-btn-container');
|
||||||
|
|
||||||
|
weekdays.forEach((day, index) => {
|
||||||
|
const checkboxDiv = document.createElement('div');
|
||||||
|
const checkbox = document.createElement('label');
|
||||||
|
checkbox.classList.add('custom-checkbox');
|
||||||
|
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'checkbox';
|
||||||
|
input.id = `${day.toLowerCase()}Checkbox`;
|
||||||
|
input.checked = daysValue[Object.keys(daysValue)[index]];
|
||||||
|
|
||||||
|
// Preventing checkbox clicks
|
||||||
|
checkbox.addEventListener('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkmark = document.createElement('span');
|
||||||
|
checkmark.classList.add('checkmark');
|
||||||
|
|
||||||
|
const labelText = document.createElement('span');
|
||||||
|
labelText.textContent = day;
|
||||||
|
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 = '✎';
|
||||||
|
|
||||||
|
// 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>
|
||||||
|
|
Loading…
Reference in New Issue