Merge branch 'main' of gitpot.org:sangelo/website

This commit is contained in:
Sangelo 2024-10-29 18:52:36 +01:00
commit cda90ee02a
2 changed files with 31 additions and 3 deletions

View file

@ -1,6 +1,11 @@
<script lang="ts">
import { smoothScrollTo, handleKeydown } from '$lib/index';
<<<<<<< HEAD
=======
import { smoothScrollTo, handleKeydown } from '$lib/index';
>>>>>>> 18dbba03a6b12b96e49fa2035d696de633ac3e6f
// Modal
import Modal from '$lib/components/Modal.svelte';
import DashinitModal from '$lib/modals/dashinit.svelte';

View file

@ -1,10 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<!--
(c) Sangelo
(c) Sangelo 2024
v1.0.2
----------------
Simple countdown webpage that can be used as a startpage
You can feed the date the counter should be counting down to in the URL like this:
http://<countdown>/?date=YYYY-MM-DDTHH:MM:SS
or you can display the current time using ?time parameter like this:
http://<countdown>/?time
-->
<head>
<meta charset="UTF-8">
@ -46,6 +50,7 @@
const countdownElement = document.getElementById("countdown");
const countdownDate = getDateFromUrl();
const showCurrentTime = getTimeFromUrl();
function updateCountdown() {
const now = new Date().getTime();
@ -71,6 +76,16 @@
requestAnimationFrame(updateCountdown);
}
function updateTime() {
const now = new Date();
const hours = formatWithLeadingZeros(now.getHours(), 2);
const minutes = formatWithLeadingZeros(now.getMinutes(), 2);
const seconds = formatWithLeadingZeros(now.getSeconds(), 2);
countdownElement.innerHTML = `${hours}:${minutes}:${seconds}`;
requestAnimationFrame(updateTime);
}
function getDateFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
const dateParam = urlParams.get('date');
@ -83,8 +98,16 @@
return new Date("1970-01-01T00:00:00").getTime();
}
requestAnimationFrame(updateCountdown);
function getTimeFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.has('time');
}
if (showCurrentTime) {
requestAnimationFrame(updateTime);
} else {
requestAnimationFrame(updateCountdown);
}
</script>
</body>
</html>