<!DOCTYPE html>
Browse files<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShiftSync Calculator 1</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#10B981',
dark: '#1F2937',
light: '#F3F4F6'
}
}
}
}
</script>
<style>
.shift-card {
transition: all 0.3s ease;
}
.shift-card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.time-input {
background-color: rgba(255, 255, 255, 0.9);
border: 1px solid #E5E7EB;
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-green-50 min-h-screen">
<div class="container mx-auto px-4 py-4 max-w-5xl">
<!-- Header -->
<header class="mb-4 text-center">
<div class="flex items-center justify-center gap-4">
<img src="https://huggingface.co/spaces/BabloOG/TamroMatematik/resolve/main/images/gorilla.png" alt="Logo" class="w-16 h-16 object-contain">
<h1 class="text-4xl font-bold text-dark mb-2">Tamro <span class="text-primary">Shift Calculator</span></h1>
</div>
<div class="mt-4 flex justify-center items-center space-x-4">
<div class="px-4 py-2 bg-primary text-white rounded-lg shadow animate-pulse">
<span id="current-time" class="font-mono"></span>
<span class="ml-2">CET (Sweden)</span>
</div>
<div class="px-4 py-2 bg-secondary text-white rounded-lg shadow">
<span id="current-date" class="font-mono"></span>
</div>
</div>
</header>
<!-- Toggle Button -->
<div class="flex justify-center mb-6">
<button id="toggle-calculator" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-3 px-6 rounded-lg transition flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-repeat mr-2"><polyline points="17 1 21 5 17 9"></polyline><path d="M3 11V9a4 4 0 0 1 4-4h14"></path><polyline points="7 23 3 19 7 15"></polyline><path d="M21 13v2a4 4 0 0 1-4 4H3"></path></svg>
<span id="toggle-text">Switch to OSR</span>
</button>
</div>
<!-- Calculator Sections -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- Slinga 2 Calculator -->
<div id="slinga2-calculator" class="calculator-section">
<div class="bg-white p-4 rounded-xl shadow-lg mb-4">
<h2 class="text-2xl font-semibold text-dark mb-4 text-center">Slinga 2</h2>
<div id="slinga2-shift-container" class="grid grid-cols-1 gap-4 mb-6">
<!-- Slinga 2 shifts will be dynamically inserted here -->
</div>
</div>
<div class="bg-white p-4 rounded-xl shadow-lg">
<h2 class="text-2xl font-semibold text-dark mb-4">Shift Details</h2>
<div class="mb-4 space-y-2">
<div class="space-y-2">
<label class="block text-gray-700">Start Time</label>
<input type="time" id="slinga2-start-time" class="time-input w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
</div>
<div class="space-y-2">
<label class="block text-gray-700">End Time</label>
<input type="time" id="slinga2-end-time" class="time-input w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
</div>
<div class="space-y-2">
<div id="slinga2-break-input-container">
<!-- Slinga 2 break times will be dynamically inserted here -->
</div>
<button id="slinga2-add-break-btn" class="mt-2 bg-gray-100 hover:bg-gray-200 text-gray-700 py-1 px-3 rounded-lg transition flex items-center">
<i data-feather="plus" class="w-4 h-4 mr-1"></i> Add Break
</button>
</div>
</div>
<div class="mb-4">
<h3 class="text-lg font-medium text-dark mb-2">Adjust Time</h3>
<div class="grid grid-cols-4 gap-2">
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="-5">-5 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="-15">-15 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="-30">-30 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="-60">-60 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="5">+5 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="15">+15 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="30">+30 min</button>
<button class="time-adjust-btn bg-gray-100 hover:bg-gray-200 py-2 px-3 rounded-lg transition" data-minutes="60">+60 min</button>
</div>
</div>
<div class="mb-6">
<h3 class="text-lg font-medium text-dark mb-2">Employees for <span id="slinga2-selected-shift-name" class="text-primary">No Shift Selected</span></h3>
<div class="flex items-center space-x-4">
<button id="slinga2-decrease-employees" class="bg-red-100 hover:bg-red-200 text-red-700 p-2 rounded-full transition">
<i data-feather="minus"></i>
</button>
<span id="slinga2-employee-count" class="text-2xl font-bold">0</span>
<button id="slinga2-increase-employees" class="bg-green-100 hover:bg-green-200 text-green-700 p-2 rounded-full transition">
<i data-feather="plus"></i>
</button>
</div>
</div>
<div class="bg-blue-50 p-3 rounded-lg mb-3">
<h3 class="text-lg font-medium text-dark mb-2">Shift Hours</h3>
<div class="flex justify-between items-center">
<span class="text-gray-600">Selected Shift:</span>
<span id="slinga2-hours-per-employee" class="text-2xl font-bold text-primary">0h 0m</span>
</div>
<div class="flex justify-between items-center mt-2">
<span class="text-gray-600">All Shifts Total:</span>
<span id="slinga2-total-hours-all" class="text-2xl font-bold text-secondary">0h 0m</span>
</div>
<div class="flex justify-between items-center mt-2">
<span class="text-gray-600">Remaining Today:</span>
<span id="slinga2-remaining-today" class="text-2xl font-bold text-blue-700">0h 0m</span>
</div>
</div>
<div class="bg-purple-50 p-3 rounded-lg">
<h3 class="text-lg font-medium text-dark mb-2">Hourly Rate Calculator</h3>
<div class="flex items-center space-x-2 mb-2">
<span class="text-gray-600">Total Amount:</span>
<input type="number" id="slinga2-total-amount" class="time-input w-24 px-3 py-1 border rounded-lg" placeholder="rader">
</div>
<div class="flex space-x-2 mb-2">
<button id="slinga2-calculate-rate-btn" class="bg-purple-100 hover:bg-purple-200 text-purple-700 py-2 px-4 rounded-lg transition flex-1">
Total Hours Rate
</button>
<button id="slinga2-calculate-remaining-rate-btn" class="bg-indigo-100 hover:bg-indigo-200 text-indigo-700 py-2 px-4 rounded-lg transition flex-1">
Remaining Rate
</button>
</div>
<div class="mt-2 flex justify-between items-center">
<span class="text-gray-600">Hourly Rate:</span>
<span id="slinga2-hourly-rate" class="text-xl font-bold text-purple-700">0 rader/hour</span>
</div>
</div>
</div>
</div>
<!-- OSR Calculator -->
Files changed (2)
- README.md+8-5
- index.html+620-18
12345678910---title: Shiftsync Pro Calculatoremoji: 📉colorFrom: greencolorTo: indigosdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213---title: ShiftSync Pro Calculator 🚀colorFrom: purplecolorTo: greenemoji: 🐳sdk: staticpinned: falsetags:- deepsite-v3---# Welcome to your new DeepSite project!This project was created with [DeepSite](https://deepsite.hf.co).
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>ShiftSync Pro Calculator</title><script src="https://cdn.tailwindcss.com"></script><script src="https://unpkg.com/feather-icons"></script><script>tailwind.config = {theme: {extend: {colors: {primary: {500: '#6366f1',600: '#4f46e5'},secondary: {500: '#10b981',600: '#059669'}}}}}</script><style>.shift-card {transition: all 0.2s ease;}.shift-card:hover {transform: translateY(-1px);}.compact-input {padding: 0.35rem 0.5rem;font-size: 0.875rem;}.result-badge {min-width: 80px;}[data-theme="dark"] {--bg-primary: #1e293b;--bg-secondary: #334155;--text-primary: #f8fafc;--text-secondary: #e2e8f0;}</style></head><body class="bg-gray-50 text-gray-800" data-theme="light"><div class="container mx-auto px-2 py-4 max-w-3xl"><!-- Compact Header --><header class="mb-3 flex items-center justify-between"><div class="flex items-center gap-2"><div class="w-10 h-10 rounded-full bg-primary-500 flex items-center justify-center text-white"><i data-feather="clock"></i></div><h1 class="text-xl font-bold">ShiftSync <span class="text-primary-500">Pro</span></h1></div><div class="flex gap-2"><div class="px-2 py-1 bg-gray-200 rounded-md text-sm"><span id="current-time"></span></div><button onclick="toggleTheme()" class="p-1 rounded-md hover:bg-gray-200"><i data-feather="moon"></i></button></div></header><!-- Compact Toggle --><div class="flex justify-center mb-3"><button id="toggle-calculator" class="bg-primary-500 hover:bg-primary-600 text-white text-sm py-1 px-4 rounded-full transition flex items-center"><i data-feather="repeat" class="w-3 h-3 mr-1"></i><span id="toggle-text">Switch to OSR</span></button></div><!-- Compact Calculator Sections --><div class="grid grid-cols-1 gap-3"><!-- Slinga 2 Calculator --><div id="slinga2-calculator" class="bg-white rounded-lg shadow-sm p-3 calculator-section"><div class="flex items-center justify-between mb-2"><h2 class="text-lg font-semibold">Slinga 2</h2><div class="text-sm bg-gray-100 px-2 py-1 rounded"><span id="slinga2-total-hours-all" class="font-medium">0h 0m</span></div></div><div id="slinga2-shift-container" class="grid grid-cols-2 gap-2 mb-3"><!-- Slinga 2 shifts will be dynamically inserted here --></div><div class="space-y-2"><div class="grid grid-cols-2 gap-2"><div><label class="block text-xs text-gray-500 mb-1">Start Time</label><input type="time" id="slinga2-start-time" class="compact-input w-full border rounded focus:ring-1 focus:ring-primary-500"></div><div><label class="block text-xs text-gray-500 mb-1">End Time</label><input type="time" id="slinga2-end-time" class="compact-input w-full border rounded focus:ring-1 focus:ring-primary-500"></div></div><div id="slinga2-break-input-container" class="space-y-1"><!-- Breaks will be inserted here --></div><button id="slinga2-add-break-btn" class="text-xs text-primary-500 hover:text-primary-600 flex items-center"><i data-feather="plus" class="w-3 h-3 mr-1"></i> Add break</button></div><div class="mt-3 grid grid-cols-3 gap-2"><div class="bg-gray-50 p-2 rounded"><div class="text-xs text-gray-500">Selected</div><div id="slinga2-hours-per-employee" class="text-sm font-medium">0h 0m</div></div><div class="bg-gray-50 p-2 rounded"><div class="text-xs text-gray-500">Employees</div><div class="flex items-center justify-between"><span id="slinga2-employee-count" class="text-sm font-medium">0</span><div class="flex gap-1"><button id="slinga2-decrease-employees" class="text-xs p-0.5 rounded hover:bg-gray-200"><i data-feather="minus" class="w-3 h-3"></i></button><button id="slinga2-increase-employees" class="text-xs p-0.5 rounded hover:bg-gray-200"><i data-feather="plus" class="w-3 h-3"></i></button></div></div></div><div class="bg-blue-50 p-2 rounded"><div class="text-xs text-gray-500">Remaining</div><div id="slinga2-remaining-today" class="text-sm font-medium text-blue-600">0h 0m</div></div></div><div class="mt-3 border-t pt-3"><div class="flex items-center gap-2 mb-2"><input type="number" id="slinga2-total-amount" placeholder="Amount" class="compact-input flex-1 border rounded"><span class="text-xs text-gray-500">rader</span></div><div class="grid grid-cols-2 gap-2"><button id="slinga2-calculate-rate-btn" class="text-xs bg-gray-100 hover:bg-gray-200 py-1 px-2 rounded">Total Rate</button><button id="slinga2-calculate-remaining-rate-btn" class="text-xs bg-gray-100 hover:bg-gray-200 py-1 px-2 rounded">Remaining Rate</button></div><div class="mt-2 text-sm"><span class="text-gray-500">Rate:</span><span id="slinga2-hourly-rate" class="font-medium">0 rader/h</span></div></div></div><!-- OSR Calculator --><div id="osr-calculator" class="bg-white rounded-lg shadow-sm p-3 calculator-section hidden"><div class="flex items-center justify-between mb-2"><h2 class="text-lg font-semibold">OSR</h2><div class="text-sm bg-gray-100 px-2 py-1 rounded"><span id="osr-total-hours-all" class="font-medium">0h 0m</span></div></div><div id="osr-shift-container" class="grid grid-cols-2 gap-2 mb-3"><!-- OSR shifts will be dynamically inserted here --></div><div class="space-y-2"><div class="grid grid-cols-2 gap-2"><div><label class="block text-xs text-gray-500 mb-1">Start Time</label><input type="time" id="osr-start-time" class="compact-input w-full border rounded focus:ring-1 focus:ring-primary-500"></div><div><label class="block text-xs text-gray-500 mb-1">End Time</label><input type="time" id="osr-end-time" class="compact-input w-full border rounded focus:ring-1 focus:ring-primary-500"></div></div><div id="osr-break-input-container" class="space-y-1"><!-- Breaks will be inserted here --></div><button id="osr-add-break-btn" class="text-xs text-primary-500 hover:text-primary-600 flex items-center"><i data-feather="plus" class="w-3 h-3 mr-1"></i> Add break</button></div><div class="mt-3 grid grid-cols-3 gap-2"><div class="bg-gray-50 p-2 rounded"><div class="text-xs text-gray-500">Selected</div><div id="osr-hours-per-employee" class="text-sm font-medium">0h 0m</div></div><div class="bg-gray-50 p-2 rounded"><div class="text-xs text-gray-500">Employees</div><div class="flex items-center justify-between"><span id="osr-employee-count" class="text-sm font-medium">0</span><div class="flex gap-1"><button id="osr-decrease-employees" class="text-xs p-0.5 rounded hover:bg-gray-200"><i data-feather="minus" class="w-3 h-3"></i></button><button id="osr-increase-employees" class="text-xs p-0.5 rounded hover:bg-gray-200"><i data-feather="plus" class="w-3 h-3"></i></button></div></div></div><div class="bg-blue-50 p-2 rounded"><div class="text-xs text-gray-500">Remaining</div><div id="osr-remaining-today" class="text-sm font-medium text-blue-600">0h 0m</div></div></div><div class="mt-3 border-t pt-3"><div class="flex items-center gap-2 mb-2"><input type="number" id="osr-total-amount" placeholder="Amount" class="compact-input flex-1 border rounded"><span class="text-xs text-gray-500">rader</span></div><div class="grid grid-cols-2 gap-2"><button id="osr-calculate-rate-btn" class="text-xs bg-gray-100 hover:bg-gray-200 py-1 px-2 rounded">Total Rate</button><button id="osr-calculate-remaining-rate-btn" class="text-xs bg-gray-100 hover:bg-gray-200 py-1 px-2 rounded">Remaining Rate</button></div><div class="mt-2 text-sm"><span class="text-gray-500">Rate:</span><span id="osr-hourly-rate" class="font-medium">0 rader/h</span></div></div></div></div></div><script>// Shifts dataconst slinga2Shifts = [{ name: "06:00-08:30", start: "06:00", end: "08:30", breaks: [] },{ name: "06:00-10:00", start: "06:00", end: "10:00", breaks: ["08:30-08:45"] },{ name: "06:00-11:00", start: "06:00", end: "11:00", breaks: ["08:30-08:45"] },{ name: "06:00-14:30", start: "06:00", end: "14:30", breaks: ["08:30-08:45", "11:00-11:30", "12:45-13:00"] },{ name: "10:00-18:30", start: "10:00", end: "18:30", breaks: ["13:00-13:30", "15:00-15:15", "17:00-17:15"] },{ name: "11:00-19:30", start: "11:00", end: "19:30", breaks: ["13:00-13:30", "15:00-15:15", "17:15-17:30"] },{ name: "14:30-18:30", start: "14:30", end: "18:30", breaks: ["17:00-17:15"] },{ name: "14:30-19:30", start: "14:30", end: "19:30", breaks: ["17:15-17:30"] }];const osrShifts = [{ name: "06:00-08:30", start: "06:00", end: "08:30", breaks: [] },{ name: "06:00-10:00", start: "06:00", end: "10:00", breaks: ["08:30-08:45"] },{ name: "06:00-11:00", start: "06:00", end: "11:00", breaks: ["08:30-08:45"] },{ name: "06:00-14:30", start: "06:00", end: "14:30", breaks: ["08:30-08:45", "11:00-11:30", "12:45-13:00"] },{ name: "10:00-18:30", start: "10:00", end: "18:30", breaks: ["13:00-13:30", "15:00-15:15", "17:00-17:15"] },{ name: "11:00-19:30", start: "11:00", end: "19:30", breaks: ["13:00-13:30", "15:00-15:15", "17:15-17:30"] },{ name: "14:30-18:30", start: "14:30", end: "18:30", breaks: ["17:00-17:15"] },{ name: "14:30-19:30", start: "14:30", end: "19:30", breaks: ["17:15-17:30"] }];// Initialize variables for both calculatorslet slinga2SelectedShift = null;let osrSelectedShift = null;const slinga2ShiftEmployees = {};const osrShiftEmployees = {};slinga2Shifts.forEach(shift => { slinga2ShiftEmployees[shift.name] = 0; });osrShifts.forEach(shift => { osrShiftEmployees[shift.name] = 0; });// Current date and timefunction updateTime() {const now = new Date();const options = {timeZone: 'Europe/Stockholm',hour: '2-digit',minute: '2-digit',hour12: false};document.getElementById('current-time').textContent = now.toLocaleTimeString('sv-SE', options);}updateTime();setInterval(updateTime, 60000); // Update every minute// Theme togglefunction toggleTheme() {const body = document.body;const currentTheme = body.getAttribute('data-theme');const newTheme = currentTheme === 'light' ? 'dark' : 'light';body.setAttribute('data-theme', newTheme);if (newTheme === 'dark') {body.classList.remove('bg-gray-50', 'text-gray-800');body.classList.add('bg-gray-900', 'text-gray-100');document.querySelectorAll('.calculator-section').forEach(section => {section.classList.remove('bg-white');section.classList.add('bg-gray-800');});feather.replace({ color: 'white' });} else {body.classList.remove('bg-gray-900', 'text-gray-100');body.classList.add('bg-gray-50', 'text-gray-800');document.querySelectorAll('.calculator-section').forEach(section => {section.classList.remove('bg-gray-800');section.classList.add('bg-white');});feather.replace();}}// Toggle functionalitydocument.getElementById('toggle-calculator').addEventListener('click', function() {const slinga2Section = document.getElementById('slinga2-calculator');const osrSection = document.getElementById('osr-calculator');const toggleText = document.getElementById('toggle-text');if (slinga2Section.classList.contains('hidden')) {// Switch to Slinga 2slinga2Section.classList.remove('hidden');osrSection.classList.add('hidden');toggleText.textContent = 'Switch to OSR';} else {// Switch to OSRslinga2Section.classList.add('hidden');osrSection.classList.remove('hidden');toggleText.textContent = 'Switch to Slinga 2';}});// Initialize both calculatorsinitializeCalculator('slinga2', slinga2Shifts, slinga2ShiftEmployees);initializeCalculator('osr', osrShifts, osrShiftEmployees);function initializeCalculator(prefix, shifts, shiftEmployees) {const shiftContainer = document.getElementById(`${prefix}-shift-container`);const startTimeInput = document.getElementById(`${prefix}-start-time`);const endTimeInput = document.getElementById(`${prefix}-end-time`);const employeeCountDisplay = document.getElementById(`${prefix}-employee-count`);const hoursPerEmployeeDisplay = document.getElementById(`${prefix}-hours-per-employee`);const totalHoursDisplay = document.getElementById(`${prefix}-total-hours-all`);const remainingTodayDisplay = document.getElementById(`${prefix}-remaining-today`);const hourlyRateDisplay = document.getElementById(`${prefix}-hourly-rate`);const totalAmountInput = document.getElementById(`${prefix}-total-amount`);let selectedShift = null;// Render shiftsfunction renderShifts() {shiftContainer.innerHTML = '';shifts.forEach(shift => {const shiftCard = document.createElement('div');shiftCard.className = 'shift-card bg-gray-50 hover:bg-gray-100 text-sm p-2 rounded cursor-pointer border border-gray-200';shiftCard.innerHTML = `<div class="flex justify-between items-center"><div>${shift.name}</div>${shiftEmployees[shift.name] > 0 ?`<span class="bg-green-100 text-green-800 text-xs px-1.5 py-0.5 rounded-full">${shiftEmployees[shift.name]}</span>` : ''}</div>`;shiftCard.addEventListener('click', (event) => selectShift(shift, event));shiftContainer.appendChild(shiftCard);});}// Select a shiftfunction selectShift(shift, event) {selectedShift = shift;document.querySelectorAll(`#${prefix}-shift-container .shift-card`).forEach(card => {card.classList.remove('border-primary-500', 'bg-primary-50');});event.currentTarget.classList.add('border-primary-500', 'bg-primary-50');startTimeInput.value = shift.start;endTimeInput.value = shift.end;employeeCountDisplay.textContent = shiftEmployees[shift.name];renderBreaks(shift.breaks);calculateHours();updateRemainingTodayDisplay();}// Render breaksfunction renderBreaks(breaks) {const container = document.getElementById(`${prefix}-break-input-container`);container.innerHTML = '';breaks.forEach((breakTime, index) => {const breakDiv = document.createElement('div');breakDiv.className = 'flex items-center gap-1';breakDiv.innerHTML = `<input type="time" value="${breakTime.split('-')[0]}" class="break-start compact-input w-full border rounded"><span class="text-gray-500 text-xs">to</span><input type="time" value="${breakTime.split('-')[1]}" class="break-end compact-input w-full border rounded"><button class="remove-break-btn text-red-500 hover:text-red-600" data-index="${index}"><i data-feather="x" class="w-3 h-3"></i></button>`;container.appendChild(breakDiv);const startInput = breakDiv.querySelector('.break-start');const endInput = breakDiv.querySelector('.break-end');startInput.addEventListener('change', () => updateBreakTime(index));endInput.addEventListener('change', () => updateBreakTime(index));});feather.replace();}function updateBreakTime(index) {const breakInputs = document.querySelectorAll(`#${prefix}-break-input-container > div`);const breakDiv = breakInputs[index];const startValue = breakDiv.querySelector('.break-start').value;const endValue = breakDiv.querySelector('.break-end').value;if (startValue && endValue) {selectedShift.breaks[index] = `${startValue}-${endValue}`;calculateHours();}}// Add break buttondocument.getElementById(`${prefix}-add-break-btn`).addEventListener('click', function() {if (!selectedShift) return;selectedShift.breaks.push('00:00-00:30');renderBreaks(selectedShift.breaks);});// Remove break functionalitydocument.getElementById(`${prefix}-break-input-container`).addEventListener('click', function(e) {if (e.target.closest('.remove-break-btn')) {const index = parseInt(e.target.closest('.remove-break-btn').dataset.index);selectedShift.breaks.splice(index, 1);renderBreaks(selectedShift.breaks);calculateHours();}});// Employee count adjustmentdocument.getElementById(`${prefix}-increase-employees`).addEventListener('click', function() {if (selectedShift) {shiftEmployees[selectedShift.name]++;employeeCountDisplay.textContent = shiftEmployees[selectedShift.name];renderShifts();calculateHours();calculateAllShiftsTotal();}});document.getElementById(`${prefix}-decrease-employees`).addEventListener('click', function() {if (selectedShift && shiftEmployees[selectedShift.name] > 0) {shiftEmployees[selectedShift.name]--;employeeCountDisplay.textContent = shiftEmployees[selectedShift.name];renderShifts();calculateHours();calculateAllShiftsTotal();}});// Calculate shift minutesfunction calculateShiftMinutes(shift) {const startParts = shift.start.split(':').map(Number);const endParts = shift.end.split(':').map(Number);let startDate = new Date(0, 0, 0, startParts[0], startParts[1]);let endDate = new Date(0, 0, 0, endParts[0], endParts[1]);if (endDate <= startDate) endDate.setDate(endDate.getDate() + 1);let totalMinutes = (endDate - startDate) / (1000 * 60);shift.breaks.forEach(breakTime => {const [start, end] = breakTime.split('-');const startParts = start.split(':').map(Number);const endParts = end.split(':').map(Number);const startDate = new Date(0, 0, 0, startParts[0], startParts[1]);const endDate = new Date(0, 0, 0, endParts[0], endParts[1]);totalMinutes -= (endDate - startDate) / (1000 * 60);});return totalMinutes;}// Calculate hoursfunction calculateHours() {if (!selectedShift) return;try {const totalMinutes = calculateShiftMinutes(selectedShift);const hours = Math.floor(totalMinutes / 60);const minutes = Math.floor(totalMinutes % 60);hoursPerEmployeeDisplay.textContent = `${hours}h ${minutes}m`;calculateAllShiftsTotal();updateRemainingTodayDisplay();} catch (e) {console.error("Error calculating hours:", e);}}// Calculate all shifts totalfunction calculateAllShiftsTotal() {let totalMinutes = 0;shifts.forEach(shift => {if (shiftEmployees[shift.name] > 0) {const shiftMinutes = calculateShiftMinutes(shift);totalMinutes += shiftMinutes * shiftEmployees[shift.name];}});const hours = Math.floor(totalMinutes / 60);const minutes = Math.floor(totalMinutes % 60);totalHoursDisplay.textContent = `${hours}h ${minutes}m`;}// Update remaining time displayfunction updateRemainingTodayDisplay() {const remainingMinutes = calculateRemainingToday();if (remainingMinutes === undefined) return;const hours = Math.floor(remainingMinutes / 60);const minutes = Math.floor(remainingMinutes % 60);remainingTodayDisplay.textContent = `${hours}h ${minutes}m`;}// Calculate remaining time todayfunction calculateRemainingToday() {const now = new Date();const currentHour = now.getHours();const currentMinute = now.getMinutes();let totalRemainingMinutes = 0;shifts.forEach(shift => {if (shiftEmployees[shift.name] === 0) return;const [shiftStartHour, shiftStartMinute] = shift.start.split(':').map(Number);const [shiftEndHour, shiftEndMinute] = shift.end.split(':').map(Number);if (currentHour < shiftStartHour ||(currentHour === shiftStartHour && currentMinute < shiftStartMinute)) {totalRemainingMinutes += calculateShiftMinutes(shift) * shiftEmployees[shift.name];return;}if (currentHour > shiftEndHour ||(currentHour === shiftEndHour && currentMinute >= shiftEndMinute)) {return;}let remainingMinutes = (shiftEndHour - currentHour) * 60 + (shiftEndMinute - currentMinute);shift.breaks.forEach(breakTime => {const [breakStart, breakEnd] = breakTime.split('-').map(time => {const [h, m] = time.split(':').map(Number);return h * 60 + m;});if (breakStart > (currentHour * 60 + currentMinute)) {remainingMinutes -= (breakEnd - breakStart);} else if (breakStart <= (currentHour * 60 + currentMinute) &&breakEnd > (currentHour * 60 + currentMinute)) {remainingMinutes -= (breakEnd - (currentHour * 60 + currentMinute));}});totalRemainingMinutes += remainingMinutes * shiftEmployees[shift.name];});return totalRemainingMinutes;}// Hourly rate calculationdocument.getElementById(`${prefix}-calculate-rate-btn`).addEventListener('click', function() {const totalAmount = parseFloat(totalAmountInput.value);if (isNaN(totalAmount) || totalAmount <= 0) return;const totalHoursText = totalHoursDisplay.textContent;const [hours, mins] = totalHoursText.split('h ').map(part => parseInt(part));const totalHours = hours + (mins / 60);if (totalHours <= 0) return;const hourlyRate = totalAmount / totalHours;hourlyRateDisplay.textContent = `${hourlyRate.toFixed(2)} rader/h`;});document.getElementById(`${prefix}-calculate-remaining-rate-btn`).addEventListener('click', function() {const totalAmount = parseFloat(totalAmountInput.value);if (isNaN(totalAmount) || totalAmount <= 0) return;const remainingMinutes = calculateRemainingToday();if (remainingMinutes <= 0) return;const remainingHours = remainingMinutes / 60;const hourlyRate = totalAmount / remainingHours;hourlyRateDisplay.textContent = `${hourlyRate.toFixed(2)} rader/h (rem)`;});// Event listenersstartTimeInput.addEventListener('change', calculateHours);endTimeInput.addEventListener('change', calculateHours);// Auto-update remaining time every minutesetInterval(updateRemainingTodayDisplay, 60000);// InitializerenderShifts();calculateAllShiftsTotal();updateRemainingTodayDisplay();}feather.replace();</script></body></html>