%PDF- %PDF-
| Direktori : /home2/rezakur1/public_html/timer/ |
| Current File : //home2/rezakur1/public_html/timer/index.php |
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countdown Timer</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.glow {
box-shadow:
0 0 80px rgba(99, 102, 241, 0.12),
0 20px 80px rgba(0, 0, 0, 0.35);
}
.timer-text {
font-variant-numeric: tabular-nums;
letter-spacing: -0.06em;
}
</style>
</head>
<body class="min-h-screen bg-[#080b14] text-white">
<!-- Background -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div class="absolute -top-40 -right-40
w-[500px] h-[500px]
bg-indigo-600/10
rounded-full blur-3xl">
</div>
<div class="absolute -bottom-40 -left-40
w-[500px] h-[500px]
bg-purple-600/10
rounded-full blur-3xl">
</div>
</div>
<!-- Main -->
<main class="relative min-h-screen flex items-center justify-center p-6">
<div class="w-full max-w-6xl">
<!-- Header -->
<div class="mb-8">
<div class="flex items-center gap-3">
<div class="w-11 h-11
rounded-xl
bg-indigo-500/10
border border-indigo-500/20
flex items-center justify-center">
<svg
class="w-5 h-5 text-indigo-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z">
</path>
</svg>
</div>
<div>
<h1 class="text-xl font-bold">
Countdown Timer
</h1>
<p class="text-sm text-slate-500">
Hitung mundur menuju waktu yang ditentukan
</p>
</div>
</div>
</div>
<!-- Dashboard -->
<div class="grid grid-cols-1 lg:grid-cols-[360px_1fr]
gap-5">
<!-- ============================= -->
<!-- LEFT : SETTINGS -->
<!-- ============================= -->
<div class="bg-[#111522]
border border-white/[0.06]
rounded-3xl
p-6
glow">
<div class="mb-7">
<p class="text-xs uppercase
tracking-[0.15em]
text-slate-500
font-semibold">
Pengaturan
</p>
<h2 class="text-lg font-semibold mt-1">
Tentukan Waktu
</h2>
</div>
<!-- Current Time -->
<div class="bg-black/20
border border-white/[0.05]
rounded-2xl
p-4
mb-5">
<div class="flex items-center justify-between">
<span class="text-sm text-slate-500">
Sekarang
</span>
<span
id="currentDate"
class="text-xs text-slate-600">
-
</span>
</div>
<div
id="currentTime"
class="text-3xl
font-bold
tracking-tight
mt-2">
00:00:00
</div>
</div>
<!-- Target -->
<div class="mb-5">
<label
for="targetTime"
class="block
text-sm
font-medium
text-slate-300
mb-2">
Target Jam
</label>
<input
id="targetTime"
type="time"
class="w-full
bg-[#0b0e17]
border border-white/[0.08]
rounded-2xl
px-4 py-4
text-2xl
font-semibold
text-center
outline-none
focus:border-indigo-500
focus:ring-2
focus:ring-indigo-500/20
transition">
</div>
<!-- Target Preview -->
<div class="bg-indigo-500/[0.07]
border border-indigo-500/10
rounded-2xl
p-4
mb-5">
<div class="flex justify-between items-center">
<span class="text-sm text-slate-500">
Target
</span>
<span
id="targetPreview"
class="font-semibold text-indigo-400">
--:--
</span>
</div>
<p
id="targetInfo"
class="text-xs
text-slate-600
mt-2">
Belum ada waktu target
</p>
</div>
<!-- Buttons -->
<div class="grid grid-cols-2 gap-3">
<button
onclick="startCountdown()"
class="bg-indigo-600
hover:bg-indigo-500
active:scale-[0.98]
rounded-2xl
py-4
font-semibold
transition">
Mulai
</button>
<button
onclick="resetTimer()"
class="bg-white/[0.05]
hover:bg-white/[0.08]
border border-white/[0.06]
rounded-2xl
py-4
font-semibold
text-slate-300
transition">
Reset
</button>
</div>
<!-- Status -->
<div class="flex items-center gap-2 mt-6">
<span
id="statusDot"
class="w-2 h-2
rounded-full
bg-slate-600">
</span>
<span
id="status"
class="text-xs text-slate-500">
Siap digunakan
</span>
</div>
</div>
<!-- ============================= -->
<!-- RIGHT : TIMER -->
<!-- ============================= -->
<div class="relative
bg-[#111522]
border border-white/[0.06]
rounded-3xl
p-8
lg:p-12
min-h-[520px]
flex flex-col
justify-center
overflow-hidden
glow">
<!-- Decorative circle -->
<div class="absolute
w-[450px]
h-[450px]
rounded-full
border border-indigo-500/[0.04]
top-1/2
left-1/2
-translate-x-1/2
-translate-y-1/2">
</div>
<!-- Top label -->
<div class="relative text-center">
<p class="text-xs
uppercase
tracking-[0.25em]
text-slate-500
font-semibold">
Sisa Waktu
</p>
</div>
<!-- Main Timer -->
<div class="relative
text-center
mt-5">
<div
id="countdown"
class="timer-text
text-[clamp(4rem,10vw,8rem)]
leading-none
font-black
text-white">
00:00:00
</div>
</div>
<!-- Target -->
<div class="relative
text-center
mt-7">
<span class="text-slate-500 text-sm">
Menuju
</span>
<span
id="targetLarge"
class="ml-2
text-indigo-400
font-semibold">
--:--
</span>
</div>
<!-- Progress -->
<div class="relative
max-w-xl
w-full
mx-auto
mt-10">
<div class="flex justify-between
text-xs
text-slate-600
mb-2">
<span>
Mulai
</span>
<span>
Target
</span>
</div>
<div class="h-2
bg-white/[0.05]
rounded-full
overflow-hidden">
<div
id="progress"
class="h-full
w-0
bg-indigo-500
rounded-full
transition-all
duration-1000">
</div>
</div>
</div>
<!-- Message -->
<div class="relative
text-center
mt-7">
<p
id="countdownMessage"
class="text-sm
text-slate-500">
Tentukan waktu target untuk memulai countdown
</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="text-center mt-6">
<p class="text-xs text-slate-700">
Countdown menggunakan waktu perangkat Anda
</p>
</div>
</div>
</main>
<script>
let countdownInterval = null;
let targetDate = null;
let startDate = null;
/* =========================
FORMAT
========================= */
function pad(number) {
return String(number).padStart(2, '0');
}
function formatTime(date) {
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
}
/* =========================
CURRENT TIME
========================= */
function updateCurrentTime() {
const now = new Date();
document.getElementById('currentTime')
.textContent = formatTime(now);
document.getElementById('currentDate')
.textContent =
now.toLocaleDateString('id-ID', {
day: '2-digit',
month: 'short',
year: 'numeric'
});
}
/* =========================
TARGET INPUT
========================= */
document.getElementById('targetTime')
.addEventListener('change', function () {
const value = this.value;
document.getElementById('targetPreview')
.textContent = value || '--:--';
document.getElementById('targetLarge')
.textContent = value || '--:--';
});
/* =========================
START COUNTDOWN
========================= */
function startCountdown() {
const targetInput =
document.getElementById('targetTime').value;
if (!targetInput) {
alert('Silakan pilih target jam terlebih dahulu.');
return;
}
if (countdownInterval) {
clearInterval(countdownInterval);
}
const [hour, minute] =
targetInput.split(':').map(Number);
const now = new Date();
startDate = new Date(now);
targetDate = new Date();
targetDate.setHours(
hour,
minute,
0,
0
);
/*
* Jika target sudah lewat,
* gunakan target besok.
*/
if (targetDate <= now) {
targetDate.setDate(
targetDate.getDate() + 1
);
}
const targetText =
targetDate.toLocaleDateString('id-ID', {
day: 'numeric',
month: 'long'
});
document.getElementById('targetInfo')
.textContent =
`Target ${targetText} pukul ${targetInput}`;
document.getElementById('status')
.textContent = 'Countdown aktif';
document.getElementById('statusDot')
.className =
'w-2 h-2 rounded-full bg-emerald-500';
document.getElementById('countdownMessage')
.textContent =
`Waktu target ${targetInput}`;
updateCountdown();
countdownInterval =
setInterval(updateCountdown, 1000);
}
/* =========================
COUNTDOWN
========================= */
function updateCountdown() {
const now = new Date();
const difference =
targetDate.getTime() -
now.getTime();
if (difference <= 0) {
document.getElementById('countdown')
.textContent = '00:00:00';
document.getElementById('progress')
.style.width = '100%';
document.getElementById('status')
.textContent = 'Waktu selesai';
document.getElementById('statusDot')
.className =
'w-2 h-2 rounded-full bg-red-500';
document.getElementById('countdownMessage')
.textContent =
'Waktu target telah tiba';
clearInterval(countdownInterval);
return;
}
const totalSeconds =
Math.floor(difference / 1000);
const hours =
Math.floor(totalSeconds / 3600);
const minutes =
Math.floor(
(totalSeconds % 3600) / 60
);
const seconds =
totalSeconds % 60;
document.getElementById('countdown')
.textContent =
`${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
/*
* Progress
*/
const totalDuration =
targetDate.getTime() -
startDate.getTime();
const elapsed =
now.getTime() -
startDate.getTime();
let progress =
(elapsed / totalDuration) * 100;
progress =
Math.max(
0,
Math.min(100, progress)
);
document.getElementById('progress')
.style.width = `${progress}%`;
/*
* Message
*/
if (hours > 0) {
document.getElementById('countdownMessage')
.textContent =
`${hours} jam ${minutes} menit lagi`;
} else if (minutes > 0) {
document.getElementById('countdownMessage')
.textContent =
`${minutes} menit ${seconds} detik lagi`;
} else {
document.getElementById('countdownMessage')
.textContent =
`${seconds} detik lagi`;
}
}
/* =========================
RESET
========================= */
function resetTimer() {
if (countdownInterval) {
clearInterval(countdownInterval);
}
targetDate = null;
startDate = null;
document.getElementById('countdown')
.textContent = '00:00:00';
document.getElementById('progress')
.style.width = '0%';
document.getElementById('targetPreview')
.textContent = '--:--';
document.getElementById('targetLarge')
.textContent = '--:--';
document.getElementById('targetInfo')
.textContent =
'Belum ada waktu target';
document.getElementById('countdownMessage')
.textContent =
'Tentukan waktu target untuk memulai countdown';
document.getElementById('status')
.textContent =
'Siap digunakan';
document.getElementById('statusDot')
.className =
'w-2 h-2 rounded-full bg-slate-600';
document.getElementById('targetTime')
.value = '';
}
/* =========================
INIT
========================= */
updateCurrentTime();
setInterval(
updateCurrentTime,
1000
);
</script>
</body>
</html>