Spaces:
g
Running

g / index.html
sfssss's picture
Add 2 files
0f3ddf2 verified
Raw History Blame Contribute Delete
18.6 kB
<!DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DAL wala milk</title>
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
@keyframes slideIn {
from { transform: translateX(-50px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #f5e6ff, #ffe6e6, #ffebcc);
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}
h1 {
text-align: center;
color: #9c27b0;
text-shadow: 2px 2px 3px #ccc;
margin-bottom: 30px;
font-size: 32px;
background: linear-gradient(to right, #f3e5f5, #e1bee7);
padding: 15px;
border-radius: 15px;
border: 3px solid #8e24aa;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
width: 100%;
max-width: 800px;
animation: pulse 2s infinite ease-in-out, fadeIn 1s ease-out;
}
.date-container {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 30px;
width: 100%;
max-width: 800px;
}
.date-row {
display: flex;
background-color: #fff;
border-radius: 12px;
padding: 15px;
box-shadow: 0 3px 6px rgba(0,0,0,0.1);
border-left: 5px solid #9c27b0;
transition: transform 0.3s, box-shadow 0.3s;
justify-content: center;
width: 100%;
animation: slideIn 0.5s ease-out;
animation-fill-mode: both;
}
.date-row:hover {
transform: translateY(-2px);
box-shadow: 0 5px 10px rgba(0,0,0,0.15);
}
.date-row:nth-child(odd) {
border-left: 5px solid #e91e63;
}
.date-row:nth-child(3n+1) {
border-left: 5px solid #673ab7;
}
.date-row:nth-child(4n+1) {
border-left: 5px solid #3f51b5;
}
.date-row:nth-child(5n+1) {
border-left: 5px solid #009688;
}
.date {
width: 120px;
font-weight: bold;
display: flex;
align-items: center;
color: #333;
}
.checkboxes {
display: flex;
gap: 20px;
flex-grow: 1;
align-items: center;
}
.checkbox-container {
display: flex;
align-items: center;
gap: 5px;
position: relative;
}
input[type="radio"] {
width: 20px;
height: 20px;
cursor: pointer;
accent-color: #9c27b0;
}
input[type="radio"]:checked + label {
color: #9c27b0;
font-weight: bold;
transform: scale(1.1);
transition: all 0.3s ease;
}
input[type="text"] {
width: 60px;
padding: 5px;
border: 2px solid #9c27b0;
border-radius: 5px;
font-size: 14px;
text-align: center;
transition: all 0.3s ease;
}
input[type="text"]:focus {
border-color: #e91e63;
box-shadow: 0 0 8px rgba(233, 30, 99, 0.5);
outline: none;
}
label {
font-size: 16px;
cursor: pointer;
font-weight: 500;
color: #555;
transition: all 0.3s ease;
}
.summary {
margin-top: 20px;
background: linear-gradient(to right, #f3e5f5, #e1bee7);
padding: 20px;
border-radius: 12px;
border: 2px solid #ce93d8;
display: flex;
flex-direction: column;
gap: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
width: 100%;
max-width: 800px;
margin-bottom: 80px;
animation: fadeIn 1s ease-out;
}
.summary-row {
display: flex;
justify-content: space-between;
}
.summary-item {
font-size: 20px;
font-weight: bold;
color: #7b1fa2;
}
.amount {
color: #e91e63;
}
.breakdown {
font-size: 14px;
color: #666;
margin-top: 10px;
border-top: 1px dashed #ce93d8;
padding-top: 10px;
}
.breakdown-item {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
}
.delete-btn {
background-color: #ff5252;
color: white;
border: none;
border-radius: 4px;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 1;
cursor: pointer;
margin-left: 5px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.delete-btn:hover {
background-color: #ff1744;
transform: scale(1.1);
}
.custom-milk-label {
font-weight: bold;
color: #9c27b0;
margin-right: 5px;
}
@media (max-width: 600px) {
.checkboxes {
flex-wrap: wrap;
}
.date-row {
flex-direction: column;
gap: 10px;
}
.date {
width: 100%;
justify-content: center;
}
}
</style>
</head>
<body>
<h1>DAL wala milk</h1>
<div class="date-container" id="dateContainer">
</div>
<div class="summary" id="summary">
<div class="summary-row">
<div class="summary-item">कुल दूध: <span id="totalMilk">0</span> kg</div>
<div class="summary-item amount">कुल राशि: ₹<span id="totalAmount">0</span></div>
</div>
<div class="breakdown" id="breakdown">
</div>
</div>
<script>
function generateDates() {
const dateContainer = document.getElementById('dateContainer');
const startDate = new Date(2025, 3, 1); // April 1, 2025
const endDate = new Date(2025, 4, 1); // May 1, 2025 (inclusive)
let currentDate = new Date(startDate);
let index = 0;
while (currentDate <= endDate) {
const dateRow = document.createElement('div');
dateRow.className = 'date-row';
dateRow.style.animationDelay = `${index * 0.05}s`;
const dateOptions = { day: 'numeric', month: 'short', year: 'numeric' };
const formattedDate = currentDate.toLocaleDateString('hi-IN', dateOptions);
const dateElement = document.createElement('div');
dateElement.className = 'date';
dateElement.textContent = formattedDate;
const checkboxesContainer = document.createElement('div');
checkboxesContainer.className = 'checkboxes';
const dateString = currentDate.toISOString().split('T')[0];
const radioGroupName = `radio-${dateString}`;
const radio500gm = createRadio('500gm', currentDate, radioGroupName);
const radio1kg = createRadio('1kg', currentDate, radioGroupName);
const radio125kg = createRadio('1.25kg', currentDate, radioGroupName);
const customMilkContainer = document.createElement('div');
customMilkContainer.className = 'checkbox-container';
const customMilkLabel = document.createElement('label');
customMilkLabel.className = 'custom-milk-label';
customMilkLabel.textContent = 'कस्टम:';
const customMilkInput = document.createElement('input');
customMilkInput.type = 'text';
customMilkInput.id = `custom-${dateString}`;
customMilkInput.dataset.date = dateString;
customMilkInput.placeholder = 'दूध gm';
customMilkInput.addEventListener('input', function() {
if (this.value) {
const radios = document.querySelectorAll(`input[name="${radioGroupName}"]`);
radios.forEach(radio => {
radio.checked = false;
});
updateSummary();
}
});
customMilkContainer.appendChild(customMilkLabel);
customMilkContainer.appendChild(customMilkInput);
const deleteContainer = document.createElement('div');
deleteContainer.className = 'checkbox-container';
const deleteBtn = document.createElement('button');
deleteBtn.className = 'delete-btn';
deleteBtn.textContent = '×';
deleteBtn.title = 'हटाएं';
deleteBtn.dataset.date = dateString;
deleteBtn.onclick = function() {
clearDateSelection(this.dataset.date);
};
deleteContainer.appendChild(deleteBtn);
checkboxesContainer.appendChild(radio500gm);
checkboxesContainer.appendChild(radio1kg);
checkboxesContainer.appendChild(radio125kg);
checkboxesContainer.appendChild(customMilkContainer);
checkboxesContainer.appendChild(deleteContainer);
dateRow.appendChild(dateElement);
dateRow.appendChild(checkboxesContainer);
dateContainer.appendChild(dateRow);
currentDate.setDate(currentDate.getDate() + 1);
index++;
}
loadSavedData();
}
function createRadio(weight, date, groupName) {
const container = document.createElement('div');
container.className = 'checkbox-container';
const dateString = date.toISOString().split('T')[0];
const id = `${dateString}-${weight}`;
const radio = document.createElement('input');
radio.type = 'radio';
radio.id = id;
radio.name = groupName;
radio.value = weight;
if (weight === '500gm') {
radio.dataset.weight = '500';
} else if (weight === '1kg') {
radio.dataset.weight = '1000';
} else if (weight === '1.25kg') {
radio.dataset.weight = '1250';
}
radio.dataset.date = dateString;
radio.dataset.displayWeight = weight;
radio.addEventListener('change', function() {
document.getElementById(`custom-${dateString}`).value = '';
updateSummary();
});
const label = document.createElement('label');
label.htmlFor = id;
label.textContent = weight;
container.appendChild(radio);
container.appendChild(label);
return container;
}
function clearDateSelection(dateString) {
const radios = document.querySelectorAll(`input[data-date="${dateString}"][type="radio"]`);
radios.forEach(radio => {
radio.checked = false;
});
const customInput = document.getElementById(`custom-${dateString}`);
if (customInput) {
customInput.value = '';
}
updateSummary();
}
function updateSummary() {
const radios = document.querySelectorAll('input[type="radio"]:checked');
const customInputs = document.querySelectorAll('input[type="text"]');
let totalMilkGrams = 0;
let count500gm = 0;
let count1kg = 0;
let count125kg = 0;
let countCustom = 0;
let customGrams = 0;
radios.forEach(radio => {
const weightValue = parseFloat(radio.dataset.weight);
totalMilkGrams += weightValue;
if (weightValue === 500) count500gm++;
else if (weightValue === 1000) count1kg++;
else if (weightValue === 1250) count125kg++;
});
customInputs.forEach(input => {
if (input.value && !isNaN(parseFloat(input.value))) {
const inputValue = parseFloat(input.value);
totalMilkGrams += inputValue;
countCustom++;
customGrams += inputValue;
}
});
const totalMilkKg = totalMilkGrams / 1000;
const totalAmount = totalMilkKg * 40; // Price at ₹40 per kg
document.getElementById('totalMilk').textContent = totalMilkKg.toFixed(2);
document.getElementById('totalAmount').textContent = totalAmount.toFixed(0);
const breakdownDiv = document.getElementById('breakdown');
breakdownDiv.innerHTML = '';
if (count500gm > 0) {
const div = document.createElement('div');
div.className = 'breakdown-item';
div.innerHTML = `<span>500gm: ${count500gm} दिन</span> <span>${(count500gm * 500 / 1000).toFixed(2)} kg</span>`;
breakdownDiv.appendChild(div);
}
if (count1kg > 0) {
const div = document.createElement('div');
div.className = 'breakdown-item';
div.innerHTML = `<span>1kg: ${count1kg} दिन</span> <span>${count1kg.toFixed(2)} kg</span>`;
breakdownDiv.appendChild(div);
}
if (count125kg > 0) {
const div = document.createElement('div');
div.className = 'breakdown-item';
div.innerHTML = `<span>1.25kg: ${count125kg} दिन</span> <span>${(count125kg * 1.25).toFixed(2)} kg</span>`;
breakdownDiv.appendChild(div);
}
if (countCustom > 0) {
const div = document.createElement('div');
div.className = 'breakdown-item';
div.innerHTML = `<span>कस्टम: ${countCustom} दिन</span> <span>${(customGrams / 1000).toFixed(2)} kg</span>`;
breakdownDiv.appendChild(div);
}
saveData(); // Auto-save on summary update
}
function saveData() {
const allRadios = document.querySelectorAll('input[type="radio"]');
const allCustomInputs = document.querySelectorAll('input[type="text"]');
const data = {
radios: {},
customInputs: {}
};
allRadios.forEach(radio => {
data.radios[radio.id] = radio.checked;
});
allCustomInputs.forEach(input => {
data.customInputs[input.id] = input.value;
});
localStorage.setItem('dalWalaMilkData', JSON.stringify(data));
}
function loadSavedData() {
const savedData = localStorage.getItem('dalWalaMilkData');
if (savedData) {
const data = JSON.parse(savedData);
if (data.radios) {
Object.keys(data.radios).forEach(id => {
const radio = document.getElementById(id);
if (radio && data.radios[id]) {
radio.checked = true;
}
});
}
if (data.customInputs) {
Object.keys(data.customInputs).forEach(id => {
const input = document.getElementById(id);
if (input && data.customInputs[id]) {
input.value = data.customInputs[id];
}
});
}
updateSummary();
}
}
window.onload = function() {
generateDates();
};
</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=sfssss/g" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>