Spaces:
Running
Running
Download index.html from deniser224/tally: direct link, hf CLI and curl.
- Browser
- Download file 18 kB
-
https://huggingface.co/spaces/deniser224/tally/resolve/main/index.html
- Command line
-
hf download hf://spaces/deniser224/tally/index.html
-
curl -L -o index.html https://huggingface.co/spaces/deniser224/tally/resolve/main/index.html
18 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Tally Counter</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| @keyframes pulse { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.1); } | |
| 100% { transform: scale(1); } | |
| } | |
| .pulse-animation { | |
| animation: pulse 0.3s ease; | |
| } | |
| .tally-card { | |
| transition: all 0.3s ease; | |
| } | |
| .tally-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 6px rgba(0,0,0,0.1); | |
| } | |
| .slide-in { | |
| animation: slideIn 0.3s ease-out; | |
| } | |
| @keyframes slideIn { | |
| from { transform: translateY(20px); opacity: 0; } | |
| to { transform: translateY(0); opacity: 1; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 font-sans"> | |
| <div class="container mx-auto px-4 py-8 max-w-3xl"> | |
| <!-- Header --> | |
| <header class="mb-8"> | |
| <div class="flex justify-between items-center"> | |
| <h1 class="text-3xl font-bold text-gray-800">Tally Counter</h1> | |
| <button id="settings-btn" class="p-2 rounded-full bg-gray-200 hover:bg-gray-300 transition"> | |
| <i class="fas fa-cog text-gray-600"></i> | |
| </button> | |
| </div> | |
| <p class="text-gray-500 mt-1">Track multiple counts with ease</p> | |
| </header> | |
| <!-- Main Content --> | |
| <main> | |
| <!-- Add New Tally Button --> | |
| <button id="add-tally-btn" class="w-full mb-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition flex items-center justify-center"> | |
| <i class="fas fa-plus mr-2"></i> Add New Tally | |
| </button> | |
| <!-- Tally List --> | |
| <div id="tally-list" class="space-y-4"> | |
| <!-- Tallies will be added here dynamically --> | |
| </div> | |
| </main> | |
| <!-- Settings Modal --> | |
| <div id="settings-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white rounded-xl p-6 w-full max-w-md mx-4 slide-in"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold">Settings</h2> | |
| <button id="close-settings" class="p-2 rounded-full hover:bg-gray-100"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Increment Value</label> | |
| <input type="number" id="increment-value" min="1" value="1" class="w-full px-3 py-2 border border-gray-300 rounded-md"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Tally Divider</label> | |
| <input type="number" id="divider-value" min="1" value="5" class="w-full px-3 py-2 border border-gray-300 rounded-md"> | |
| </div> | |
| <div class="pt-4"> | |
| <button id="save-settings" class="w-full py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-md font-medium transition"> | |
| Save Settings | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Add Tally Modal --> | |
| <div id="add-tally-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white rounded-xl p-6 w-full max-w-md mx-4 slide-in"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-bold">Add New Tally</h2> | |
| <button id="close-add-modal" class="p-2 rounded-full hover:bg-gray-100"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Tally Name</label> | |
| <input type="text" id="new-tally-name" placeholder="e.g. Pushups, Coffee Cups" class="w-full px-3 py-2 border border-gray-300 rounded-md"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Starting Value</label> | |
| <input type="number" id="starting-value" min="0" value="0" class="w-full px-3 py-2 border border-gray-300 rounded-md"> | |
| </div> | |
| <div class="pt-4"> | |
| <button id="confirm-add-tally" class="w-full py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-md font-medium transition"> | |
| Add Tally | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // App State | |
| let state = { | |
| tallies: JSON.parse(localStorage.getItem('tallies')) || [], | |
| settings: { | |
| incrementValue: parseInt(localStorage.getItem('incrementValue')) || 1, | |
| dividerValue: parseInt(localStorage.getItem('dividerValue')) || 5 | |
| } | |
| }; | |
| // DOM Elements | |
| const tallyList = document.getElementById('tally-list'); | |
| const addTallyBtn = document.getElementById('add-tally-btn'); | |
| const settingsBtn = document.getElementById('settings-btn'); | |
| const settingsModal = document.getElementById('settings-modal'); | |
| const closeSettings = document.getElementById('close-settings'); | |
| const saveSettings = document.getElementById('save-settings'); | |
| const incrementValueInput = document.getElementById('increment-value'); | |
| const dividerValueInput = document.getElementById('divider-value'); | |
| const addTallyModal = document.getElementById('add-tally-modal'); | |
| const closeAddModal = document.getElementById('close-add-modal'); | |
| const confirmAddTally = document.getElementById('confirm-add-tally'); | |
| const newTallyNameInput = document.getElementById('new-tally-name'); | |
| const startingValueInput = document.getElementById('starting-value'); | |
| // Initialize | |
| function init() { | |
| renderTallies(); | |
| incrementValueInput.value = state.settings.incrementValue; | |
| dividerValueInput.value = state.settings.dividerValue; | |
| // Event Listeners | |
| addTallyBtn.addEventListener('click', () => { | |
| newTallyNameInput.value = ''; | |
| startingValueInput.value = 0; | |
| addTallyModal.classList.remove('hidden'); | |
| }); | |
| settingsBtn.addEventListener('click', () => { | |
| settingsModal.classList.remove('hidden'); | |
| }); | |
| closeSettings.addEventListener('click', () => { | |
| settingsModal.classList.add('hidden'); | |
| }); | |
| closeAddModal.addEventListener('click', () => { | |
| addTallyModal.classList.add('hidden'); | |
| }); | |
| saveSettings.addEventListener('click', saveAppSettings); | |
| confirmAddTally.addEventListener('click', addNewTally); | |
| // Close modals when clicking outside | |
| window.addEventListener('click', (e) => { | |
| if (e.target === settingsModal) { | |
| settingsModal.classList.add('hidden'); | |
| } | |
| if (e.target === addTallyModal) { | |
| addTallyModal.classList.add('hidden'); | |
| } | |
| }); | |
| } | |
| // Render all tallies | |
| function renderTallies() { | |
| tallyList.innerHTML = ''; | |
| if (state.tallies.length === 0) { | |
| tallyList.innerHTML = ` | |
| <div class="text-center py-8 text-gray-500"> | |
| <i class="fas fa-clipboard-list text-4xl mb-2"></i> | |
| <p>No tallies yet. Add your first tally!</p> | |
| </div> | |
| `; | |
| return; | |
| } | |
| state.tallies.forEach((tally, index) => { | |
| const tallyElement = document.createElement('div'); | |
| tallyElement.className = 'tally-card bg-white rounded-xl shadow-sm p-4 border border-gray-100'; | |
| tallyElement.innerHTML = ` | |
| <div class="flex justify-between items-center mb-3"> | |
| <h3 class="font-medium text-lg">${tally.name}</h3> | |
| <div class="flex space-x-2"> | |
| <button class="edit-tally-btn p-2 text-gray-500 hover:text-blue-500" data-index="${index}"> | |
| <i class="fas fa-pencil-alt"></i> | |
| </button> | |
| <button class="delete-tally-btn p-2 text-gray-500 hover:text-red-500" data-index="${index}"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="flex items-center justify-between mb-4"> | |
| <button class="decrement-btn p-3 bg-gray-100 hover:bg-gray-200 rounded-lg" data-index="${index}"> | |
| <i class="fas fa-minus"></i> | |
| </button> | |
| <div class="text-center"> | |
| <div class="text-4xl font-bold my-2">${tally.value}</div> | |
| <div class="text-sm text-gray-500"> | |
| ${renderTallyMarks(tally.value, state.settings.dividerValue)} | |
| </div> | |
| </div> | |
| <button class="increment-btn p-3 bg-blue-100 hover:bg-blue-200 rounded-lg pulse-animation" data-index="${index}"> | |
| <i class="fas fa-plus"></i> | |
| </button> | |
| </div> | |
| <div class="flex justify-between text-sm text-gray-500"> | |
| <button class="reset-btn px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded" data-index="${index}"> | |
| Reset | |
| </button> | |
| <div>Last updated: ${formatDate(tally.updatedAt)}</div> | |
| </div> | |
| `; | |
| tallyList.appendChild(tallyElement); | |
| }); | |
| // Add event listeners to all buttons | |
| document.querySelectorAll('.increment-btn').forEach(btn => { | |
| btn.addEventListener('click', incrementTally); | |
| }); | |
| document.querySelectorAll('.decrement-btn').forEach(btn => { | |
| btn.addEventListener('click', decrementTally); | |
| }); | |
| document.querySelectorAll('.reset-btn').forEach(btn => { | |
| btn.addEventListener('click', resetTally); | |
| }); | |
| document.querySelectorAll('.delete-tally-btn').forEach(btn => { | |
| btn.addEventListener('click', deleteTally); | |
| }); | |
| document.querySelectorAll('.edit-tally-btn').forEach(btn => { | |
| btn.addEventListener('click', editTally); | |
| }); | |
| } | |
| // Helper to render tally marks | |
| function renderTallyMarks(count, divider) { | |
| if (divider <= 0) return ''; | |
| const fullGroups = Math.floor(count / divider); | |
| const remainder = count % divider; | |
| let marks = ''; | |
| // Add full groups (with diagonal line) | |
| for (let i = 0; i < fullGroups; i++) { | |
| marks += '卌 '; // This is a Unicode character that looks like a tally group | |
| } | |
| // Add remainder marks | |
| if (remainder > 0) { | |
| marks += '|'.repeat(remainder); | |
| } | |
| return marks || '0'; | |
| } | |
| // Format date for display | |
| function formatDate(dateString) { | |
| if (!dateString) return 'Never'; | |
| const date = new Date(dateString); | |
| return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) + | |
| ' ' + date.toLocaleDateString([], { month: 'short', day: 'numeric' }); | |
| } | |
| // Tally Actions | |
| function incrementTally(e) { | |
| const index = e.currentTarget.getAttribute('data-index'); | |
| state.tallies[index].value += state.settings.incrementValue; | |
| state.tallies[index].updatedAt = new Date().toISOString(); | |
| saveState(); | |
| renderTallies(); | |
| // Add pulse animation to the clicked button | |
| e.currentTarget.classList.add('pulse-animation'); | |
| setTimeout(() => { | |
| e.currentTarget.classList.remove('pulse-animation'); | |
| }, 300); | |
| } | |
| function decrementTally(e) { | |
| const index = e.currentTarget.getAttribute('data-index'); | |
| if (state.tallies[index].value > 0) { | |
| state.tallies[index].value -= state.settings.incrementValue; | |
| state.tallies[index].updatedAt = new Date().toISOString(); | |
| saveState(); | |
| renderTallies(); | |
| } | |
| } | |
| function resetTally(e) { | |
| const index = e.currentTarget.getAttribute('data-index'); | |
| state.tallies[index].value = 0; | |
| state.tallies[index].updatedAt = new Date().toISOString(); | |
| saveState(); | |
| renderTallies(); | |
| } | |
| function deleteTally(e) { | |
| const index = e.currentTarget.getAttribute('data-index'); | |
| if (confirm(`Are you sure you want to delete "${state.tallies[index].name}"?`)) { | |
| state.tallies.splice(index, 1); | |
| saveState(); | |
| renderTallies(); | |
| } | |
| } | |
| function editTally(e) { | |
| const index = e.currentTarget.getAttribute('data-index'); | |
| const tally = state.tallies[index]; | |
| newTallyNameInput.value = tally.name; | |
| startingValueInput.value = tally.value; | |
| const oldConfirmHandler = confirmAddTally.onclick; | |
| confirmAddTally.onclick = function() { | |
| const newName = newTallyNameInput.value.trim(); | |
| const newValue = parseInt(startingValueInput.value) || 0; | |
| if (newName) { | |
| state.tallies[index].name = newName; | |
| state.tallies[index].value = newValue; | |
| state.tallies[index].updatedAt = new Date().toISOString(); | |
| saveState(); | |
| renderTallies(); | |
| addTallyModal.classList.add('hidden'); | |
| // Restore original handler | |
| confirmAddTally.onclick = oldConfirmHandler; | |
| } | |
| }; | |
| addTallyModal.classList.remove('hidden'); | |
| } | |
| // Add new tally | |
| function addNewTally() { | |
| const name = newTallyNameInput.value.trim(); | |
| const value = parseInt(startingValueInput.value) || 0; | |
| if (name) { | |
| state.tallies.push({ | |
| name, | |
| value, | |
| createdAt: new Date().toISOString(), | |
| updatedAt: new Date().toISOString() | |
| }); | |
| saveState(); | |
| renderTallies(); | |
| addTallyModal.classList.add('hidden'); | |
| } | |
| } | |
| // Save settings | |
| function saveAppSettings() { | |
| state.settings.incrementValue = parseInt(incrementValueInput.value) || 1; | |
| state.settings.dividerValue = parseInt(dividerValueInput.value) || 5; | |
| localStorage.setItem('incrementValue', state.settings.incrementValue); | |
| localStorage.setItem('dividerValue', state.settings.dividerValue); | |
| settingsModal.classList.add('hidden'); | |
| renderTallies(); | |
| } | |
| // Save state to localStorage | |
| function saveState() { | |
| localStorage.setItem('tallies', JSON.stringify(state.tallies)); | |
| } | |
| // Initialize the app | |
| init(); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=deniser224/tally" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |