Download index.html from NeoTechEra/construction-calculator: direct link, hf CLI and curl.
- Browser
- Download file 18.9 kB
-
https://huggingface.co/spaces/NeoTechEra/construction-calculator/resolve/main/index.html
- Command line
-
hf download hf://spaces/NeoTechEra/construction-calculator/index.html
-
curl -L -o index.html https://huggingface.co/spaces/NeoTechEra/construction-calculator/resolve/main/index.html
18.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Construction Calculator</title> | |
| <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> | |
| <style> | |
| .calculator-btn:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | |
| } | |
| .btn-primary { | |
| background-color: #3b82f6; | |
| color: white; | |
| } | |
| .btn-primary:hover { | |
| background-color: #2563eb; | |
| } | |
| .btn-secondary { | |
| background-color: #e5e7eb; | |
| color: #1f2937; | |
| } | |
| .btn-secondary:hover { | |
| background-color: #d1d5db; | |
| } | |
| .material-selector input:checked + label { | |
| background-color: #3b82f6; | |
| color: white; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <header class="mb-8 text-center"> | |
| <h1 class="text-3xl font-bold text-gray-800 mb-2">Construction Calculator</h1> | |
| <p class="text-gray-600">Calculate materials and costs for your construction projects</p> | |
| </header> | |
| <div class="max-w-4xl mx-auto bg-white rounded-xl shadow-md overflow-hidden"> | |
| <div class="grid md:grid-cols-2 gap-6 p-6"> | |
| <!-- Calculator Section --> | |
| <div class="calculator-section bg-gray-50 p-6 rounded-lg"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-700">Area Calculator</h2> | |
| <div class="grid grid-cols-1 gap-4"> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Shape</label> | |
| <select id="shape" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| <option value="rectangle">Rectangle</option> | |
| <option value="triangle">Triangle</option> | |
| <option value="circle">Circle</option> | |
| </select> | |
| </div> | |
| <div id="rectangle-inputs"> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Length (ft)</label> | |
| <input type="number" id="length" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="0"> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Width (ft)</label> | |
| <input type="number" id="width" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="0"> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="triangle-inputs" class="hidden"> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Base (ft)</label> | |
| <input type="number" id="base" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="0"> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Height (ft)</label> | |
| <input type="number" id="height" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="0"> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="circle-inputs" class="hidden"> | |
| <div> | |
| <label class="block text-gray-700 mb-2">Radius (ft)</label> | |
| <input type="number" id="radius" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="0"> | |
| </div> | |
| </div> | |
| <div class="mt-4"> | |
| <label class="block text-gray-700 mb-2">Material Type</label> | |
| <div class="material-selector grid grid-cols-3 gap-2"> | |
| <input type="radio" name="material" id="concrete" value="concrete" class="hidden" checked> | |
| <label for="concrete" class="px-3 py-2 border border-gray-300 rounded-md text-center cursor-pointer transition"> | |
| <i data-feather="box" class="inline mr-2"></i> Concrete | |
| </label> | |
| <input type="radio" name="material" id="bricks" value="bricks" class="hidden"> | |
| <label for="bricks" class="px-3 py-2 border border-gray-300 rounded-md text-center cursor-pointer transition"> | |
| <i data-feather="square" class="inline mr-2"></i> Bricks | |
| </label> | |
| <input type="radio" name="material" id="wood" value="wood" class="hidden"> | |
| <label for="wood" class="px-3 py-2 border border-gray-300 rounded-md text-center cursor-pointer transition"> | |
| <i data-feather="grid" class="inline mr-2"></i> Wood | |
| </label> | |
| </div> | |
| </div> | |
| <div id="thickness-input" class="mt-4"> | |
| <label class="block text-gray-700 mb-2">Thickness (in)</label> | |
| <input type="number" id="thickness" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="4" value="4"> | |
| </div> | |
| <button id="calculate-btn" class="w-full mt-4 py-3 px-4 btn-primary rounded-md font-medium transition"> | |
| <i data-feather="calculator" class="inline mr-2"></i> Calculate | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Results Section --> | |
| <div class="results-section bg-white border border-gray-200 p-6 rounded-lg"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-700">Results</h2> | |
| <div class="space-y-4"> | |
| <div class="grid grid-cols-2 gap-2 items-center"> | |
| <div class="text-gray-600">Area:</div> | |
| <div id="area-result" class="font-semibold text-blue-600">0 sq ft</div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-2 items-center"> | |
| <div class="text-gray-600">Volume:</div> | |
| <div id="volume-result" class="font-semibold text-blue-600">0 cu ft</div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-2 items-center"> | |
| <div class="text-gray-600">Material Needed:</div> | |
| <div id="material-result" class="font-semibold text-blue-600">0 units</div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-2 items-center"> | |
| <div class="text-gray-600">Cost Estimate:</div> | |
| <div id="cost-result" class="font-semibold text-blue-600">$0</div> | |
| </div> | |
| </div> | |
| <div class="mt-6 p-4 bg-yellow-50 border border-yellow-200 rounded-lg"> | |
| <h3 class="font-medium text-yellow-800 mb-2">Material Information</h3> | |
| <div id="material-info" class="text-sm text-yellow-700"> | |
| Select a material type to see coverage and cost details. | |
| </div> | |
| </div> | |
| <div class="mt-6"> | |
| <button id="save-btn" class="w-full py-2 px-4 btn-secondary rounded-md font-medium transition"> | |
| <i data-feather="save" class="inline mr-2"></i> Save Calculation | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Saved Calculations --> | |
| <div class="max-w-4xl mx-auto mt-8 bg-white rounded-xl shadow-md overflow-hidden"> | |
| <div class="p-6"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-700">Saved Calculations</h2> | |
| <div id="saved-list" class="space-y-2"> | |
| <div class="py-2 text-center text-gray-500"> | |
| No saved calculations yet | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| feather.replace(); | |
| // Initialize saved calculations array | |
| let savedCalculations = JSON.parse(localStorage.getItem('savedCalculations')) || []; | |
| // Material data | |
| const materialData = { | |
| concrete: { | |
| name: "Concrete", | |
| coverage: 0.25, // cubic feet per 50lb bag | |
| unit: "50lb bags", | |
| costPerUnit: 5.50, | |
| info: "Standard concrete mix covers ~0.25 cubic feet per 50lb bag. Always purchase 10% extra to account for waste." | |
| }, | |
| bricks: { | |
| name: "Bricks", | |
| coverage: 4.5, // bricks per square foot | |
| unit: "bricks", | |
| costPerUnit: 0.75, | |
| info: "Standard bricks (8x2.25x3.75 in) require about 4.5 per square foot with mortar. Include 5-10% extra for cuts and breakage." | |
| }, | |
| wood: { | |
| name: "Wood", | |
| coverage: 10, // square feet per board | |
| unit: "boards", | |
| costPerUnit: 8.00, | |
| info: "Standard board (1x6x8ft) covers ~10 square feet. Always add 15% for waste on cutting and defects." | |
| } | |
| }; | |
| // Initialize DOM elements | |
| const shapeSelect = document.getElementById('shape'); | |
| const rectangleInputs = document.getElementById('rectangle-inputs'); | |
| const triangleInputs = document.getElementById('triangle-inputs'); | |
| const circleInputs = document.getElementById('circle-inputs'); | |
| const calculateBtn = document.getElementById('calculate-btn'); | |
| const saveBtn = document.getElementById('save-btn'); | |
| // Result elements | |
| const areaResult = document.getElementById('area-result'); | |
| const volumeResult = document.getElementById('volume-result'); | |
| const materialResult = document.getElementById('material-result'); | |
| const costResult = document.getElementById('cost-result'); | |
| const materialInfo = document.getElementById('material-info'); | |
| const savedList = document.getElementById('saved-list'); | |
| // Shape selection handler | |
| shapeSelect.addEventListener('change', function() { | |
| rectangleInputs.classList.add('hidden'); | |
| triangleInputs.classList.add('hidden'); | |
| circleInputs.classList.add('hidden'); | |
| switch(this.value) { | |
| case 'rectangle': | |
| rectangleInputs.classList.remove('hidden'); | |
| break; | |
| case 'triangle': | |
| triangleInputs.classList.remove('hidden'); | |
| break; | |
| case 'circle': | |
| circleInputs.classList.remove('hidden'); | |
| break; | |
| } | |
| }); | |
| // Material selection handler | |
| document.querySelectorAll('input[name="material"]').forEach(radio => { | |
| radio.addEventListener('change', function() { | |
| if (this.checked) { | |
| updateMaterialInfo(this.value); | |
| } | |
| }); | |
| }); | |
| function updateMaterialInfo(material) { | |
| const data = materialData[material]; | |
| materialInfo.innerHTML = `<strong>${data.name}:</strong> ${data.info}`; | |
| } | |
| // Calculate function | |
| calculateBtn.addEventListener('click', function() { | |
| const shape = shapeSelect.value; | |
| const material = document.querySelector('input[name="material"]:checked').value; | |
| const thickness = parseFloat(document.getElementById('thickness').value); | |
| let area = 0; | |
| switch(shape) { | |
| case 'rectangle': | |
| const length = parseFloat(document.getElementById('length').value); | |
| const width = parseFloat(document.getElementById('width').value); | |
| area = length * width; | |
| break; | |
| case 'triangle': | |
| const base = parseFloat(document.getElementById('base').value); | |
| const height = parseFloat(document.getElementById('height').value); | |
| area = (base * height) / 2; | |
| break; | |
| case 'circle': | |
| const radius = parseFloat(document.getElementById('radius').value); | |
| area = Math.PI * Math.pow(radius, 2); | |
| break; | |
| } | |
| // Calculate volume (convert thickness from inches to feet) | |
| const thicknessInFeet = thickness / 12; | |
| const volume = area * thicknessInFeet; | |
| // Calculate material needed and cost | |
| const materialDataForType = materialData[material]; | |
| let materialNeeded; | |
| if (material === 'concrete') { | |
| materialNeeded = volume / materialDataForType.coverage; | |
| } else { | |
| materialNeeded = area * materialDataForType.coverage; | |
| } | |
| const cost = materialNeeded * materialDataForType.costPerUnit; | |
| // Update results | |
| areaResult.textContent = area.toFixed(2) + ' sq ft'; | |
| volumeResult.textContent = volume.toFixed(2) + ' cu ft'; | |
| materialResult.textContent = Math.ceil(materialNeeded) + ' ' + materialDataForType.unit; | |
| costResult.textContent = '$' + cost.toFixed(2); | |
| }); | |
| // Save calculation | |
| saveBtn.addEventListener('click', function() { | |
| const shape = shapeSelect.options[shapeSelect.selectedIndex].text; | |
| const material = document.querySelector('input[name="material"]:checked').value; | |
| const area = areaResult.textContent; | |
| const materialNeeded = materialResult.textContent; | |
| const cost = costResult.textContent; | |
| if (area === '0 sq ft') { | |
| alert('Please calculate something before saving'); | |
| return; | |
| } | |
| // Create calculation object | |
| const calculation = { | |
| shape, | |
| material, | |
| area, | |
| materialNeeded, | |
| cost, | |
| timestamp: new Date().getTime() | |
| }; | |
| // Add to saved calculations array | |
| savedCalculations.unshift(calculation); | |
| // Save to localStorage | |
| localStorage.setItem('savedCalculations', JSON.stringify(savedCalculations)); | |
| // Update the display | |
| updateSavedList(); | |
| }); | |
| // Function to delete a saved calculation | |
| function deleteCalculation(index) { | |
| savedCalculations.splice(index, 1); | |
| localStorage.setItem('savedCalculations', JSON.stringify(savedCalculations)); | |
| updateSavedList(); | |
| } | |
| // Function to update the saved calculations list | |
| function updateSavedList() { | |
| if (savedCalculations.length === 0) { | |
| savedList.innerHTML = ` | |
| <div class="py-2 text-center text-gray-500"> | |
| No saved calculations yet | |
| </div> | |
| `; | |
| return; | |
| } | |
| savedList.innerHTML = ''; | |
| savedCalculations.forEach((calc, index) => { | |
| const savedItem = document.createElement('div'); | |
| savedItem.className = 'p-3 border border-gray-200 rounded-md flex justify-between items-center'; | |
| savedItem.innerHTML = ` | |
| <div> | |
| <span class="font-medium">${calc.shape}</span> • | |
| <span class="text-blue-600">${materialData[calc.material].name}</span> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <span>${calc.area}</span> | |
| <span>${calc.materialNeeded}</span> | |
| <span class="font-semibold">${calc.cost}</span> | |
| <button class="delete-btn text-red-500 hover:text-red-700" data-index="${index}"> | |
| <i data-feather="trash-2" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| `; | |
| savedList.appendChild(savedItem); | |
| }); | |
| feather.replace(); | |
| // Add event listeners to delete buttons | |
| document.querySelectorAll('.delete-btn').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| deleteCalculation(parseInt(this.dataset.index)); | |
| }); | |
| }); | |
| } | |
| // Initialize with saved calculations on page load | |
| updateSavedList(); | |
| // Initialize with concrete info | |
| updateMaterialInfo('concrete'); | |
| // Load saved calculations on page load | |
| document.addEventListener('DOMContentLoaded', function() { | |
| if (savedCalculations.length > 0) { | |
| updateSavedList(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |