- Implemented a service worker (sw.js) to handle push notifications with dynamic options and notification click events. - Created a calendar layout in test.html with a grid system for displaying events across days and times. - Developed a visually engaging WLAN QR code page (wlan.html) with animated backgrounds, particle effects, and tips for connecting to the network.
185 lines
6.8 KiB
HTML
185 lines
6.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Countdown/Countup Timer</title>
|
|
<!-- Tab-Icon hinzufügen -->
|
|
<link rel="icon" href="https://cdn-icons-png.flaticon.com/512/8730/8730547.png" type="image/x-icon">
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
background-color: #f0f0f0;
|
|
text-align: center;
|
|
}
|
|
|
|
#main-heading {
|
|
color: red;
|
|
font-size: 3.5rem;
|
|
margin-bottom: 30px;
|
|
font-weight: 900;
|
|
background-color: #90EE90;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
#target-info {
|
|
font-size: 1.2rem;
|
|
margin-bottom: 20px;
|
|
color: #333;
|
|
}
|
|
|
|
#countdown {
|
|
font-size: 2rem;
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
#totals {
|
|
margin-top: 20px;
|
|
font-size: 1rem;
|
|
color: #666;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="main-heading">geht bald los...</div>
|
|
<div id="target-info">Bis zum 28.08.2025 um 17:30:00 Uhr sind es noch:</div>
|
|
<div id="countdown">
|
|
1d 0h 38m 26s 801ms
|
|
</div>
|
|
<div id="totals">
|
|
Jahre: 0.00 |
|
|
Wochen: 0 |
|
|
Tage: 1 |
|
|
Stunden: 24 |
|
|
Sekunden: 88.706
|
|
</div>
|
|
|
|
<script>
|
|
// Function to get query parameter from URL
|
|
function getQueryParam(param) {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
return urlParams.get(param);
|
|
}
|
|
|
|
// Function to pad numbers with leading zeros
|
|
function padZero(num, places) {
|
|
return num.toString().padStart(places, '0');
|
|
}
|
|
|
|
// Function to format number with thousand separators
|
|
function formatNumber(num) {
|
|
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
}
|
|
|
|
// Function to format date for display
|
|
function formatDate(date) {
|
|
return `${padZero(date.getDate(), 2)}.${padZero(date.getMonth() + 1, 2)}.${date.getFullYear()} um ${padZero(date.getHours(), 2)}:${padZero(date.getMinutes(), 2)}:${padZero(date.getSeconds(), 2)}`;
|
|
}
|
|
|
|
// Get query parameters
|
|
const targetDateStr = getQueryParam('target');
|
|
const headingText = getQueryParam('heading');
|
|
|
|
// Select elements
|
|
const mainHeadingElement = document.getElementById('main-heading');
|
|
const targetInfoElement = document.getElementById('target-info');
|
|
const countdownElement = document.getElementById('countdown');
|
|
const totalsElement = document.getElementById('totals');
|
|
|
|
// Set heading if provided
|
|
if (headingText) {
|
|
mainHeadingElement.textContent = decodeURIComponent(headingText);
|
|
} else {
|
|
mainHeadingElement.style.display = 'none';
|
|
}
|
|
|
|
// Handle different scenarios
|
|
if (!targetDateStr) {
|
|
// No target specified
|
|
targetInfoElement.innerHTML = "Ja, worauf warten wir?";
|
|
countdownElement.innerHTML = "";
|
|
totalsElement.innerHTML = "";
|
|
} else {
|
|
try {
|
|
// Parse the target date
|
|
const targetDate = new Date(targetDateStr);
|
|
|
|
// Validate the date
|
|
if (isNaN(targetDate.getTime())) {
|
|
targetInfoElement.innerHTML = "hmm, da stimmt was nicht!";
|
|
countdownElement.innerHTML = "";
|
|
totalsElement.innerHTML = "";
|
|
} else {
|
|
// Determine if date is in past or future
|
|
const now = new Date().getTime();
|
|
const target = targetDate.getTime();
|
|
let isInPast = target < now;
|
|
|
|
// Countdown/Countup function
|
|
function updateTimer() {
|
|
const now = new Date().getTime();
|
|
const distance = Math.abs(target - now);
|
|
isInPast = target < now;
|
|
|
|
// Set target info text based on past/future
|
|
const targetInfoText = isInPast
|
|
? `Seit dem ${formatDate(targetDate)} Uhr sind es schon:`
|
|
: `Bis zum ${formatDate(targetDate)} Uhr sind es noch:`;
|
|
targetInfoElement.innerHTML = targetInfoText;
|
|
|
|
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
|
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
|
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
|
const milliseconds = Math.floor(distance % 1000);
|
|
|
|
// Calculate total values
|
|
const totalDays = days;
|
|
const totalWeeks = Math.floor(totalDays / 7);
|
|
const totalHours = totalDays * 24 + hours;
|
|
const totalSeconds = totalDays * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds;
|
|
const totalYears = (totalDays / 365).toFixed(2); // Calculate total years to 2 decimal places
|
|
|
|
// Display countdown/countup
|
|
countdownElement.innerHTML = `
|
|
${days}d ${hours}h ${minutes}m ${seconds}s ${padZero(milliseconds, 3)}ms
|
|
`;
|
|
|
|
// Display totals with thousand separators
|
|
totalsElement.innerHTML = `
|
|
Jahre: ${totalYears} |
|
|
Wochen: ${formatNumber(totalWeeks)} |
|
|
Tage: ${formatNumber(totalDays)} |
|
|
Stunden: ${formatNumber(totalHours)} |
|
|
Sekunden: ${formatNumber(totalSeconds)}
|
|
`;
|
|
}
|
|
|
|
// Update timer every 10 milliseconds
|
|
setInterval(updateTimer, 10);
|
|
updateTimer(); // Initial call
|
|
}
|
|
} catch (error) {
|
|
targetInfoElement.innerHTML = "hmm, da stimmt was nicht!";
|
|
countdownElement.innerHTML = "";
|
|
totalsElement.innerHTML = "";
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |