wip
This commit is contained in:
parent
8631733274
commit
bba62e3527
18 changed files with 916 additions and 11 deletions
122
timer/index.html
122
timer/index.html
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Countdown Timer</title>
|
||||
<description>A simple large display countdown timer, its just counts down</description>
|
||||
<meta property="og:title" content="Countdown Timer" />
|
||||
<meta property="og:image" content="http://shots.wayl.one/shot/?url=https://timer.wayl.one/&height=630&width=1200&scaled_width=1200&scaled_height=630&selectors=" />
|
||||
<meta property="og:description" content="A simple large display countdown timer, its just counts down" />
|
||||
|
|
@ -33,8 +33,11 @@
|
|||
#title {
|
||||
font-size: 4vw;
|
||||
margin-bottom: 2vh;
|
||||
padding: 2rem 0;
|
||||
outline: none;
|
||||
text-align: center;
|
||||
min-height: 4vw;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#countdown {
|
||||
|
|
@ -44,13 +47,68 @@
|
|||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.75);
|
||||
display: none;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.modal {
|
||||
box-shadow: 0 0 3rem 1rem #00ff0017;
|
||||
background: black;
|
||||
border: 2px solid lime;
|
||||
border-radius: 0.5rem;
|
||||
padding: 2rem;
|
||||
max-width: 90%;
|
||||
color: lime;
|
||||
text-align: left;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.modal h2 {
|
||||
margin-top: 0;
|
||||
color: #008e00;
|
||||
}
|
||||
.modal ul {
|
||||
color: #00ae00;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="title" contenteditable="true">Click to Edit Title</div>
|
||||
<div id="title" contenteditable="true"></div>
|
||||
<div id="countdown" contenteditable="true">00:05:00</div>
|
||||
<!-- Modal -->
|
||||
<dialog id="modal-overlay" class="modal-overlay">
|
||||
<div class="modal">
|
||||
<h2>Help</h2>
|
||||
<p>
|
||||
It's just a countdown timer, it counts down.
|
||||
</p>
|
||||
<p>
|
||||
Use query parameters to change the time ex. ?hr=5&min=30&sec=0
|
||||
</p>
|
||||
<p>
|
||||
Start typing to give it a title.
|
||||
</p>
|
||||
<p>
|
||||
Copy with <kbd>Ctrl</kbd> + <kbd>c</kbd>
|
||||
</p>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const title = urlParams.get('title');
|
||||
const title_el = document.getElementById('title')
|
||||
if (title) {
|
||||
title_el.textContent = title;
|
||||
}
|
||||
const countdownEl = document.getElementById("countdown");
|
||||
|
||||
let endTime = null;
|
||||
|
|
@ -120,6 +178,58 @@
|
|||
}
|
||||
});
|
||||
|
||||
// ---- Modal logic ----
|
||||
const overlay = document.getElementById('modal-overlay');
|
||||
|
||||
function toggleModal() {
|
||||
if (overlay.style.display === 'none') {
|
||||
overlay.style.display = 'flex';
|
||||
} else {
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
function hideModal() {
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'c' && e.ctrlKey) {
|
||||
const time = countdownEl.textContent;
|
||||
navigator.clipboard.writeText(time);
|
||||
} else if (e.key === 'Enter' && !(document.activeElement === title_el)) {
|
||||
// toggleTimer();
|
||||
} else if (e.key === 'Escape' && document.activeElement === title_el) {
|
||||
title_el.blur();
|
||||
} else if (e.key === 'Escape') {
|
||||
hideModal();
|
||||
} else if (e.code === 'Space' && !(document.activeElement === title_el)) {
|
||||
// toggleTimer();
|
||||
|
||||
} else if (e.key === '?' && !title_el.isFocused) {
|
||||
toggleModal();
|
||||
} else if (e.key === '?') {
|
||||
} else if (e.keyCode === 191) {
|
||||
} else if (e.ctrlKey && e.key === 'a'){
|
||||
title_el.focus();
|
||||
} else if (e.ctrlKey){
|
||||
} else if (e.shiftKey){
|
||||
} else if (overlay.style.display === 'flex') {
|
||||
} else {
|
||||
title_el.focus();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// on change of title update query params
|
||||
title_el.addEventListener('input', () => {
|
||||
const new_title = title_el.textContent;
|
||||
const url = new URL(window.location);
|
||||
url.searchParams.set('title', new_title);
|
||||
window.history.replaceState({}, '', url);
|
||||
});
|
||||
|
||||
|
||||
// Support query params (e.g. ?min=3&sec=30)
|
||||
function getInitialTimeFromQuery(urlParams) {
|
||||
const hr = parseInt(urlParams.get("hr") || "0", 10);
|
||||
|
|
@ -147,14 +257,8 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Start
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const initialMs = getInitialTimeFromQuery(urlParams);
|
||||
countdownEl.textContent = formatTime(initialMs);
|
||||
const title = urlParams.get("title");
|
||||
if (title) {
|
||||
document.getElementById("title").textContent = title;
|
||||
}
|
||||
startCountdown(initialMs);
|
||||
requestWakeLock();
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue