Spaces:
Running
Running
undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +100 -18
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: calculator
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,101 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Minimal Scientific Calculator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
.btn {
|
| 10 |
+
transition: all 0.2s ease;
|
| 11 |
+
}
|
| 12 |
+
.btn:active {
|
| 13 |
+
transform: scale(0.95);
|
| 14 |
+
}
|
| 15 |
+
#display {
|
| 16 |
+
height: 2.5rem;
|
| 17 |
+
}
|
| 18 |
+
</style>
|
| 19 |
+
</head>
|
| 20 |
+
<body class="bg-gray-100 min-h-screen flex items-center justify-center">
|
| 21 |
+
<div class="bg-white rounded-xl shadow-xl overflow-hidden w-80">
|
| 22 |
+
<div class="p-4 bg-gray-50">
|
| 23 |
+
<input id="display" class="w-full text-right text-2xl font-medium bg-transparent outline-none" readonly>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div class="grid grid-cols-4 gap-1 p-2 bg-gray-100">
|
| 27 |
+
<button onclick="clearAll()" class="btn bg-red-500 hover:bg-red-600 text-white font-medium py-3 rounded-lg">C</button>
|
| 28 |
+
<button onclick="backspace()" class="btn bg-gray-300 hover:bg-gray-400 py-3 rounded-lg">←</button>
|
| 29 |
+
<button onclick="append('%')" class="btn bg-gray-300 hover:bg-gray-400 py-3 rounded-lg">%</button>
|
| 30 |
+
<button onclick="append('/')" class="btn bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 rounded-lg">/</button>
|
| 31 |
+
|
| 32 |
+
<button onclick="append('7')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">7</button>
|
| 33 |
+
<button onclick="append('8')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">8</button>
|
| 34 |
+
<button onclick="append('9')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">9</button>
|
| 35 |
+
<button onclick="append('*')" class="btn bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 rounded-lg">×</button>
|
| 36 |
+
|
| 37 |
+
<button onclick="append('4')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">4</button>
|
| 38 |
+
<button onclick="append('5')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">5</button>
|
| 39 |
+
<button onclick="append('6')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">6</button>
|
| 40 |
+
<button onclick="append('-')" class="btn bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 rounded-lg">-</button>
|
| 41 |
+
|
| 42 |
+
<button onclick="append('1')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">1</button>
|
| 43 |
+
<button onclick="append('2')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">2</button>
|
| 44 |
+
<button onclick="append('3')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">3</button>
|
| 45 |
+
<button onclick="append('+')" class="btn bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 rounded-lg">+</button>
|
| 46 |
+
|
| 47 |
+
<button onclick="append('0')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg col-span-2">0</button>
|
| 48 |
+
<button onclick="append('.')" class="btn bg-white hover:bg-gray-100 py-3 rounded-lg">.</button>
|
| 49 |
+
<button onclick="calculate()" class="btn bg-green-500 hover:bg-green-600 text-white font-medium py-3 rounded-lg">=</button>
|
| 50 |
+
|
| 51 |
+
<!-- Scientific functions -->
|
| 52 |
+
<button onclick="append('Math.sin(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">sin</button>
|
| 53 |
+
<button onclick="append('Math.cos(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">cos</button>
|
| 54 |
+
<button onclick="append('Math.tan(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">tan</button>
|
| 55 |
+
<button onclick="append('Math.sqrt(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">√</button>
|
| 56 |
+
|
| 57 |
+
<button onclick="append('Math.log(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">log</button>
|
| 58 |
+
<button onclick="append('Math.PI')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">π</button>
|
| 59 |
+
<button onclick="append('Math.pow(')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">x^y</button>
|
| 60 |
+
<button onclick="append(')')" class="btn bg-purple-100 hover:bg-purple-200 py-3 rounded-lg text-sm">)</button>
|
| 61 |
+
</div>
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<script>
|
| 65 |
+
const display = document.getElementById('display');
|
| 66 |
+
let currentInput = '';
|
| 67 |
+
|
| 68 |
+
function append(value) {
|
| 69 |
+
currentInput += value;
|
| 70 |
+
display.value = currentInput;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
function clearAll() {
|
| 74 |
+
currentInput = '';
|
| 75 |
+
display.value = '';
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function backspace() {
|
| 79 |
+
currentInput = currentInput.slice(0, -1);
|
| 80 |
+
display.value = currentInput;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function calculate() {
|
| 84 |
+
try {
|
| 85 |
+
// Replace visual operators with JavaScript operators
|
| 86 |
+
let expression = currentInput
|
| 87 |
+
.replace(/×/g, '*')
|
| 88 |
+
.replace(/÷/g, '/');
|
| 89 |
+
|
| 90 |
+
// Evaluate the expression
|
| 91 |
+
const result = eval(expression);
|
| 92 |
+
currentInput = result.toString();
|
| 93 |
+
display.value = currentInput;
|
| 94 |
+
} catch (error) {
|
| 95 |
+
display.value = 'Error';
|
| 96 |
+
currentInput = '';
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
</script>
|
| 100 |
+
</body>
|
| 101 |
</html>
|
prompts.txt
ADDED
|
File without changes
|